Skip to content

Commit

Permalink
fix(k8s): add manifest-hash annotations also for upsert operations
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
stefreak committed Nov 25, 2022
1 parent ac474d4 commit e12d77a
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions core/src/plugins/kubernetes/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
// because kubectl applies some normalization/transformation that is sometimes difficult to reason about).
// Hashing the input prevents "Too long annotation..." errors.
if (!obj.metadata.annotations) {
obj.metadata.annotations = {}
}
if (obj.metadata.annotations[gardenAnnotationKey("manifest-hash")]) {
delete obj.metadata.annotations[gardenAnnotationKey("manifest-hash")]
}
obj.metadata.annotations[gardenAnnotationKey("manifest-hash")] = await hashManifest(obj)

const api = this[crudMap[kind].group]
const name = obj.metadata.name

Expand Down

0 comments on commit e12d77a

Please sign in to comment.