Skip to content

Commit

Permalink
agent: block bundle redeployment in more cases
Browse files Browse the repository at this point in the history
Signed-off-by: Silvio Moioli <[email protected]>
  • Loading branch information
moio committed May 16, 2023
1 parent dfc2aed commit ad2c91f
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions modules/agent/pkg/controllers/bundledeployment/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"errors"
"fmt"
"regexp"
"strings"
"sync"
"time"
Expand Down Expand Up @@ -143,15 +144,18 @@ func deployErrToStatus(err error, status fleet.BundleDeploymentStatus) (bool, fl
msg := err.Error()

// The following error conditions are turned into a status
// * when a Helm wait occurs and it times out
// * manifests fail to pass validation
// * atomic is set and a rollback occurs
// Note: these error strings are returned by the Helm SDK and its dependencies
if strings.Contains(msg, "timed out waiting for the condition") ||
strings.Contains(msg, "error validating data") ||
strings.Contains(msg, "chart requires kubeVersion") ||
strings.Contains(msg, "failed, and has been rolled back due to atomic being set") {

re := regexp.MustCompile(
"(timed out waiting for the condition)|" + // a Helm wait occurs and it times out
"(error validating data)|" + // manifests fail to pass validation
"(chart requires kubeVersion)|" + // kubeVersion mismatch
"(annotation validation error)|" + // annotations fail to pass validation
"(failed, and has been rolled back due to atomic being set)|" + // atomic is set and a rollback occurs
"(YAML parse error)|" + // YAML is broken in source files
"(Forbidden: updates to [0-9A-Za-z]+ spec for fields other than [0-9A-Za-z ']+ are forbidden)|" + // trying to update fields that cannot be updated
"(Forbidden: spec is immutable after creation)", // trying to modify immutable spec
)
if re.MatchString(msg) {
status.Ready = false
status.NonModified = true

Expand Down

0 comments on commit ad2c91f

Please sign in to comment.