From 81ae6f38fc2b065ea5ba7b49502f72b2f001767e Mon Sep 17 00:00:00 2001 From: Ta-Ching Chen Date: Sat, 28 Sep 2019 04:35:57 +0800 Subject: [PATCH] Fix spec doesn't update status of failed package when applying spec files (#1332) Previously, the spec doesn't update the package status if nothing in the spec file changed. Due to this, the failed package will always stay in the failed state. This PR adds a check to see whether a package is in the failed state. If yes, then changes the state to pending for builder manager to rebuild it. --- examples/go/specs/env.yaml | 5 ++--- examples/go/specs/function-hello.yaml | 1 + pkg/fission-cli/spec.go | 8 +++++++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/examples/go/specs/env.yaml b/examples/go/specs/env.yaml index 0b5bd87d..c5c9b140 100644 --- a/examples/go/specs/env.yaml +++ b/examples/go/specs/env.yaml @@ -7,7 +7,6 @@ spec: version: 2 builder: command: build - image: fission/go-builder:0.6.0 + image: fission/go-builder-1.12:1.5.0 runtime: - image: fission/go-env:0.6.0 - + image: fission/go-env-1.12:1.5.0 diff --git a/examples/go/specs/function-hello.yaml b/examples/go/specs/function-hello.yaml index a6da6abb..f53e92dd 100644 --- a/examples/go/specs/function-hello.yaml +++ b/examples/go/specs/function-hello.yaml @@ -31,6 +31,7 @@ spec: environment: name: go namespace: default + functionTimeout: 60 package: functionName: Handler packageref: diff --git a/pkg/fission-cli/spec.go b/pkg/fission-cli/spec.go index 8c473253..e25f5d4a 100644 --- a/pkg/fission-cli/spec.go +++ b/pkg/fission-cli/spec.go @@ -746,7 +746,7 @@ func applyPackages(fclient *client.Client, fr *spec.FissionResources, delete boo keep = true } - if keep { + if keep && existingObj.Status.BuildStatus == fv1.BuildStatusSucceeded { // nothing to do on the server metadataMap[mapKey(&o.Metadata)] = existingObj.Metadata } else { @@ -760,6 +760,12 @@ func applyPackages(fclient *client.Client, fr *spec.FissionResources, delete boo if err != nil { // log and ignore fmt.Printf("Error waiting for package '%v' build, ignoring\n", o.Metadata.Name) + pkg = &o + } + + // update status in order to rebuild the package again + if pkg.Status.BuildStatus == fv1.BuildStatusFailed { + pkg.Status.BuildStatus = fv1.BuildStatusPending } newmeta, err := fclient.PackageUpdate(pkg)