Skip to content
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

Merged

Conversation

Miciah
Copy link
Contributor

@Miciah Miciah commented May 11, 2022

This is a manual cherry-pick of #681 and #691. #582 introduced conflicts that required resolution.


setDefaultPublishingStrategy: Reformat with switch

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 protocol

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

  • pkg/operator/controller/ingress/controller.go (setDefaultPublishingStrategy): Fix logic to properly handle null values for status.endpointPublishingStrategy.hostNetwork or status.endpointPublishingStrategy.nodePort.

setDefaultPublishingStrategy: Deep copy, tests

Make a copy of spec.endpointPublishingStrategy to avoid mutating it, and add unit tests for setDefaultDomain and setDefaultPublishingStrategy.

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

Miciah Masters added 2 commits May 11, 2022 18:05
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.
@openshift-ci openshift-ci bot added bugzilla/severity-high Referenced Bugzilla bug's severity is high 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. labels May 11, 2022
@openshift-ci
Copy link
Contributor

openshift-ci bot commented May 11, 2022

@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
  • bug is open, matching expected state (open)
  • bug target release (4.9.z) matches configured target release for branch (4.9.z)
  • bug is in the state ASSIGNED, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)
  • dependent bug Bugzilla bug 1997226 is in the state CLOSED (ERRATA), which is one of the valid states (VERIFIED, RELEASE_PENDING, CLOSED (ERRATA), CLOSED (CURRENTRELEASE))
  • dependent Bugzilla bug 1997226 targets the "4.10.0" release, which is one of the valid target releases: 4.10.0, 4.10.z
  • bug has dependents

Requesting review from QA contact:
/cc @lihongan

In response to this:

[release-4.9] Bug 2084336: Fix enabling PROXY protocol on an upgraded cluster

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 added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 11, 2022
@candita
Copy link
Contributor

candita commented May 12, 2022

Step e2e-aws-operator-gather-must-gather failed after 10m30s.

/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 {
Copy link
Contributor

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?

Copy link
Contributor Author

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


case operatorv1.NodePortServiceStrategyType:
if effectiveStrategy.NodePort == nil {
effectiveStrategy.NodePort = &operatorv1.NodePortStrategy{}

Copy link
Contributor

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.

@candita
Copy link
Contributor

candita commented May 12, 2022

I'll leave it up to you whether you'd like to add the unit tests in this PR.

/lgtm

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

openshift-ci bot commented May 12, 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

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 openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Jun 3, 2022
@Miciah
Copy link
Contributor Author

Miciah commented Jun 3, 2022

Added #691 for the unit tests. After some discussion, we decided that the deepcopy that #691 adds is safe to backport.

@Miciah Miciah added the backport-risk-assessed Indicates a PR to a release branch has been evaluated and considered safe to accept. label Jun 3, 2022
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jun 3, 2022

@Miciah: This pull request references Bugzilla bug 2084336, which is valid.

6 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.9.z) matches configured target release for branch (4.9.z)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)
  • dependent bug Bugzilla bug 1997226 is in the state CLOSED (ERRATA), which is one of the valid states (VERIFIED, RELEASE_PENDING, CLOSED (ERRATA), CLOSED (CURRENTRELEASE))
  • dependent Bugzilla bug 1997226 targets the "4.10.0" release, which is one of the valid target releases: 4.10.0, 4.10.z
  • bug has dependents

Requesting review from QA contact:
/cc @quarterpin

In response to this:

[release-4.9] Bug 2084336: Fix enabling PROXY protocol on an upgraded cluster

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 quarterpin and removed request for ironcladlou June 3, 2022 14:36
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.
@Miciah Miciah force-pushed the cherry-pick-681-to-release-4.9 branch from acff139 to c19f75e Compare June 3, 2022 14:47
@lihongan
Copy link
Contributor

lihongan commented Jun 6, 2022

/retest

@lihongan
Copy link
Contributor

lihongan commented Jun 6, 2022

/label cherry-pick-approved,

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jun 6, 2022

@lihongan: The label(s) /label cherry-pick-approved, cannot be applied. These labels are supported: platform/aws, platform/azure, platform/baremetal, platform/google, platform/libvirt, platform/openstack, ga, tide/merge-method-merge, tide/merge-method-rebase, tide/merge-method-squash, px-approved, docs-approved, qe-approved, downstream-change-needed, backport-risk-assessed, cherry-pick-approved

In response to this:

/label cherry-pick-approved,

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.

@lihongan
Copy link
Contributor

lihongan commented Jun 6, 2022

/label cherry-pick-approved

@openshift-ci openshift-ci bot added the cherry-pick-approved Indicates a cherry-pick PR into a release branch has been approved by the release branch manager. label Jun 6, 2022
@quarterpin
Copy link

/label qe-approved
Verified via pre-merge workflow. More details can be found in https://bugzilla.redhat.com/show_bug.cgi?id=2084336#c1.

@openshift-ci openshift-ci bot added the qe-approved Signifies that QE has signed off on this PR label Jun 29, 2022
@candita
Copy link
Contributor

candita commented Jul 6, 2022

/assign candita

@candita
Copy link
Contributor

candita commented Jul 6, 2022

RUN TestHTTPHeaderCapture
operator_test.go:1682: failed to find output:
.....
operator_test.go:1689: failed to observe the expected log message: timed out waiting for the condition
62443
panic.go:613: deleted ingresscontroller headercapture
62444
--- FAIL: TestHTTPHeaderCapture (270.57s)

/test e2e-aws-operator

@candita
Copy link
Contributor

candita commented Jul 6, 2022

From the must-gather log:

ClusterOperators:
clusteroperator/authentication is degraded because APIServerDeploymentDegraded: 1 of 3 requested instances are unavailable for apiserver.openshift-oauth-apiserver ()
OAuthServerDeploymentDegraded: 1 of 3 requested instances are unavailable for oauth-openshift.openshift-authentication ()
clusteroperator/machine-config is not upgradeable because One or more machine config pools are updating, please see oc get mcp for further details
clusteroperator/openshift-apiserver is degraded because APIServerDeploymentDegraded: 1 of 3 requested instances are unavailable for apiserver.openshift-apiserver ()

/test e2e-aws-operator

@candita
Copy link
Contributor

candita commented Jul 6, 2022

/lgtm

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

openshift-ci bot commented Jul 7, 2022

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

@openshift-ci openshift-ci bot merged commit a3a3396 into openshift:release-4.9 Jul 7, 2022
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jul 7, 2022

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

Bugzilla bug 2084336 has been moved to the MODIFIED state.

In response to this:

[release-4.9] Bug 2084336: Fix enabling PROXY protocol on an upgraded cluster

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. backport-risk-assessed Indicates a PR to a release branch has been evaluated and considered safe to accept. bugzilla/severity-high Referenced Bugzilla bug's severity is high 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. cherry-pick-approved Indicates a cherry-pick PR into a release branch has been approved by the release branch manager. lgtm Indicates that a PR is ready to be merged. qe-approved Signifies that QE has signed off on this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants