The .spec.additionalMetadata field of RolloutManager CR can be used to set labels/annotations on the resources that are created by the Argo Rollouts operator.
However, at present, when you change the labels/annotations in that field, OR if you add labels/annotations (in that field) on a RolloutManager that already exists, the appropriate labels/annotations will NOT be correctly set on the rollout resources.
This appears to be because in the reconcile* functions in resources.go, we are first calling setAdditionalRolloutsLabelsAndAnnotationsToObject(obj, cr), then immediately calling fetchObject(...), which causes those set labels/annotations to be discarded (in the case where the resource already exists).
This means the labels will only be applied in the resource creation case, not the update case. This might be intended behaviour, but IMHO it makes sense to always keep labels/annotations in sync with resources.
Update the logic of the various reconcile* functions in resources.go to ensure they work with both the create and update case of the .spec.additionalMetadata field
Update the unit tests for the reconcile* functions in resources_test.go, to ensure both the create and update case are tested as working, for .spec.additionalMetadata field.
Note: When updating labels/annotations of a resource, don't erase any existing labels/annotations that were already set on that resource (perhaps by other components).
For example, if a ClusterRole has a .metadata.label of 'my-label: my-value', after reconcile is called that label should still be present, along with the labels specified in '.spec.additionalMetadata'.
This case should be covered in the unit tests as well, as we really want to avoid discarding labels/annotations set by other components.
The
.spec.additionalMetadata
field of RolloutManager CR can be used to set labels/annotations on the resources that are created by the Argo Rollouts operator.However, at present, when you change the labels/annotations in that field, OR if you add labels/annotations (in that field) on a RolloutManager that already exists, the appropriate labels/annotations will NOT be correctly set on the rollout resources.
This appears to be because in the
reconcile*
functions inresources.go
, we are first callingsetAdditionalRolloutsLabelsAndAnnotationsToObject(obj, cr)
, then immediately callingfetchObject(...)
, which causes those set labels/annotations to be discarded (in the case where the resource already exists).This means the labels will only be applied in the resource creation case, not the update case. This might be intended behaviour, but IMHO it makes sense to always keep labels/annotations in sync with resources.
For an example of this, see reconcileRolloutsClusterRole.
Fix criteria:
Update the logic of the various
reconcile*
functions inresources.go
to ensure they work with both the create and update case of the.spec.additionalMetadata
fieldUpdate the unit tests for the
reconcile*
functions inresources_test.go
, to ensure both the create and update case are tested as working, for.spec.additionalMetadata
field.Note: When updating labels/annotations of a resource, don't erase any existing labels/annotations that were already set on that resource (perhaps by other components).