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

OCPBUGS-14994: Don't add clientca-configmap finalizer if deleting #948

Conversation

Miciah
Copy link
Contributor

@Miciah Miciah commented Jun 15, 2023

Don't add the clientca-configmap finalizer to an IngressController if it is marked for deletion.

Before this change, the clientca-configmap controller would attempt to add (or re-add) its finalizer to an IngressController that had been marked for deletion. This attempt resulted in the following error from the API:

IngressController.operator.openshift.io "test-client-ca-configmap" is invalid: metadata.finalizers: Forbidden: no new finalizers can be added if the object is being deleted, found new finalizers []string{"ingresscontroller.operator.openshift.io/finalizer-clientca-configmap"}

The controller would retry adding the finalizer repeatedly, causing the same error to be repeatedly logged until the deletion completed.

  • pkg/operator/controller/clientca-configmap/controller.go (Reconcile): Only attempt to add the finalizer if the IngressController is not marked for deletion.

@openshift-ci-robot openshift-ci-robot added jira/severity-low Referenced Jira bug's severity is low for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. labels Jun 15, 2023
@openshift-ci-robot
Copy link
Contributor

@Miciah: This pull request references Jira Issue OCPBUGS-14994, which is valid. The bug has been moved to the POST state.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.14.0) matches configured target version for branch (4.14.0)
  • bug is in the state New, which is one of the valid states (NEW, ASSIGNED, POST)

Requesting review from QA contact:
/cc @lihongan

The bug has been updated to refer to the pull request using the external bug tracker.

In response to this:

Don't add the clientca-configmap finalizer to an IngressController if it is marked for deletion.

Before this change, the clientca-configmap controller would attempt to add (or re-add) its finalizer to an IngressController that had been marked for deletion. This attempt resulted in the following error from the API:

IngressController.operator.openshift.io "test-client-ca-configmap" is invalid: metadata.finalizers: Forbidden: no new finalizers can be added if the object is being deleted, found new finalizers []string{"ingresscontroller.operator.openshift.io/finalizer-clientca-configmap"}

The controller would retry adding the finalizer repeatedly, causing the same error to be repeatedly logged until the deletion completed.

  • pkg/operator/controller/clientca-configmap/controller.go (Reconcile): Only attempt to add the finalizer if the IngressController is not marked for deletion.

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.

@candita
Copy link
Contributor

candita commented Jun 21, 2023

/assign

@@ -191,7 +191,7 @@ func (r *reconciler) Reconcile(ctx context.Context, request reconcile.Request) (
}

