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

Use hashing to compare deployment specs for equality #13552

Conversation

SaschaSchwarze0
Copy link
Contributor

@SaschaSchwarze0 SaschaSchwarze0 commented Dec 13, 2022

Fixes #13204

Proposed Changes

We are running Knative at scale with thousands of services. We observed that there are frequent updates of the Kubernetes Deployment related to a Knative Revision. Most of these update operations are no-ops caused by an incorrect assumption that a locally built Deployment spec can be compared with the latest spec from the server object. This does not work because the server object has defaulting applied.

The proposed change

  • Introduces an annotation serving.knative.dev/deployment-spec-hash on the Deployment where the hash of the client-side created Deployment spec is stored.
  • In case of updates, this hash is used to compare against the newest version.
  • In case they are the same, the update call is omitted.

This saves us around 150k Update operations per day in our largest cluster.

Release Note

The revision reconciler now omits updates to the Deployment object when there are no changes to be made

@knative-prow knative-prow bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Dec 13, 2022
@knative-prow
Copy link

knative-prow bot commented Dec 13, 2022

Welcome @SaschaSchwarze0! It looks like this is your first PR to knative/serving 🎉

@knative-prow
Copy link

knative-prow bot commented Dec 13, 2022

Hi @SaschaSchwarze0. Thanks for your PR.

I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@knative-prow knative-prow bot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. area/API API objects and controllers labels Dec 13, 2022
@knative-prow knative-prow bot requested review from carlisia and nealhu December 13, 2022 12:40
@psschwei
Copy link
Contributor

/ok-to-test

@codecov
Copy link

codecov bot commented Dec 13, 2022

Codecov Report

Patch coverage: 75.67% and project coverage change: -0.06 ⚠️

Comparison is base (6bc4bb2) 86.16% compared to head (aae2e70) 86.11%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #13552      +/-   ##
==========================================
- Coverage   86.16%   86.11%   -0.06%     
==========================================
  Files         197      197              
  Lines       14790    14822      +32     
==========================================
+ Hits        12744    12764      +20     
- Misses       1743     1750       +7     
- Partials      303      308       +5     
Impacted Files Coverage Δ
pkg/reconciler/revision/resources/deploy.go 87.84% <70.00%> (-2.47%) ⬇️
pkg/reconciler/revision/cruds.go 64.70% <100.00%> (+2.20%) ⬆️

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@evankanderson
Copy link
Member

/assign @psschwei @dprotaso

Not sure if we want to be doing this, server-side-apply, checking managedFields, or something else...

@psschwei psschwei added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jan 3, 2023
@psschwei
Copy link
Contributor

psschwei commented Jan 3, 2023

I'd need to think a bit to see if I have any strong opinions on what the best way to do this is... going to add this as an agenda item for the next working group call in case that's easier than discussing here

@dprotaso
Copy link
Member

/hold

From: #13204 (comment)

I started to look at server side apply and I believe it could solve the excess upgrades described in this issue as well as allowing two controllers to coordinate reconciling a single resource (tracked here: knative/pkg#2128).

1.9 release is next week but I think this is worth digging into for Knative 1.10 (something that I can do)

@knative-prow knative-prow bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 18, 2023
@knative-prow-robot knative-prow-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 17, 2023
@SaschaSchwarze0 SaschaSchwarze0 force-pushed the sascha-deployment-updates branch from dbda09e to aae2e70 Compare March 2, 2023 07:59
@knative-prow-robot knative-prow-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 2, 2023
@knative-prow
Copy link

knative-prow bot commented Mar 2, 2023

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: SaschaSchwarze0
Once this PR has been reviewed and has the lgtm label, please ask for approval from dprotaso. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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

@knative-prow-robot knative-prow-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 27, 2023
@knative-prow-robot
Copy link
Contributor

PR needs rebase.

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.

@github-actions
Copy link

This Pull Request is stale because it has been open for 90 days with
no activity. It will automatically close after 30 more days of
inactivity. Reopen with /reopen. Mark as fresh by adding the
comment /remove-lifecycle stale.

@github-actions github-actions bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Aug 26, 2023
@dprotaso
Copy link
Member

Going to close this out - I'm actually going to focus on server side apply now which should address this

@dprotaso dprotaso closed this Aug 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/API API objects and controllers do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Revision reconciler always updates the Kubernetes Deployment
5 participants