Bug 2097555: Fix loadBalancerServiceAnnotationsChanged check and update#783
Conversation
Fix loadBalancerServiceAnnotationsChanged to use the provided "annotations" argument when updating annotations. Before this commit, loadBalancerServiceAnnotationsChanged used the annotations argument when checking whether annotations had changed, but then it used managedLoadBalancerServiceAnnotations when setting the annotations in the updated service object. When checking whether the service is upgradeable for the purpose of setting the ingresscontroller's "Upgradeable" status condition, loadBalancerServiceTagsModified calls loadBalancerServiceAnnotationsChanged with an annotations argument that includes the "service.beta.kubernetes.io/aws-load-balancer-additional-resource-tags" annotation key, which is not in managedLoadBalancerServiceAnnotations. As a result, loadBalancerServiceAnnotationsChanged would report that the service was not upgradeable, but then the status condition message would not show that the "aws-load-balancer-additional-resource-tags" annotation had changed. * pkg/operator/controller/ingress/load_balancer_service.go (loadBalancerServiceAnnotationsChanged): Use the provided annotations argument instead of using managedLoadBalancerServiceAnnotations when updating annotations. * pkg/operator/controller/ingress/load_balancer_service_test.go (TestLoadBalancerServiceAnnotationsChanged): New test. Verify that loadBalancerServiceAnnotationsChanged behaves correctly when an unmanaged annotation is updated or when a managed annotation is added, updated, or deleted.
|
@Miciah: This pull request references Bugzilla bug 2097555, which is invalid:
Comment DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
|
/bugzilla refresh |
|
@Miciah: This pull request references Bugzilla bug 2097555, which is valid. The bug has been moved to the POST state. The bug has been updated to refer to the pull request using the external bug tracker. 3 validation(s) were run on this bug
Requesting review from QA contact: DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
| for annotation := range annotations { | ||
| currentVal, have := current.Annotations[annotation] | ||
| expectedVal, want := expected.Annotations[annotation] | ||
| changed = changed || (want && (!have || currentVal != expectedVal)) || (have && !want) |
There was a problem hiding this comment.
| changed = changed || (want && (!have || currentVal != expectedVal)) || (have && !want) | |
| changed = changed || (want && (!have || currentVal != expectedVal)) || (have && !want) | |
| if (changed) { | |
| break | |
| } | |
Fix loadBalancerServiceAnnotationsChanged to treat nil and empty annotations maps as equal. Before this commit, the comparison erroneously flagged an empty map and a nil map as unequal. As a result, the ingress operator could erroneously report that an ingresscontroller with a service with no annotations was not upgradeable. This commit fixes bug 2097555. https://bugzilla.redhat.com/show_bug.cgi?id=2097555 * pkg/operator/controller/ingress/load_balancer_service.go (loadBalancerServiceAnnotationsChanged): Use a for loop instead of go-cmp to check whether any managed annotations have changed. * pkg/operator/controller/ingress/load_balancer_service_test.go (TestLoadBalancerServiceAnnotationsChanged): Add test cases for empty/nil current/expected annotations.
ae15e52 to
8522772
Compare
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: candita, Miciah The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
@Miciah: The following test failed, say
Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
|
@Miciah: All pull requests linked via external trackers have merged: Bugzilla bug 2097555 has been moved to the MODIFIED state. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
loadBalancerServiceAnnotationsChanged: Fix updateFix
loadBalancerServiceAnnotationsChangedto use the providedannotationsargument when updating annotations. Before this change,loadBalancerServiceAnnotationsChangedused theannotationsargument when checking whether annotations had changed, but then it usedmanagedLoadBalancerServiceAnnotationswhen setting the annotations in the updated service object.When checking whether the service is upgradeable for the purpose of setting the ingresscontroller's "Upgradeable" status condition,
loadBalancerServiceTagsModifiedcallsloadBalancerServiceAnnotationsChangedwith anannotationsargument that includes the "service.beta.kubernetes.io/aws-load-balancer-additional-resource-tags" annotation key, which is not inmanagedLoadBalancerServiceAnnotations. As a result,loadBalancerServiceAnnotationsChangedwould report that the service was not upgradeable, but then the status condition message would not show that the "aws-load-balancer-additional-resource-tags" annotation had changed.pkg/operator/controller/ingress/load_balancer_service.go(loadBalancerServiceAnnotationsChanged): Use the providedannotationsargument instead of usingmanagedLoadBalancerServiceAnnotationswhen updating annotations.pkg/operator/controller/ingress/load_balancer_service_test.go(TestLoadBalancerServiceAnnotationsChanged): New test. Verify thatloadBalancerServiceAnnotationsChangedbehaves correctly when an unmanaged annotation is updated or when a managed annotation is added, updated, or deleted.loadBalancerServiceAnnotationsChanged: Fix checkFix
loadBalancerServiceAnnotationsChangedto treat nil and empty annotations maps as equal. Before this commit, the comparison erroneously flagged an empty map and a nil map as unequal. As a result, the ingress operator could erroneously report that an ingresscontroller with a service with no annotations was not upgradeable.pkg/operator/controller/ingress/load_balancer_service.go(loadBalancerServiceAnnotationsChanged): Use aforloop instead of go-cmp to check whether any managed annotations have changed.pkg/operator/controller/ingress/load_balancer_service_test.go(TestLoadBalancerServiceAnnotationsChanged): Add test cases for empty/nil current/expected annotations.