From 22d15cfae992d14627907392d2b16fa6a272f28f Mon Sep 17 00:00:00 2001 From: LiuYan <361112237@qq.com> Date: Tue, 28 Feb 2023 18:50:41 +0800 Subject: [PATCH] fix(constraints.gatekeeper.sh.constraint): fix resourceVersion not updated issue (#8285) --- shell/models/constraints.gatekeeper.sh.constraint.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/shell/models/constraints.gatekeeper.sh.constraint.js b/shell/models/constraints.gatekeeper.sh.constraint.js index 6ae8d3919e..63c735f7a8 100644 --- a/shell/models/constraints.gatekeeper.sh.constraint.js +++ b/shell/models/constraints.gatekeeper.sh.constraint.js @@ -9,15 +9,20 @@ export const ENFORCEMENT_ACTION_VALUES = { export default class GateKeeperConstraint extends SteveModel { async save() { let constraint; + let resourceVersion; if (this.constraint) { constraint = await this.findLatestConstraint(); + resourceVersion = constraint?.metadata?.resourceVersion; } else { constraint = await this.$dispatch('cluster/create', { type: `constraints.gatekeeper.sh.${ this.kind.toLowerCase() }` }, { root: true }); } constraint.spec = this.spec; constraint.metadata = this.metadata; + if (resourceVersion) { + constraint.metadata.resourceVersion = resourceVersion; + } await constraint.save(); }