const finalizer = "ingresscontroller.operator.openshift.io/finalizer-clientca-configmap"
if len(ic.Spec.ClientTLS.ClientCA.Name) != 0 && !slice.ContainsString(ic.Finalizers, finalizer) {
if len(ic.Spec.ClientTLS.ClientCA.Name) != 0 && ic.DeletionTimestamp == nil && !slice.ContainsString(ic.Finalizers, finalizer) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add a unit test for this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Miciah Miciah force-pushed the OCPBUGS-14994-do-not-add-clientca-configmap-finalizer-if-deleting branch from d6ec543 to b3ea675 Compare June 22, 2023 02:50
@candita
Copy link
Contributor

candita commented Jun 26, 2023

/retest-required

@openshift-bot
Copy link
Contributor

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@openshift-ci openshift-ci bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Sep 25, 2023
@candita
Copy link
Contributor

candita commented Sep 25, 2023

/remove-lifecycle stale

@openshift-ci openshift-ci bot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Sep 25, 2023
@candita
Copy link
Contributor

candita commented Sep 25, 2023

/test e2e-gpc-ovn
/test e2e-azure-operator
/test e2e-aws-ovn-single-node

@candita
Copy link
Contributor

candita commented Oct 18, 2023

/assign @frobware

expectDelete: []client.Object{},
},
{
name: "source configmap absent, target configmap absent, finalizer absent",
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't the source configmap present in existingObjects and expectUpdate? And the finalizer is present in expectUpdate too. Am I reading it wrong?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this test case, the IngressController exists and specifies the "ca-bundle" configmap, but the configmap doesn't exist, so the controller can add the finalizer but cannot copy the configmap.

Copy link
Contributor

Choose a reason for hiding this comment

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

If it's not too much trouble, it would be helpful to specify in the test name what the outcome of the test is supposed to be. So here, because there is no cm in the existingObjects, there is no cm in the expectUpdate? And, it is ok for the configmap name to be there in the ic even if there is no cm object? And we only add a finalizer if there is a configmap name, even if there is no matching cm object?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If it's not too much trouble, it would be helpful to specify in the test name what the outcome of the test is supposed to be.

Done in https://github.com/openshift/cluster-ingress-operator/compare/3a3fb20502db4bb46db3de1ffef89faa5f84cc6a..e9ceaf5969c681a0ba773d5f97bc661703dfbf17.

So here, because there is no cm in the existingObjects, there is no cm in the expectUpdate?

Correct. There is no source configmap, so the controller cannot make a copy of it.

And, it is ok for the configmap name to be there in the ic even if there is no cm object?

It can happen, so the controller needs to handle the case. The router pods cannot start until the configmap exists though because the router pods have a volume mount for the configmap.

And we only add a finalizer if there is a configmap name, even if there is no matching cm object?

Correct.

Namespace: "openshift-ingress-operator",
Name: "test",
},
Spec: operatorv1.IngressControllerSpec{
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is the configmap being examined in these tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The purpose of this controller is to copy the user-provided configmap, which is specified in the IngressController, from the "openshift-config" namespace into the "openshift-ingress" namespace, so the test is written to give the controller an IngressController that specifies a configmap and verify that the controller copies the configmap if it exists.

Did I understand your question correctly and answer it? Should I add a code comment with the above explanation?

Copy link
Contributor

Choose a reason for hiding this comment

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

I was expecting a test that only checked for refraining of adding the finalizer when deleting.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The controller was missing test coverage entirely, so I added a comprehensive test, including test cases for the specific issue in OCPBUGS-14994. Would it be better if I split it into two commits: one to add the test and one to add the specific test case that is related to OCPBUGS-14994?

Copy link
Contributor

Choose a reason for hiding this comment

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

No, this is fine.

Copy link
Contributor

@frobware frobware left a comment

Choose a reason for hiding this comment

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

LGTM, just a comment regarding the necessity of the OperatorNamespace in Test_Reconcile.

@frobware
Copy link
Contributor

/retest

@frobware
Copy link
Contributor

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Oct 19, 2023
Don't add the clientca-configmap finalizer to an IngressController if it is
marked for deletion.

Before this commit, the clientca-configmap controller would attempt to
add (or re-add) its finalizer to an IngressController that had been marked
for deletion.  This attempt resulted in the following error from the API:

    IngressController.operator.openshift.io "test-client-ca-configmap" is invalid: metadata.finalizers: Forbidden: no new finalizers can be added if the object is being deleted, found new finalizers []string{"ingresscontroller.operator.openshift.io/finalizer-clientca-configmap"}

The controller would retry adding the finalizer repeatedly, causing the
same error to be repeatedly logged until the deletion completed.

This commit fixes OCPBUGS-14994.

https://issues.redhat.com/browse/OCPBUGS-14994

* pkg/operator/controller/clientca-configmap/controller.go (Reconcile):
Only attempt to add the finalizer if the IngressController is not marked
for deletion.
* pkg/operator/controller/clientca-configmap/controller_test.go: New file.
(Test_Reconcile): New test.  Verify that Reconcile adds and removes the
finalizer and creates, updates, or deletes the target configmap as
appropriate.
(fakeClientRecorder): New type, used in Test_Reconcile.
(Create, Delete, Update): New methods for fakeClientRecorder to implement
the controller-runtime client.Client interface.
* pkg/operator/controller/clientca-configmap/controller.go (Config):
* pkg/operator/controller/clientca-configmap/controller_test.go (Test_Reconcile):
* pkg/operator/operator.go (New): Remove unused OperatorNamespace field.
@Miciah Miciah force-pushed the OCPBUGS-14994-do-not-add-clientca-configmap-finalizer-if-deleting branch from 3a3fb20 to e9ceaf5 Compare October 25, 2023 04:50
@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Oct 25, 2023
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Oct 25, 2023

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

@frobware
Copy link
Contributor

Good doc additions on both the test function and individual test cases.

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Oct 25, 2023
@candita
Copy link
Contributor

candita commented Oct 30, 2023

/approve

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Oct 30, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: candita

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 added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 30, 2023
@openshift-ci openshift-ci bot merged commit 23ee5be into openshift:master Oct 30, 2023
14 checks passed
@openshift-ci-robot
Copy link
Contributor

@Miciah: Jira Issue OCPBUGS-14994: All pull requests linked via external trackers have merged:

Jira Issue OCPBUGS-14994 has been moved to the MODIFIED state.

In response to this:

Don't add the clientca-configmap finalizer to an IngressController if it is marked for deletion.

Before this change, the clientca-configmap controller would attempt to add (or re-add) its finalizer to an IngressController that had been marked for deletion. This attempt resulted in the following error from the API:

IngressController.operator.openshift.io "test-client-ca-configmap" is invalid: metadata.finalizers: Forbidden: no new finalizers can be added if the object is being deleted, found new finalizers []string{"ingresscontroller.operator.openshift.io/finalizer-clientca-configmap"}

The controller would retry adding the finalizer repeatedly, causing the same error to be repeatedly logged until the deletion completed.

  • pkg/operator/controller/clientca-configmap/controller.go (Reconcile): Only attempt to add the finalizer if the IngressController is not marked for deletion.

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-merge-robot
Copy link
Contributor

Fix included in accepted release 4.15.0-0.nightly-2023-10-31-054858

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. jira/severity-low Referenced Jira bug's severity is low for the branch this PR is targeting. jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants