-
Notifications
You must be signed in to change notification settings - Fork 273
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
fix(k8s): compareDeployedResources & manifest hash annotations #3386
Conversation
compareDeployedResources actually just skipped isSubset check in case the manifest hash was present. Now it actually returns "outdated" when manifest hash differs. This is necessary if the manifest removes annotations that are present in the deployed manifest. E.g.: 1. upsert annotations: {"some-annotation": "present"} 2. upsert annotations: {} before this change, compareDeployedResources just returned "ready" even though the deployedManifest was actually outdated (the annotation needed to be removed) This commit fixes that
previously we added garden manifest-hash only for kubectl apply ops. This commit makes sure to add the manifest-hash also for upserts. This enables for more accurate (and quicker) comparison results in compareDeployedResources for the affected resources.
e12d77a
to
10b2d1c
Compare
continue | ||
if (lastAppliedHashed) { | ||
const calculated = await hashManifest(manifest) | ||
if (calculated !== lastAppliedHashed) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably we should keep the continue if it's equal – that way we are saving some cpu cycles.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (calculated !== lastAppliedHashed) { | |
if (calculated === lastAppliedHashed) { | |
continue | |
} else { |
@@ -597,6 +597,17 @@ export class KubeApi { | |||
obj: O | |||
log: LogEntry | |||
}) { | |||
// Hash the raw input and add as an annotation on each manifest (this is helpful beyond kubectl's own annotation, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this code block is copied from apply()
and should be extracted to a helper method
There are some test failures. I'll convert this to a draft, and will try to take a look later this week. |
What this PR does / why we need it:
compareDeployedResources actually just skipped isSubset check in case
the manifest hash was present.
Now it actually returns "outdated" when manifest hash differs.
This is necessary if the manifest removes annotations that are
present in the deployed manifest.
E.g.:
before this change, compareDeployedResources just returned "ready"
even though the deployedManifest was actually outdated (the annotation
needed to be removed)
This commit fixes that
previously we added garden manifest-hash only for kubectl apply ops.
This commit makes sure to add the manifest-hash also for upserts.
This enables for more accurate (and quicker) comparison results in
compareDeployedResources for the affected resources.
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer: