Skip to content

Commit

Permalink
Merge pull request #933 from fluxcd/fail-fast
Browse files Browse the repository at this point in the history
Enable fail-fast behavior for health checks
  • Loading branch information
stefanprodan authored Aug 2, 2023
2 parents 610ec69 + 7765f0c commit 460a165
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions internal/controller/kustomization_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ type KustomizationReconciler struct {
statusManager string
NoCrossNamespaceRefs bool
NoRemoteBases bool
FailFast bool
DefaultServiceAccount string
KubeConfigOpts runtimeClient.KubeConfigOptions
}
Expand Down Expand Up @@ -863,6 +864,7 @@ func (r *KustomizationReconciler) checkHealth(ctx context.Context,
if err := manager.WaitForSet(toCheck, ssa.WaitOptions{
Interval: 5 * time.Second,
Timeout: obj.GetTimeout(),
FailFast: r.FailFast,
}); err != nil {
conditions.MarkFalse(obj, meta.ReadyCondition, kustomizev1.HealthCheckFailedReason, err.Error())
conditions.MarkFalse(obj, kustomizev1.HealthyCondition, kustomizev1.HealthCheckFailedReason, err.Error())
Expand Down
7 changes: 7 additions & 0 deletions internal/features/features.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ const (
// large number of resources, as it will potentially reduce the amount of
// memory used by the controller.
DisableStatusPollerCache = "DisableStatusPollerCache"

// DisableFailFastBehavior controls whether the fail-fast behavior when
// waiting for resources to become ready should be disabled.
DisableFailFastBehavior = "DisableFailFastBehavior"
)

var features = map[string]bool{
Expand All @@ -44,6 +48,9 @@ var features = map[string]bool{
// DisableStatusPollerCache
// opt-in from v0.35
DisableStatusPollerCache: false,
// DisableFailFastBehavior
// opt-in from v1.1
DisableFailFastBehavior: false,
}

// FeatureGates contains a list of all supported feature gates and
Expand Down
6 changes: 6 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,11 @@ func main() {
pollingOpts.ClusterReaderFactory = engine.ClusterReaderFactoryFunc(clusterreader.NewDirectClusterReader)
}

failFast := true
if ok, _ := features.Enabled(features.DisableFailFastBehavior); ok {
failFast = false
}

if err = (&controller.KustomizationReconciler{
ControllerName: controllerName,
DefaultServiceAccount: defaultServiceAccount,
Expand All @@ -208,6 +213,7 @@ func main() {
EventRecorder: eventRecorder,
NoCrossNamespaceRefs: aclOptions.NoCrossNamespaceRefs,
NoRemoteBases: noRemoteBases,
FailFast: failFast,
KubeConfigOpts: kubeConfigOpts,
PollingOpts: pollingOpts,
StatusPoller: polling.NewStatusPoller(mgr.GetClient(), mgr.GetRESTMapper(), pollingOpts),
Expand Down

0 comments on commit 460a165

Please sign in to comment.