Skip to content

Commit d99383c

Browse files
jan-lawopenshift-merge-bot[bot]
authored andcommitted
Treat missing and empty annotations as equivalent
While testing https://issues.redhat.com/browse/ACM-14577 , some objects reported missing annotations as an empty map while other objects omitted the annotations key. Handle empty annotations before comparing objects. Signed-off-by: Janelle Law <[email protected]>
1 parent e9a8b4e commit d99383c

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

controllers/configurationpolicy_controller.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3575,6 +3575,10 @@ func removeFieldsForComparison(obj *unstructured.Unstructured) {
35753575
)
35763576
// The generation might actually bump but the API output might be the same.
35773577
unstructured.RemoveNestedField(obj.Object, "metadata", "generation")
3578+
3579+
if len(obj.GetAnnotations()) == 0 {
3580+
unstructured.RemoveNestedField(obj.Object, "metadata", "annotations")
3581+
}
35783582
}
35793583

35803584
// setEvaluatedObject updates the cache to indicate that the ConfigurationPolicy has evaluated this

test/resources/case8_status_check/case8_service.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ kind: Service
33
metadata:
44
name: grc-policy-propagator-metrics
55
namespace: managed
6-
annotations:
7-
test: test
86
spec:
97
internalTrafficPolicy: Cluster
108
ipFamilies:

0 commit comments

Comments
 (0)