Skip to content

Comments

Bug 2097555: Fix loadBalancerServiceAnnotationsChanged check and update#783

Merged
openshift-ci[bot] merged 2 commits intoopenshift:masterfrom
Miciah:BZ2097555-fix-loadBalancerServiceAnnotationsChanged
Jun 17, 2022
Merged

Bug 2097555: Fix loadBalancerServiceAnnotationsChanged check and update#783
openshift-ci[bot] merged 2 commits intoopenshift:masterfrom
Miciah:BZ2097555-fix-loadBalancerServiceAnnotationsChanged

Conversation

@Miciah
Copy link
Contributor

@Miciah Miciah commented Jun 16, 2022

loadBalancerServiceAnnotationsChanged: Fix update

Fix loadBalancerServiceAnnotationsChanged to use the provided annotations argument when updating annotations. Before this change, 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.

loadBalancerServiceAnnotationsChanged: Fix check

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.

  • 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.

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.
@openshift-ci openshift-ci bot added bugzilla/severity-urgent Referenced Bugzilla bug's severity is urgent for the branch this PR is targeting. bugzilla/invalid-bug Indicates that a referenced Bugzilla bug is invalid for the branch this PR is targeting. labels Jun 16, 2022
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jun 16, 2022

@Miciah: This pull request references Bugzilla bug 2097555, which is invalid:

  • expected the bug to target the "4.11.0" release, but it targets "---" instead

Comment /bugzilla refresh to re-evaluate validity if changes to the Bugzilla bug are made, or edit the title of this pull request to link to a different bug.

Details

In response to this:

Bug 2097555: Fix loadBalancerServiceAnnotationsChanged check and update

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.

@openshift-ci openshift-ci bot requested review from alebedev87 and frobware June 16, 2022 12:33
@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 16, 2022
@Miciah
Copy link
Contributor Author

Miciah commented Jun 16, 2022

/bugzilla refresh

@openshift-ci openshift-ci bot added bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. and removed bugzilla/invalid-bug Indicates that a referenced Bugzilla bug is invalid for the branch this PR is targeting. labels Jun 16, 2022
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jun 16, 2022

@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
  • bug is open, matching expected state (open)
  • bug target release (4.11.0) matches configured target release for branch (4.11.0)
  • bug is in the state ASSIGNED, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

Requesting review from QA contact:
/cc @lihongan

Details

In response to this:

/bugzilla refresh

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.

@openshift-ci openshift-ci bot requested a review from lihongan June 16, 2022 12:49
for annotation := range annotations {
currentVal, have := current.Annotations[annotation]
expectedVal, want := expected.Annotations[annotation]
changed = changed || (want && (!have || currentVal != expectedVal)) || (have && !want)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
changed = changed || (want && (!have || currentVal != expectedVal)) || (have && !want)
changed = changed || (want && (!have || currentVal != expectedVal)) || (have && !want)
if (changed) {
break
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

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.
@candita
Copy link
Contributor

candita commented Jun 16, 2022

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jun 16, 2022
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jun 16, 2022

[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

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jun 17, 2022

@Miciah: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-aws-single-node 8522772 link false /test e2e-aws-single-node

Full PR test history. Your PR dashboard.

Details

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. I understand the commands that are listed here.

@openshift-ci openshift-ci bot merged commit 99beb07 into openshift:master Jun 17, 2022
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jun 17, 2022

@Miciah: All pull requests linked via external trackers have merged:

Bugzilla bug 2097555 has been moved to the MODIFIED state.

Details

In response to this:

Bug 2097555: Fix loadBalancerServiceAnnotationsChanged check and update

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. bugzilla/severity-urgent Referenced Bugzilla bug's severity is urgent for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants