Skip to content

Commit 6d58896

Browse files
authored
Merge pull request #647 from fluxcd/allow-drift-diff-only
Allow opt-out of drift correction
2 parents ad9a3f9 + 46add22 commit 6d58896

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

controllers/helmrelease_controller.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,8 @@ func (r *HelmReleaseReconciler) reconcileRelease(ctx context.Context,
352352

353353
msg := "no diff in cluster resources compared to release"
354354
if drift {
355-
hasNewState = true
356355
msg = "diff in cluster resources compared to release"
356+
hasNewState, _ = features.Enabled(features.CorrectDrift)
357357
}
358358
if changeSet != nil {
359359
msg = fmt.Sprintf("%s:\n\n%s", msg, changeSet.String())

docs/spec/v2beta1/helmreleases.md

+7
Original file line numberDiff line numberDiff line change
@@ -1280,6 +1280,13 @@ compare the manifests from the Helm storage with the current state of the cluste
12801280
If this comparison detects a drift (either due resource being created or modified during the
12811281
dry-run), the controller will perform an upgrade for the release, restoring the desired state.
12821282

1283+
To help aid transition to this new feature, it is possible to enable drift detection without it
1284+
correcting drift. This can be done by adding `CorrectDrift=false` to the `--feature-gates` flag,
1285+
i.e. `--feature-gates=DetectDrift=true,CorrectDrift=false`. This will allow you to see what drift
1286+
is detected in the controller logs (with `--log-level=debug`), to potentially add the appropriate
1287+
[exclusions annotations or labels](#excluding-resources-from-drift-detection), before enabling the
1288+
feature full.
1289+
12831290
### Excluding resources from drift detection
12841291

12851292
The drift detection feature can be configured to exclude certain resources from the comparison

internal/features/features.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ const (
3333
// storage object.
3434
DetectDrift = "DetectDrift"
3535

36+
// CorrectDrift configures the correction of cluster state drift compared to
37+
// the desired state as described in the manifest of the Helm release. It
38+
// is only effective when DetectDrift is enabled.
39+
CorrectDrift = "CorrectDrift"
40+
3641
// AllowDNSLookups allows the controller to perform DNS lookups when rendering Helm
3742
// templates. This is disabled by default, as it can be a security risk.
3843
//
@@ -48,9 +53,12 @@ var features = map[string]bool{
4853
// CacheSecretsAndConfigMaps
4954
// opt-in from v0.28
5055
CacheSecretsAndConfigMaps: false,
51-
// DetectClusterStateDrift
56+
// DetectDrift
5257
// opt-in from v0.31
5358
DetectDrift: false,
59+
// CorrectDrift,
60+
// opt-out from v0.31.2
61+
CorrectDrift: true,
5462
// AllowDNSLookups
5563
// opt-in from v0.31
5664
AllowDNSLookups: false,

0 commit comments

Comments
 (0)