Skip to content

OCPBUGS-36465: Delete and recreate canary route to clear spec.host#1095

Merged
openshift-merge-bot[bot] merged 1 commit intoopenshift:masterfrom
Miciah:OCPBUGS-32887-delete-and-recreate-the-canary-route-to-clear-spec.host
Jul 10, 2024
Merged

OCPBUGS-36465: Delete and recreate canary route to clear spec.host#1095
openshift-merge-bot[bot] merged 1 commit intoopenshift:masterfrom
Miciah:OCPBUGS-32887-delete-and-recreate-the-canary-route-to-clear-spec.host

Conversation

@Miciah
Copy link
Contributor

@Miciah Miciah commented Jun 27, 2024

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 (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 clear spec.host, and so setting spec.subdomain had no effect.

After this change, the operator should clear spec.host, and spec.subdomain should be in effect.

Follow-up to #1047.

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

@Miciah: This pull request references Jira Issue OCPBUGS-32887, which is invalid:

  • expected the bug to target either version "4.17." or "openshift-4.17.", but it targets "4.16.0" instead

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

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

Details

In response to this:

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 (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 clear spec.host, and so setting spec.subdomain had no effect.

After this change, the operator should clear spec.host, and spec.subdomain should be in effect.

Follow-up to #1047.

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.

@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 27, 2024
@openshift-ci openshift-ci bot requested review from gcs278 and knobunc June 27, 2024 03:57
@Miciah Miciah force-pushed the OCPBUGS-32887-delete-and-recreate-the-canary-route-to-clear-spec.host branch from 3239d99 to e3c06ab Compare June 27, 2024 03:59
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 27, 2024
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.
@Miciah Miciah force-pushed the OCPBUGS-32887-delete-and-recreate-the-canary-route-to-clear-spec.host branch from e3c06ab to 1ae7e8c Compare July 2, 2024 23:48
@Miciah Miciah changed the title OCPBUGS-32887: Delete and recreate canary route to clear spec.host OCPBUGS-36465: Delete and recreate canary route to clear spec.host Jul 2, 2024
@openshift-ci-robot openshift-ci-robot added jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. and removed jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Jul 2, 2024
@openshift-ci-robot
Copy link
Contributor

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

Requesting review from QA contact:
/cc @melvinjoseph86

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

Details

In response to this:

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 (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 clear spec.host, and so setting spec.subdomain had no effect.

After this change, the operator should clear spec.host, and spec.subdomain should be in effect.

Follow-up to #1047.

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.

@candita
Copy link
Contributor

candita commented Jul 3, 2024

/assign
/assign @rfredette

@rfredette
Copy link
Contributor

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jul 9, 2024
// 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
Copy link
Contributor

@candita candita Jul 10, 2024

Choose a reason for hiding this comment

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

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.

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 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)
}
Copy link
Contributor

@candita candita Jul 10, 2024

Choose a reason for hiding this comment

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

I think we need to specifically call the function updateCanaryRoute to test this. In unit test. Can be completed in a followup.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is an end-to-end test, not a unit test. All it needs to do is the following:

  1. Get the canary route.
  2. Update its spec.host field.
  3. 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 {
Copy link
Contributor

Choose a reason for hiding this comment

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

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Update: I was mistaken on this.
/unhold

Copy link
Contributor

Choose a reason for hiding this comment

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

https://github.com/openshift/cluster-ingress-operator/pull/965/files hasn't been fully backported yet and I was looking in the wrong branch.

@openshift-ci openshift-ci bot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. and removed do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels Jul 10, 2024
@candita
Copy link
Contributor

candita commented Jul 10, 2024

/approve

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jul 10, 2024

[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

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 openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 10, 2024
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jul 10, 2024

@Miciah: all tests passed!

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

@openshift-merge-bot openshift-merge-bot bot merged commit f072291 into openshift:master Jul 10, 2024
@openshift-ci-robot
Copy link
Contributor

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

Details

In response to this:

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 (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 clear spec.host, and so setting spec.subdomain had no effect.

After this change, the operator should clear spec.host, and spec.subdomain should be in effect.

Follow-up to #1047.

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.

@openshift-bot
Copy link
Contributor

[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.
All builds following this will include this PR.

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-moderate Referenced Jira bug's severity is moderate 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.

6 participants