Applying cluster-scoped objects with namespace metadata reveals unexpected behavior #40
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.
Describe the bug
While deploying the local path provisioner with k3s using the addon controller / static manifests I encountered the following behavior:
ClusterRole
orClusterRoleBinding
) but reference a namespace in their metadata (e.g.local-path-provisioner-role
orlocal-path-provisioner-bind
) are handled incorrectly. Since those objects are persisted without namespace property, compareSets comes to the conclusion that the existing object (with stripped namespace) should be deleted and a new object should be created.process
creates objects before it deletes them. This effectively causes non-namespaced objects to be missing.Proposed fix
The namespace property of objects that are not scoped by namespace can be safely removed before they are being applied. This helps compareSets to identify existing resources and prevent them from being deleted.