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-26498: Optimize Upgrade Validation plugin by skipping unnecessary changes #587

Merged

Conversation

gcs278
Copy link
Contributor

@gcs278 gcs278 commented Apr 25, 2024

Both performIngressConditionUpdate and performIngressConditionRemoval functions add tasks to the writerlease queue even if no work needed to be done. This commit optimizes the Upgrade Validation plugin by ensuring that tasks for updating UnservableInFutureVersions are only added to the queue when changes are required.

This reduction in unnecessary work significantly lowers the frequency of lease extensions. Previously, excessive lease extensions could delay route status updates under certain conditions, such as during temporary contention periods
where a router pod gets demoted to a follower. After the contention is resolved, the pod’s subsequent retry will be delayed more than necessary.

Additionally, this update provides a clearer indication of when updates are actually required, but have been completed by another router pod. The prior logic did not clearly distinguish between unnecessary updates and updates that were completed by another pod.

The selective updates are only added to the interface used by Upgrade Validation plugin to avoid perturbing existing Admitted condition logic. This means nominal clusters without SHA1 routes should not be impacted by the Upgrade
Validation plugin, minimizing the risk associated with its introduction.

Fixes TestRouteAdmissionPolicy Flake by reducing the number of unnecessary lease extensions.

@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/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. labels Apr 25, 2024
@openshift-ci-robot
Copy link
Contributor

@gcs278: This pull request references Jira Issue OCPBUGS-26498, which is valid.

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

Requesting review from QA contact:
/cc @ShudiLi

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

In response to this:

Previously, both performIngressConditionUpdate and performIngressConditionRemoval functions were adding tasks to the writerlease queue even if no work needed to be done. This commit optimizes the logic by ensuring that tasks are only added to the queue when changes are required.

This reduction in unnecessary work significantly lowers the frequency of lease extensions. Previously, excessive lease extensions could delay route status updates under certain conditions, such as during temporary contention periods
where a router pod gets demoted to a follower. After the contention is resolved, the pod’s subsequent retry will be delayed more than necessary.

Additionally, this update provides a clearer indication of when updates are actually required, but have been completed by another router pod. The prior logic did not clearly distinguish between unnecessary updates and updates that were completed by another pod.

This PR also add some logging in leasewriter and the plugin chain for assisting future debugging efforts.

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.

@gcs278 gcs278 changed the title OCPBUGS-26498: Optimize route status updates by skipping unnecessary changes [WIP] OCPBUGS-26498: Optimize route status updates by skipping unnecessary changes Apr 25, 2024
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 25, 2024
@gcs278 gcs278 force-pushed the efficient-route-status-updates branch from caddb91 to 6746855 Compare April 25, 2024 17:34
@gcs278
Copy link
Contributor Author

gcs278 commented Apr 29, 2024

Though this is a valid improvement, I'm closing in favor of #588 as I now don't think this PR fixes the TestRouteAdmissionPolicy flake.

/close

Copy link
Contributor

openshift-ci bot commented Apr 29, 2024

@gcs278: Closed this PR.

In response to this:

Though this is a valid improvement, I'm closing in favor of #588 as I now don't think this PR fixes the TestRouteAdmissionPolicy flake.

/close

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 closed this Apr 29, 2024
@openshift-ci-robot
Copy link
Contributor

@gcs278: This pull request references Jira Issue OCPBUGS-26498. The bug has been updated to no longer refer to the pull request using the external bug tracker.

In response to this:

Previously, both performIngressConditionUpdate and performIngressConditionRemoval functions were adding tasks to the writerlease queue even if no work needed to be done. This commit optimizes the logic by ensuring that tasks are only added to the queue when changes are required.

This reduction in unnecessary work significantly lowers the frequency of lease extensions. Previously, excessive lease extensions could delay route status updates under certain conditions, such as during temporary contention periods
where a router pod gets demoted to a follower. After the contention is resolved, the pod’s subsequent retry will be delayed more than necessary.

Additionally, this update provides a clearer indication of when updates are actually required, but have been completed by another router pod. The prior logic did not clearly distinguish between unnecessary updates and updates that were completed by another pod.

Fixes TestRouteAdmissionPolicy Flake by reducing the number of unnecessary lease extensions.

This PR also add some logging in writerlease and the plugin chain for assisting future debugging efforts.

WIP because it needs testing.

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.

@gcs278
Copy link
Contributor Author

gcs278 commented May 1, 2024

