OCPBUGS-36465: Delete and recreate canary route to clear spec.host#1095
Conversation
|
@Miciah: This pull request references Jira Issue OCPBUGS-32887, which is invalid:
Comment The bug has been updated to refer to the pull request using the external bug tracker. 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 openshift-eng/jira-lifecycle-plugin repository. |
3239d99 to
e3c06ab
Compare
Fix the update logic for the canary route to handle clearing spec.host. Attempts to clear spec.host using a simple update may be ignored[1]. Therefore it is necessary to delete and recreate the route. 1. openshift/origin@54c072c Before this commit, the operator would set spec.subdomain, but it did not actually clear spec.host, and so setting spec.subdomain had no effect. After this commit, the operator should clear spec.host, and spec.subdomain should be in effect. Follow-up to commit 77c61ba. This commit is related to OCPBUGS-36465. https://issues.redhat.com/browse/OCPBUGS-36465 * pkg/operator/controller/canary/route.go (updateCanaryRoute): Delete and recreate the route in order to clear spec.host. (deleteCanaryRoute): Add an options parameter for updateCanaryRoute to use. * test/e2e/canary_test.go (TestCanaryRouteClearsSpecHost): New test. Verify that the operator clears spec.host if it is set on the canary route. * test/e2e/all_test.go (TestAll): Add TestCanaryRouteClearsSpecHost as a serial test.
e3c06ab to
1ae7e8c
Compare
|
@Miciah: This pull request references Jira Issue OCPBUGS-36465, which is valid. The bug has been moved to the POST state. 3 validation(s) were run on this bug
Requesting review from QA contact: The bug has been updated to refer to the pull request using the external bug tracker. 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 openshift-eng/jira-lifecycle-plugin repository. |
|
/assign |
|
/lgtm |
| // Attempts to clear spec.host may be ignored. Thus, to clear | ||
| // spec.host, it is necessary to delete and recreate the route. | ||
| log.Info("deleting and recreating the canary route to clear spec.host", "namespace", current.Namespace, "name", current.Name, "old spec.host", current.Spec.Host) | ||
| foreground := metav1.DeletePropagationForeground |
There was a problem hiding this comment.
DeletePropagationForeground keeps the key-value in the store until all the dependencies are also deleted (making sure there are no orphans). It's not perfectly clear to me why this is needed, but I don't expect it to cause any harm.
There was a problem hiding this comment.
The godoc for the DeletePropagationForeground value is getting into the implementation details, but the godoc for the PropagationPolicy field is more to the point:
// Whether and how garbage collection will be performed.
// Either this field or OrphanDependents may be set, but not both.
// The default policy is decided by the existing finalizer set in the
// metadata.finalizers and the resource-specific default policy.
// Acceptable values are: 'Orphan' - orphan the dependents; 'Background' -
// allow the garbage collector to delete the dependents in the background;
// 'Foreground' - a cascading policy that deletes all dependents in the
// foreground.The important thing is that deletion happens in the foreground so that the operator can immediately recreate the route.
| t.Log("Setting a bogus spec.host...") | ||
| if err := kclient.Update(context.TODO(), &canaryRoute); err != nil { | ||
| t.Fatal(err) | ||
| } |
There was a problem hiding this comment.
I think we need to specifically call the function updateCanaryRoute to test this. In unit test. Can be completed in a followup.
There was a problem hiding this comment.
This is an end-to-end test, not a unit test. All it needs to do is the following:
- Get the canary route.
- Update its
spec.hostfield. - Verify that the operator clears the field.
The fact that clearing the field requires deleting and recreating the route is irrelevant for this test. If the operator succeeds in clearing spec.host, it's good. Is there some case that this test fails to cover?
| return false, nil | ||
| } | ||
|
|
||
| if len(updated.Spec.Host) == 0 && len(current.Spec.Host) != 0 { |
There was a problem hiding this comment.
It looks like we also need to fix the function canaryRouteChanged to return true if the Spec.Host changed, otherwise we never get here.
/hold
There was a problem hiding this comment.
Update: I was mistaken on this.
/unhold
There was a problem hiding this comment.
https://github.com/openshift/cluster-ingress-operator/pull/965/files hasn't been fully backported yet and I was looking in the wrong branch.
|
/approve |
|
[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 DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
@Miciah: all tests passed! 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-sigs/prow repository. I understand the commands that are listed here. |
|
@Miciah: Jira Issue OCPBUGS-36465: All pull requests linked via external trackers have merged: Jira Issue OCPBUGS-36465 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 openshift-eng/jira-lifecycle-plugin repository. |
|
[ART PR BUILD NOTIFIER] This PR has been included in build ose-cluster-ingress-operator-container-v4.17.0-202407102341.p0.gf072291.assembly.stream.el9 for distgit ose-cluster-ingress-operator. |
Fix the update logic for the canary route to handle clearing
spec.host. Attempts to clearspec.hostusing a simple update may be ignored (see openshift/origin@54c072c). Therefore it is necessary to delete and recreate the route.Before this change, the operator would set
spec.subdomain, but it did not actually clearspec.host, and so settingspec.subdomainhad no effect.After this change, the operator should clear
spec.host, andspec.subdomainshould be in effect.Follow-up to #1047.