diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2025-01-16 18:33:58 +0100 |
|---|---|---|
| committer | Aleksandr Nogikh <nogikh@google.com> | 2025-01-22 13:17:53 +0000 |
| commit | f860a27a963cf1411f34b5f14332bbd2b9f41d8b (patch) | |
| tree | c867e5e30972aecdc8476536ec111df90b0845c4 | |
| parent | cc143e38041972ad4dbaff9cfbfd416c29d581b5 (diff) | |
syz-cluster: remove submit-test
It's not necessary - submit the results from the individual steps
instead.
Report patched kernel build failures as findings.
| -rw-r--r-- | syz-cluster/Makefile | 6 | ||||
| -rw-r--r-- | syz-cluster/pkg/workflow/template.yaml | 38 | ||||
| -rw-r--r-- | syz-cluster/workflow/build-step/main.go | 56 | ||||
| -rw-r--r-- | syz-cluster/workflow/build-step/workflow-template.yaml | 14 | ||||
| -rw-r--r-- | syz-cluster/workflow/submit-test/Dockerfile | 22 | ||||
| -rw-r--r-- | syz-cluster/workflow/submit-test/main.go | 38 |
6 files changed, 74 insertions, 100 deletions
diff --git a/syz-cluster/Makefile b/syz-cluster/Makefile index 3fdc07579..a248a4af4 100644 --- a/syz-cluster/Makefile +++ b/syz-cluster/Makefile @@ -37,15 +37,11 @@ build-build-step-dev: eval $$(minikube docker-env);\ docker build -t build-step-local -f ./workflow/build-step/Dockerfile ../ -build-submit-test-dev: - eval $$(minikube docker-env);\ - docker build -t submit-test-local -f ./workflow/submit-test/Dockerfile ../ - build-go-tests-dev: eval $$(minikube docker-env);\ docker build -t go-tests-local -f Dockerfile.go-tests ../ -build-workflow-dev: build-triage-step-dev build-build-step-dev build-submit-test-dev +build-workflow-dev: build-triage-step-dev build-build-step-dev all-containers: build-controller-dev build-series-tracker-dev build-db-mgmt-dev build-web-dashboard-dev build-workflow-dev diff --git a/syz-cluster/pkg/workflow/template.yaml b/syz-cluster/pkg/workflow/template.yaml index 1a51ee646..c8ef8357d 100644 --- a/syz-cluster/pkg/workflow/template.yaml +++ b/syz-cluster/pkg/workflow/template.yaml @@ -70,6 +70,9 @@ spec: name: build-step-template template: build-step arguments: + parameters: + - name: test-name + value: "Build Base" artifacts: - name: request from: "{{steps.save-base-req.outputs.artifacts.request}}" @@ -87,21 +90,14 @@ spec: name: build-step-template template: build-step arguments: + parameters: + - name: test-name + value: "Build Patched" + - name: findings + value: "true" artifacts: - name: request from: "{{steps.save-patched-req.outputs.artifacts.request}}" - - - name: do-submit-test - template: submit-test - arguments: - parameters: - - name: test-name - value: "Build test" - - name: base-build-id - value: "{{=jsonpath(steps['base-build'].outputs.parameters.result, '$.build_id')}}" - - name: patched-build-id - value: "{{=jsonpath(steps['patched-build'].outputs.parameters.result, '$.build_id')}}" - - name: result - value: "{{=jsonpath(steps['patched-build'].outputs.parameters.result, '$.success') == true ? 'passed' : 'failed'}}" - - name: continue-if-patched-build-failed template: exit-workflow when: "{{=jsonpath(steps['patched-build'].outputs.parameters.result, '$.success')}} == false" @@ -117,24 +113,6 @@ spec: image: alpine:latest command: [sh, -c] args: ["echo '{{inputs.parameters.data}}' > /tmp/request.json"] - - name: submit-test - inputs: - parameters: - - name: test-name - - name: base-build-id - - name: patched-build-id - - name: result - container: - image: submit-test-local:latest - imagePullPolicy: IfNotPresent - command: ["/bin/submit-test"] - args: [ - "--session", "{{workflow.parameters.session-id}}", - "--test", "{{inputs.parameters.test-name}}", - "--base-build", "{{inputs.parameters.base-build-id}}", - "--patched-build", "{{inputs.parameters.patched-build-id}}", - "--result", "{{inputs.parameters.result}}" - ] - name: exit-workflow inputs: parameters: diff --git a/syz-cluster/workflow/build-step/main.go b/syz-cluster/workflow/build-step/main.go index 5ba40f39a..bd226401e 100644 --- a/syz-cluster/workflow/build-step/main.go +++ b/syz-cluster/workflow/build-step/main.go @@ -27,14 +27,19 @@ var ( flagRequest = flag.String("request", "", "path to a build request description") flagRepository = flag.String("repository", "", "path to a kernel checkout") flagOutput = flag.String("output", "", "path to save kernel build artifacts") + flagTestName = flag.String("test_name", "", "test name") + flagSession = flag.String("session", "", "session ID") + flagFindings = flag.Bool("findings", false, "report build failures as findings") ) func main() { flag.Parse() - if *flagRequest == "" || *flagRepository == "" || *flagOutput == "" { - // TODO: abort the whole workflow, no sense to retry. Alert the error. - app.Fatalf("--series, --repository and --output must be set") - } + ensureFlags(*flagRequest, "--request", + *flagRepository, "--repository", + *flagOutput, "--output", + *flagSession, "--session", + *flagTestName, "--test_name") + req := readRequest() ctx := context.Background() client := app.DefaultClient() @@ -58,6 +63,7 @@ func main() { if commit != nil { uploadReq.CommitDate = commit.CommitDate } + var finding *api.Finding if err != nil { log.Printf("failed to checkout: %v", err) uploadReq.Log = []byte(err.Error()) @@ -68,8 +74,19 @@ func main() { } else { log.Printf("failed to build: %v", err) uploadReq.Log = []byte(err.Error()) + finding = &api.Finding{ + SessionID: *flagSession, + TestName: *flagTestName, + Title: "failed to build the kernel", + Log: uploadReq.Log, + } } } + reportResults(ctx, client, req.SeriesID != "", uploadReq, finding) +} + +func reportResults(ctx context.Context, client *api.Client, patched bool, + uploadReq *api.UploadBuildReq, finding *api.Finding) { buildInfo, err := client.UploadBuild(ctx, uploadReq) if err != nil { app.Fatalf("failed to upload build: %v", err) @@ -79,6 +96,29 @@ func main() { BuildID: buildInfo.ID, Success: uploadReq.BuildSuccess, }) + testResult := &api.TestResult{ + SessionID: *flagSession, + TestName: *flagTestName, + Result: api.TestFailed, + } + if uploadReq.BuildSuccess { + testResult.Result = api.TestPassed + } + if patched { + testResult.PatchedBuildID = buildInfo.ID + } else { + testResult.BaseBuildID = buildInfo.ID + } + err = client.UploadTestResult(ctx, testResult) + if err != nil { + app.Fatalf("failed to report the test result: %v", err) + } + if *flagFindings && finding != nil { + err = client.UploadFinding(ctx, finding) + if err != nil { + app.Fatalf("failed to report the finding: %v", err) + } + } } func readRequest() *api.BuildRequest { @@ -167,3 +207,11 @@ func buildKernel(req *api.BuildRequest) error { // `-- vmlinux return nil } + +func ensureFlags(args ...string) { + for i := 0; i+1 < len(args); i += 2 { + if args[i] == "" { + app.Fatalf("%s must be set", args[i+1]) + } + } +} diff --git a/syz-cluster/workflow/build-step/workflow-template.yaml b/syz-cluster/workflow/build-step/workflow-template.yaml index b61d873e3..341d22072 100644 --- a/syz-cluster/workflow/build-step/workflow-template.yaml +++ b/syz-cluster/workflow/build-step/workflow-template.yaml @@ -9,6 +9,10 @@ spec: templates: - name: build-step inputs: + parameters: + - name: findings + value: "false" + - name: test-name artifacts: - name: request path: /tmp/request.json @@ -44,7 +48,15 @@ spec: container: image: build-step-local imagePullPolicy: IfNotPresent - command: ["/bin/build-step", "--request", "/tmp/request.json", "--repository", "/workdir", "--output", "/output"] + command: ["/bin/build-step"] + args: [ + "--request", "/tmp/request.json", + "--repository", "/workdir", + "--output", "/output", + "--session", "{{workflow.parameters.session-id}}", + "--test_name", "{{inputs.parameters.test-name}}", + "-findings={{inputs.parameters.findings}}" + ] env: - name: GIT_DIR value: "/data/.git" diff --git a/syz-cluster/workflow/submit-test/Dockerfile b/syz-cluster/workflow/submit-test/Dockerfile deleted file mode 100644 index d8d379595..000000000 --- a/syz-cluster/workflow/submit-test/Dockerfile +++ /dev/null @@ -1,22 +0,0 @@ -# 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. - -FROM golang:1.23-alpine AS submit-test-builder - -WORKDIR /build - -# Prepare the dependencies. -COPY go.mod go.sum ./ -RUN go mod download - -# Build the tool. -COPY syz-cluster/workflow/submit-test/*.go syz-cluster/workflow/submit-test/ -COPY syz-cluster/pkg/ syz-cluster/pkg/ - -RUN go build -o /build/submit-test-bin /build/syz-cluster/workflow/submit-test - -FROM ubuntu:latest - -COPY --from=submit-test-builder /build/submit-test-bin /bin/submit-test - -ENTRYPOINT ["/bin/submit-test"] diff --git a/syz-cluster/workflow/submit-test/main.go b/syz-cluster/workflow/submit-test/main.go deleted file mode 100644 index 1d6200fb9..000000000 --- a/syz-cluster/workflow/submit-test/main.go +++ /dev/null @@ -1,38 +0,0 @@ -// 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 ( - "context" - "flag" - "log" - - "github.com/google/syzkaller/syz-cluster/pkg/api" - "github.com/google/syzkaller/syz-cluster/pkg/app" -) - -var ( - flagSession = flag.String("session", "", "session ID") - flagTest = flag.String("test", "", "test name") - flagBaseBuild = flag.String("base-build", "", "base build ID") - flagPatchedBuild = flag.String("patched-build", "", "patched build ID") - flagResult = flag.String("result", "", "passed/failed/error") -) - -func main() { - flag.Parse() - client := app.DefaultClient() - result := &api.TestResult{ - SessionID: *flagSession, - BaseBuildID: *flagBaseBuild, - PatchedBuildID: *flagPatchedBuild, - TestName: *flagTest, - Result: *flagResult, - } - log.Printf("submitting %q", result) - err := client.UploadTestResult(context.Background(), result) - if err != nil { - app.Fatalf("request failed: %v", err) - } -} |
