-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stop argo pruning skiperator owned resources #160
Conversation
Results for sandbox – ❗
|
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.
LGTM, added a suggestion but feel free to ignore :-)
deployment.Spec.Template.ObjectMeta.Annotations = map[string]string{ | ||
"argocd.argoproj.io/sync-options": "Prune=false", | ||
"prometheus.io/scrape": "true", | ||
} |
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.
Since this might be common pattern going forward (common annotation + one or more special cases) I propose the following
deployment.Spec.Template.ObjectMeta.Annotations = map[string]string{ | |
"argocd.argoproj.io/sync-options": "Prune=false", | |
"prometheus.io/scrape": "true", | |
} | |
deployment.Spec.Template.ObjectMeta.Annotations = util.CommonAnnotationsPlus( | |
"prometheus.io/scrape", "true", | |
) |
And adding the following function in pkg/util/helperfunctions.go
:
func CommonAnnotationsPlus(kvs ...string) map[string]string {
if len(kvs)%2 != 0 {
panic(fmt.Sprintf("both key and value must be supplied, got %s", kvs))
}
m := CommonAnnotations
for i := 0; i < len(kvs); i = i + 2 {
m[kvs[i]] = kvs[i+1]
}
return m
}
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.
Is it possible to do it the other way around and set a Skiperator specific-annotation on these resources, and tell Argo to ignore them? Just seems a bit intrusive from Skiperators point of view to have to set this annotation.
I have no idea if that's possible, just a thought. Otherwise this looks like a good solution to the problem :)
@omaen Not sure exactly what you mean, the annotation that is set here makes Argo ignore these resources. Otherwise Argo will try to delete them when terminating a namespace which causes a deadlock when skiperator's finalizers try to delete them again. It's pretty much the same as setting the It would probably be even more intrusive if we were to do it the other way around and add some feature that made it possible for skiperator to create, but not delete resources so that argo would do deletions. Right now that is done implicitly through the ownership pattern, which tells skiperator what it owns so that it automatically cleans it up afterwards. |
Probably just a poor explanation from me 😅 Just wanted to check if one could use an annotation such as |
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.
Can discuss my comment further if necessary, but this solution also works as intended.
Maybe add a note about the annotation in the contributing doc?
Unfortunately not, it has to be this specific annotation.
Good idea, I'll document this property before merging |
When Argo and Skiperator run in the same system they conflict when tearing down a namespace. This PR tells Argo not to touch skiperator app generated resources so namespaces don't get into an infinite terminating state.
Uses this annotation: https://argo-cd.readthedocs.io/en/stable/user-guide/sync-options/#no-prune-resources
Tested in sandbox. Seems to work.