Skip to content

Commit

Permalink
Merge pull request fluxcd#1408 from fluxcd/helm-drift
Browse files Browse the repository at this point in the history
Disable Flux helm drift detection for managed resources
  • Loading branch information
aryan9600 authored Apr 10, 2023
2 parents f1def19 + 8229852 commit 5b7a679
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/router/kubernetes_default_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ func TestServiceRouter_InitializeMetadata(t *testing.T) {

primarySvc, err := mocks.kubeClient.CoreV1().Services("default").Get(context.TODO(), "podinfo-primary", metav1.GetOptions{})
require.NoError(t, err)
assert.Equal(t, 1, len(primarySvc.Annotations))
assert.Equal(t, 2, len(primarySvc.Annotations))
assert.Equal(t, "podinfo-primary", primarySvc.Labels["app"])
}

Expand Down Expand Up @@ -425,12 +425,12 @@ func TestServiceRouter_ReconcileMetadata(t *testing.T) {

canarySvc, err := mocks.kubeClient.CoreV1().Services("default").Get(context.TODO(), "podinfo-canary", metav1.GetOptions{})
require.NoError(t, err)
assert.Equal(t, 1, len(canarySvc.Annotations))
assert.Equal(t, 2, len(canarySvc.Annotations))
assert.Equal(t, "podinfo-canary", canarySvc.Labels["app"])

primarySvc, err := mocks.kubeClient.CoreV1().Services("default").Get(context.TODO(), "podinfo-primary", metav1.GetOptions{})
require.NoError(t, err)
assert.Equal(t, 1, len(primarySvc.Annotations))
assert.Equal(t, 2, len(primarySvc.Annotations))
assert.Equal(t, "podinfo-primary", primarySvc.Labels["app"])

mocks.canary.Spec.Service.Apex = &flaggerv1.CustomMetadata{
Expand Down
2 changes: 2 additions & 0 deletions pkg/router/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
const (
toolkitMarker = "toolkit.fluxcd.io"
toolkitReconcileKey = "kustomize.toolkit.fluxcd.io/reconcile"
helmDriftDetectionKey = "helm.toolkit.fluxcd.io/driftDetection"
toolkitReconcileValue = "disabled"
)

Expand All @@ -30,5 +31,6 @@ func includeLabelsByPrefix(labels map[string]string, includeLabelPrefixes []stri
func filterMetadata(meta map[string]string) map[string]string {
// prevent Flux from overriding Flagger managed objects
meta[toolkitReconcileKey] = toolkitReconcileValue
meta[helmDriftDetectionKey] = toolkitReconcileValue
return meta
}
7 changes: 7 additions & 0 deletions test/kubernetes/test-deployment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ if [ -z "$passed" ]; then
kubectl -n test get svc/podinfo-svc -oyaml
exit 1
fi
passed=$(kubectl -n test get svc/podinfo-svc -oyaml 2>&1 | { grep 'helm.toolkit.fluxcd.io/driftDetection' || true; })
if [ -z "$passed" ]; then
echo -e '\u2716 helm drift detection annotation test failed'
kubectl -n test get svc/podinfo-svc -oyaml
exit 1
fi

passed=$(kubectl -n test get deploy/podinfo-primary -oyaml 2>&1 | { grep test-label-prefix || true; })
if [ -z "$passed" ]; then
echo -e '\u2716 primary copy labels by prefix test failed'
Expand Down

0 comments on commit 5b7a679

Please sign in to comment.