This repository has been archived by the owner on Nov 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add DisableGarbageCollect annotation #2858
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
8696876
Add DisableGarbageCollect annotation
phillebaba 1f5649a
Add support for sync_only value on ignore policy
phillebaba e383949
Update docs with new annotation value
phillebaba 7b2d98a
Make sync only value constant
phillebaba c0f7160
Fix docs grammar
phillebaba File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -353,6 +353,7 @@ metadata: | |
name: dep3 | ||
namespace: other | ||
` | ||
|
||
// checkSame is a check that a result returned from the cluster is | ||
// the same as an expected. labels and annotations may be altered | ||
// by the sync process; we'll look at the "spec" field as an | ||
|
@@ -607,7 +608,7 @@ metadata: | |
test(t, kube, ns1+defs1invalid, ns1+defs1invalid, true) | ||
}) | ||
|
||
t.Run("sync doesn't apply or delete manifests marked with ignore", func(t *testing.T) { | ||
t.Run("sync doesn't apply or GC manifests marked with ignore: 'true'", func(t *testing.T) { | ||
kube, _, cancel := setup(t) | ||
defer cancel() | ||
kube.GC = true | ||
|
@@ -651,7 +652,7 @@ spec: | |
test(t, kube, ns1+dep1ignored+dep2, ns1+dep1, false) | ||
}) | ||
|
||
t.Run("sync doesn't update a cluster resource marked with ignore", func(t *testing.T) { | ||
t.Run("sync doesn't update a cluster resource marked with ignore: 'true'", func(t *testing.T) { | ||
const dep1 = `--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
|
@@ -703,7 +704,74 @@ spec: | |
test(t, kube, ns1+mod1, ns1+dep1, false) | ||
}) | ||
|
||
t.Run("sync doesn't update or delete a pre-existing resource marked with ignore", func(t *testing.T) { | ||
t.Run("sync doesn't GC resources annotated with ignore: 'sync_only'", func(t *testing.T) { | ||
kube, _, cancel := setup(t) | ||
defer cancel() | ||
kube.GC = true | ||
|
||
const dep1 = `--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: dep1 | ||
namespace: foobar | ||
annotations: {flux.weave.works/ignore: "sync_only"} | ||
` | ||
|
||
// sync namespace and deployment | ||
test(t, kube, ns1+dep1, ns1+dep1, false) | ||
|
||
// sync namespace only but expect deployment to not be GC | ||
test(t, kube, ns1, ns1+dep1, false) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice and simple test case 👍 |
||
}) | ||
|
||
t.Run("sync doesn't GC resources annotated with ignore: 'true'", func(t *testing.T) { | ||
kube, _, cancel := setup(t) | ||
defer cancel() | ||
kube.GC = true | ||
|
||
const dep1 = `--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: dep1 | ||
namespace: foobar | ||
` | ||
const dep2 = `--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: dep2 | ||
namespace: foobar | ||
annotations: {flux.weave.works/ignore: "false"} | ||
` | ||
|
||
// dep1 is created | ||
test(t, kube, ns1+dep1+dep2, ns1+dep1+dep2, false) | ||
|
||
// add ignore: 'true' annotation outside of sync loop | ||
dc := kube.client.dynamicClient | ||
rc := dc.Resource(schema.GroupVersionResource{ | ||
Group: "apps", | ||
Version: "v1", | ||
Resource: "deployments", | ||
}) | ||
res, err := rc.Namespace("foobar").Get("dep1", metav1.GetOptions{}) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
annots := res.GetAnnotations() | ||
annots["flux.weave.works/ignore"] = "true" | ||
res.SetAnnotations(annots) | ||
if _, err = rc.Namespace("foobar").Update(res, metav1.UpdateOptions{}); err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
// only sync ns1 but expect nothing to be GC | ||
test(t, kube, ns1, ns1+dep1, false) | ||
}) | ||
|
||
t.Run("sync doesn't update or delete a pre-existing resource marked with ignore: 'true'", func(t *testing.T) { | ||
kube, _, cancel := setup(t) | ||
defer cancel() | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