New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[release-4.9] Bug 2084336: Fix enabling PROXY protocol on an upgraded cluster #757
[release-4.9] Bug 2084336: Fix enabling PROXY protocol on an upgraded cluster #757
Conversation
Refactor the update logic in setDefaultPublishingStrategy. * pkg/operator/controller/ingress/controller.go (setDefaultPublishingStrategy): Use a switch statement for the update logic so that the logic only looks at parameters related to the selected endpoint publishing strategy type.
Fix the update logic in setDefaultPublishingStrategy so that updates are properly handled when status.endpointPublishingStrategy.hostNetwork or status.endpointPublishingStrategy.nodePort is null. Before OpenShift 4.8, the IngressController API did not have any fields under the status.endpointPublishingStrategy.hostNetwork and status.endpointPublishingStrategy.nodePort fields. As result, these fields could be null even if the spec.endpointPublishingStrategy.type field was set to "HostNetwork" or "NodePortService". OpenShift 4.8 added status.endpointPublishingStrategy.hostNetwork.protocol and status.endpointPublishingStrategy.nodePort.protocol fields, and the operator now sets default values for these fields when the operator admits or re-admits an ingresscontroller that specifies the "HostNetwork" or "NodePortService" strategy type, respectively. However, a cluster that was upgraded from a version of OpenShift before 4.8 could have an already admitted ingresscontroller with null values for status.endpointPublishingStrategy.hostNetwork and status.endpointPublishingStrategy.nodePort even when ingresscontroller specifies the "HostNetwork" or "NodePortService" strategy type. In this case, the operator ignored updates to the spec.endpointPublishingStrategy.hostNetwork.protocol or spec.endpointPublishingStrategy.nodePort.protocol fields. This commit fixes the update logic so that it correctly updates the status.endpointPublishingStrategy.hostNetwork.protocol or status.endpointPublishingStrategy.nodePort.protocol field when status.endpointPublishingStrategy.hostNetwork or status.endpointPublishingStrategy.nodePort is null, the spec.endpointPublishingStrategy.hostNetwork.protocol or spec.endpointPublishingStrategy.nodePort.protocol field is set, and the strategy type is "HostNetwork" or "NodePortService", respectively. This commit fixes bug 1997226. https://bugzilla.redhat.com/show_bug.cgi?id=1997226 * pkg/operator/controller/ingress/controller.go (setDefaultPublishingStrategy): Fix logic to properly handle null values for status.endpointPublishingStrategy.hostNetwork or status.endpointPublishingStrategy.nodePort.
@Miciah: This pull request references Bugzilla bug 2084336, 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. 6 validation(s) were run on this bug
Requesting review from QA contact: In 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. |
/test e2e-aws-operator |
statusNP := ic.Status.EndpointPublishingStrategy.NodePort | ||
specNP := effectiveStrategy.NodePort | ||
if specNP != nil && statusNP != nil && specNP.Protocol != statusNP.Protocol { | ||
if specNP != nil && specNP.Protocol != statusNP.Protocol { |
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.
I still have a question about this - if someone sets ic.Spec.EndpointPublishingStrategy.NodePort
to nil (or removes it), then it won't update ic.Status nor return true here, will it?
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.
Line 375 initializes ic.Spec.EndpointPublishingStrategy.NodePort
if it is nil. In fact, for that reason, we probably don't need the specNP != nil
check anyway.
effectiveStrategy := ic.Spec.EndpointPublishingStrategy |
switch effectiveStrategy.Type { |
cluster-ingress-operator/pkg/operator/controller/ingress/controller.go
Lines 373 to 375 in 8b258e5
case operatorv1.NodePortServiceStrategyType: | |
if effectiveStrategy.NodePort == nil { | |
effectiveStrategy.NodePort = &operatorv1.NodePortStrategy{} |
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.
Okay. That had a code smell and I guess this explains it.
I'll leave it up to you whether you'd like to add the unit tests in this PR. /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
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@Miciah: This pull request references Bugzilla bug 2084336, which is valid. 6 validation(s) were run on this bug
Requesting review from QA contact: In 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. |
Make a copy of spec.endpointPublishingStrategy to avoid mutating it, and add unit tests for setDefaultDomain and setDefaultPublishingStrategy. Follow-up to commit 4bfff11. * pkg/operator/controller/ingress/controller.go (setDefaultPublishingStrategy): Use a deep copy of ic.Spec.EndpointPublishingStrategy. * pkg/operator/controller/ingress/controller_test.go (TestSetDefaultDomain) (TestSetDefaultPublishingStrategySetsPlatformDefaults) (TestSetDefaultPublishingStrategyHandlesUpdates): New tests.
acff139
to
c19f75e
Compare
/retest |
/label cherry-pick-approved, |
@lihongan: The label(s) In 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. |
/label cherry-pick-approved |
/label qe-approved |
/assign candita |
/test e2e-aws-operator |
From the must-gather log:
/test e2e-aws-operator |
/lgtm |
@Miciah: all tests passed! Full PR test history. Your PR dashboard. 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. |
@Miciah: All pull requests linked via external trackers have merged: Bugzilla bug 2084336 has been moved to the MODIFIED state. In 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. |
This is a manual cherry-pick of #681 and #691. #582 introduced conflicts that required resolution.
setDefaultPublishingStrategy
: Reformat withswitch
Refactor the update logic in
setDefaultPublishingStrategy
.pkg/operator/controller/ingress/controller.go
(setDefaultPublishingStrategy
): Use a switch statement for the update logic so that the logic only looks at parameters related to the selected endpoint publishing strategy type.setDefaultPublishingStrategy
: Fix PROXY protocolFix the update logic in
setDefaultPublishingStrategy
so that updates are properly handled whenstatus.endpointPublishingStrategy.hostNetwork
orstatus.endpointPublishingStrategy.nodePort
is null.Before OpenShift 4.8, the IngressController API did not have any fields under the
status.endpointPublishingStrategy.hostNetwork
andstatus.endpointPublishingStrategy.nodePort
fields. As result, these fields could be null even if thespec.endpointPublishingStrategy.type
field was set to "HostNetwork" or "NodePortService".OpenShift 4.8 added
status.endpointPublishingStrategy.hostNetwork.protocol
andstatus.endpointPublishingStrategy.nodePort.protocol
fields, and the operator now sets default values for these fields when the operator admits or re-admits an ingresscontroller that specifies the "HostNetwork" or "NodePortService" strategy type, respectively.However, a cluster that was upgraded from a version of OpenShift before 4.8 could have an already admitted ingresscontroller with null values for
status.endpointPublishingStrategy.hostNetwork
andstatus.endpointPublishingStrategy.nodePort
even when ingresscontroller specifies the "HostNetwork" or "NodePortService" strategy type.In this case, the operator ignored updates to the
spec.endpointPublishingStrategy.hostNetwork.protocol
orspec.endpointPublishingStrategy.nodePort.protocol
fields.This PR fixes the update logic so that it correctly updates the
status.endpointPublishingStrategy.hostNetwork.protocol
orstatus.endpointPublishingStrategy.nodePort.protocol
field whenstatus.endpointPublishingStrategy.hostNetwork
orstatus.endpointPublishingStrategy.nodePort
is null, thespec.endpointPublishingStrategy.hostNetwork.protocol
orspec.endpointPublishingStrategy.nodePort.protocol
field is set, and the strategy type is "HostNetwork" or "NodePortService", respectively.pkg/operator/controller/ingress/controller.go
(setDefaultPublishingStrategy
): Fix logic to properly handle null values forstatus.endpointPublishingStrategy.hostNetwork
orstatus.endpointPublishingStrategy.nodePort
.setDefaultPublishingStrategy
: Deep copy, testsMake a copy of
spec.endpointPublishingStrategy
to avoid mutating it, and add unit tests forsetDefaultDomain
andsetDefaultPublishingStrategy
.pkg/operator/controller/ingress/controller.go
(setDefaultPublishingStrategy
): Use a deep copy ofic.Spec.EndpointPublishingStrategy
.pkg/operator/controller/ingress/controller_test.go
(TestSetDefaultDomain
,TestSetDefaultPublishingStrategySetsPlatformDefaults
,TestSetDefaultPublishingStrategyHandlesUpdates
): New tests.