aboutsummaryrefslogtreecommitdiffstats
path: root/dashboard/app/batch_db_export.go
diff options
context:
space:
mode:
authorTaras Madan <tarasmadan@google.com>2024-11-12 11:17:28 +0100
committerTaras Madan <tarasmadan@google.com>2024-11-12 11:55:16 +0000
commitc819f2276e0861eaf83d155441072013ec914f3c (patch)
tree949d934edeb8c459892347b225d09361beffde83 /dashboard/app/batch_db_export.go
parent75bb1b32609dc8e20e442a992f648e465c66cdf3 (diff)
dashboard/app: change tool name to db-export
Diffstat (limited to 'dashboard/app/batch_db_export.go')
-rw-r--r--dashboard/app/batch_db_export.go42
1 files changed, 42 insertions, 0 deletions
diff --git a/dashboard/app/batch_db_export.go b/dashboard/app/batch_db_export.go
new file mode 100644
index 000000000..9ca294d70
--- /dev/null
+++ b/dashboard/app/batch_db_export.go
@@ -0,0 +1,42 @@
+// Copyright 2024 syzkaller project authors. All rights reserved.
+// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
+
+package main
+
+import (
+ "net/http"
+
+ "cloud.google.com/go/batch/apiv1/batchpb"
+ "google.golang.org/appengine/v2"
+ "google.golang.org/appengine/v2/log"
+)
+
+const exportTimeoutSeconds = 60 * 60 * 6
+
+func handleBatchDBExport(w http.ResponseWriter, r *http.Request) {
+ ctx := appengine.NewContext(r)
+ for ns, nsConfig := range getConfig(ctx).Namespaces {
+ if nsConfig.ReproExportPath == "" {
+ continue
+ }
+ serviceAccount := &batchpb.ServiceAccount{
+ Scopes: []string{"https://www.googleapis.com/auth/userinfo.email"},
+ }
+ if err := createScriptJob(ctx, "syzkaller", "db-export",
+ exportDBScript(ns, nsConfig.ReproExportPath), exportTimeoutSeconds, serviceAccount); err != nil {
+ log.Errorf(ctx, "createScriptJob: %s", err.Error())
+ }
+ }
+}
+
+func exportDBScript(srcNamespace, archivePath string) string {
+ return "\n" +
+ "git clone -q --depth 1 --branch master --single-branch https://github.com/google/syzkaller\n" +
+ "cd syzkaller\n" +
+ "token=$(gcloud auth print-access-token)\n" +
+ "CI=1 ./tools/syz-env \"" + // CI=1 to suppress "The input device is not a TTY".
+ "go run ./tools/syz-db-export/... -namespace " + srcNamespace + " -output export -token $token -j 10 && " +
+ "tar -czf export.tar.gz ./export/ && " +
+ "gsutil -q -m cp export.tar.gz " + archivePath +
+ "\""
+}