TestRouteAdmissionPolicy is still flaking, and this may be a reasonable fix.
/reopen

Copy link
Contributor

openshift-ci bot commented May 1, 2024

@gcs278: Reopened this PR.

In response to this:

TestRouteAdmissionPolicy is still flaking, and this may be a reasonable fix.
/reopen

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 reopened this May 1, 2024
@openshift-ci-robot
Copy link
Contributor

@gcs278: This pull request references Jira Issue OCPBUGS-26498, which is valid.

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

Requesting review from QA contact:
/cc @ShudiLi

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

In response to this:

Previously, both performIngressConditionUpdate and performIngressConditionRemoval functions were adding tasks to the writerlease queue even if no work needed to be done. This commit optimizes the logic by ensuring that tasks are only added to the queue when changes are required.

This reduction in unnecessary work significantly lowers the frequency of lease extensions. Previously, excessive lease extensions could delay route status updates under certain conditions, such as during temporary contention periods
where a router pod gets demoted to a follower. After the contention is resolved, the pod’s subsequent retry will be delayed more than necessary.

Additionally, this update provides a clearer indication of when updates are actually required, but have been completed by another router pod. The prior logic did not clearly distinguish between unnecessary updates and updates that were completed by another pod.

Fixes TestRouteAdmissionPolicy Flake by reducing the number of unnecessary lease extensions.

This PR also add some logging in writerlease and the plugin chain for assisting future debugging efforts.

WIP because it needs testing.

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 May 1, 2024
@gcs278 gcs278 force-pushed the efficient-route-status-updates branch from 6746855 to b3fcf1e Compare May 1, 2024 14:16
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 1, 2024
@gcs278 gcs278 changed the title [WIP] OCPBUGS-26498: Optimize route status updates by skipping unnecessary changes [WIP] OCPBUGS-26498: Optimize Upgrade Validation plugin by skipping unnecessary changes May 1, 2024
@gcs278 gcs278 force-pushed the efficient-route-status-updates branch from b3fcf1e to 73ab620 Compare May 1, 2024 14:34
// We only do this in for the new UnservableInFutureVersions condition to avoid perturbing existing logic for the
// Admitted condition. This should be reevaluated when refactoring to use a single route status update per route
// reconciliation (see TODO at top of file).
changed, _, _, _, _ := recordIngressCondition(route.DeepCopy(), a.routerName, a.routerCanonicalHostname, expectedCondition)
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a comment to note that route.DeepCopy() is necessary because recordIngressCondition actually modifies route.

Copy link
Contributor

Choose a reason for hiding this comment

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

Consider refactoring to use findCondition instead of recordIngressCondition to save some overhead from deepcopies etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@gcs278 gcs278 force-pushed the efficient-route-status-updates branch from 73ab620 to 62ebee7 Compare May 1, 2024 17:52
@gcs278 gcs278 changed the title [WIP] OCPBUGS-26498: Optimize Upgrade Validation plugin by skipping unnecessary changes OCPBUGS-26498: Optimize Upgrade Validation plugin by skipping unnecessary changes May 1, 2024
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 1, 2024
@gcs278
Copy link
Contributor Author

gcs278 commented May 1, 2024

