-
Notifications
You must be signed in to change notification settings - Fork 529
Always retain metadata.finalizers and metadata.annotations #1010
Always retain metadata.finalizers and metadata.annotations #1010
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: marun The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@marun please rebase. |
Rebased |
Rebased and ready for review |
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.
Overall, LGTM.
2 comments for message clarify.
docs/userguide.md
Outdated
registered with KubeFed, the following operations are executed in sequence: | ||
|
||
- A new resource is computed from the template of the federated resource | ||
- If an existing resource is present, field values are retained |
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.
field values
are retained. I think it is not accurate because only partial field values are retained.
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.
Updated. PTAL.
pkg/controller/sync/resource.go
Outdated
@@ -165,6 +165,15 @@ func (r *federatedResource) ObjectForCluster(clusterName string) (*unstructured. | |||
} | |||
obj := &unstructured.Unstructured{Object: templateBody} | |||
|
|||
if len(obj.GetAnnotations()) > 0 { | |||
r.RecordError("AnnotationsNotSupported", errors.New("metadata.annotations will not be set to avoid conflicting with local controllers.")) |
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.
This message seems misunderstanding. Actually, metadata.annotations
still can be set. But by override
instead of by template
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.
Updated. PTAL
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.
This LGTM, just a clarifying comment. I see "local" controllers used throughout. What is meant by "local" here? Local to the cluster? If so, this would technically apply to any controller, not just ones local to the cluster.
@font I've replaced references to 'local controller' with 'controllers in member clusters'. Does that make more sense? |
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.
@font I've replaced references to 'local controller' with 'controllers in member clusters'. Does that make more sense?
Yep, thanks!
Rebased. |
Since finalizers and annotations will typically be managed by local controllers, ensure that these fields cannot be set from the template and are always retained from an existing resource. It will still be possible to apply overrides to add or remove entries from these collections. As part of this change, it was necessary to perform field retention before overriding to ensure that retained fields could be the subject of override directives.
Rebased |
/lgtm |
Hi! I think annotations still should propagate for non controller-managed resources, e.g. |
Now that overriding via jsonpatch is supported, it is possible to restrict modification of the
annotations
andfinalizers
fields to overrides. Modifications to these collection fields can be made using theadd
orremove
jsonpatch operations to ensure that a given item exists (or does not exist) with less chance of conflicting with local controllers.To support this change, it was necessary to move the application of overrides from before retention of local values to after so that overrides would be applied to the result of retention.
This change suggests implementing selector-based overrides to simplify applying an annotation across multiple clusters.
Fixes #982