Putting a hold to wait for testing confirmation.
/hold

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 1, 2024
Comment on lines 369 to 374
changed := existing.Host != route.Spec.Host ||
existing.WildcardPolicy != route.Spec.WildcardPolicy ||
existing.RouterCanonicalHostname != hostName
if changed {
return true
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Reading this and the unit test makes me realize that both the StatusAdmitter plugin and the UpgradeValidation plugin update the status ingress entry in case one of these fields (Host, WildcardPolicy, or RouterCanonicalHostname) needs to be updated.

Suppose the route has a host name that conflicts with another route's, and then the route is updated to have a non-conflicting host name. UpgradeValidation runs first in the plugin chain, so it updates the status ingress entry first, and the StatusAdmitter plugin updates the status condition second. Do I have that right?

Would it be safer for RecordRouteUnservableInFutureVersions to ignore changes to the status ingress entry other than the UnservableInFutureVersions status condition?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suppose the route has a host name that conflicts with another route's, and then the route is updated to have a non-conflicting host name. UpgradeValidation runs first in the plugin chain, so it updates the status ingress entry first, and the StatusAdmitter plugin updates the status condition second. Do I have that right?

Correct. Both UpgradeValidation and StatusAdmitter try to update the new host name as part of the ingress fields.

Would it be safer for RecordRouteUnservableInFutureVersions to ignore changes to the status ingress entry other than the UnservableInFutureVersions status condition?

Hmmm. Yea it might be slightly safer. If the route is also going from Rejected to Admitted, you'll have this sequence:

  1. Route is updated to fix hostname
  2. UpgradeValidation updates status to fix hostname
  3. StatusAdmitter updates status from Admitted=False to Admitted=True

If we limit UpgradeValidation to just changes in UnservableInFutureVersions, we should only get one status update:

  1. Route is updated to fix hostname
  2. UpgradeValidation does nothing since it only cares about UnservableInFutureVersions
  3. StatusAdmitter updates status to fix hostname and sets Admitted=False to Admitted=True

So yes, I agree. I can update it so we only care about conditions changes. That way, if it's just a hostname change, the UpgradeValidation plugin will let StatusAdmitter take care of that.

@gcs278 gcs278 force-pushed the efficient-route-status-updates branch 2 times, most recently from a75561c to 7c01e09 Compare May 1, 2024 23:06
Both performIngressConditionUpdate and performIngressConditionRemoval functions
add tasks to the writerlease queue even if no work needed to be done. This commit
optimizes the Upgrade Validation plugin by ensuring that tasks for updating
UnservableInFutureVersions are only added to the queue when changes are required.

This reduction in unnecessary work significantly lowers the frequency of lease
extensions. Previously, excessive lease extensions could delay route status
updates under certain conditions, such as during temporary contention periods
where a router pod gets demoted to a follower. After the contention is resolved,
the pod’s subsequent retry will be delayed more than necessary.

Additionally, this update provides a clearer indication of when updates are actually
required, but have been completed by another router pod. The prior logic did not
clearly distinguish between unnecessary updates and updates that were completed by
another pod.

The selective updates are only added to the interface used by Upgrade Validation
plugin to avoid perturbing existing Admitted condition logic. This means
nominal clusters without SHA1 routes should not be impacted by the Upgrade
Validation plugin, minimizing the risk associated with its introduction.
@gcs278 gcs278 force-pushed the efficient-route-status-updates branch from 7c01e09 to 13ab1dd Compare May 1, 2024 23:11
@Miciah
Copy link
Contributor

Miciah commented May 1, 2024

Thanks!
/approve
/lgtm

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

openshift-ci bot commented May 1, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: 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 added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 1, 2024
Copy link
Contributor

openshift-ci bot commented May 2, 2024

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

@gcs278
Copy link
Contributor Author

gcs278 commented May 2, 2024

I've ran nearly a hundred times with my e2e test in openshift/origin#28710 and no issues. Reviewed the router logs and lease extends are drastically reduced.
/hold cancel

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 2, 2024
@openshift-merge-bot openshift-merge-bot bot merged commit 5610ac8 into openshift:master May 2, 2024
8 checks passed
@openshift-ci-robot
Copy link
Contributor

@gcs278: Jira Issue OCPBUGS-26498: Some pull requests linked via external trackers have merged:

The following pull requests linked via external trackers have not merged:

These pull request must merge or be unlinked from the Jira bug in order for it to move to the next state. Once unlinked, request a bug refresh with /jira refresh.

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

In response to this:

Both performIngressConditionUpdate and performIngressConditionRemoval functions add tasks to the writerlease queue even if no work needed to be done. This commit optimizes the Upgrade Validation plugin by ensuring that tasks for updating UnservableInFutureVersions are only added to the queue when changes are required.

This reduction in unnecessary work significantly lowers the frequency of lease extensions. Previously, excessive lease extensions could delay route status updates under certain conditions, such as during temporary contention periods
where a router pod gets demoted to a follower. After the contention is resolved, the pod’s subsequent retry will be delayed more than necessary.

Additionally, this update provides a clearer indication of when updates are actually required, but have been completed by another router pod. The prior logic did not clearly distinguish between unnecessary updates and updates that were completed by another pod.

The selective updates are only added to the interface used by Upgrade Validation plugin to avoid perturbing existing Admitted condition logic. This means nominal clusters without SHA1 routes should not be impacted by the Upgrade
Validation plugin, minimizing the risk associated with its introduction.

Fixes TestRouteAdmissionPolicy Flake by reducing the number of unnecessary lease extensions.

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-haproxy-router-base-container-v4.16.0-202405020546.p0.g5610ac8.assembly.stream.el9 for distgit ose-haproxy-router-base.
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.

None yet

5 participants