Apply has no Force option to it, and will fail if it has to overwrite something (WIP)
Closed this issue ยท 2 comments
bdw617 commented
model in this case is either Kind.Deployment or Kind.DaemonSet
name: string,
namespace: string,
model: GenericClass,
) {
const app = await K8s(model).InNamespace(namespace).Get(name);
const checksum = crypto
.createHash("sha256")
.update(JSON.stringify(app))
.digest("hex");
try {
await K8s(model).Apply({
metadata: {
name: name,
namespace: namespace,
},
spec: {
template: {
metadata: {
annotations: {
"pepr.dev/checksum": checksum,
},
},
},
},
});
} catch (err) {
Log.error(`Failed to apply checksum to app: ${err.data?.message}`);
throw err;
}
}
this produces the same result
static async checksumApp(
name: string,
namespace: string,
model: GenericClass,
) {
const app = await K8s(model).InNamespace(namespace).Get(name);
app.spec.template.metadata.annotations["pepr.dev/checksum"] = crypto
.createHash("sha256")
.update(JSON.stringify(app))
.digest("hex");
app.metadata.managedFields = undefined;
try {
await K8s(model).Apply(app);
} catch (err) {
Log.error(`Failed to apply checksum to app: ${err.data?.message}`);
throw err;
}
}
lucasrod16 commented
Linking a workaround to allow Pepr to take ownership of an object's field(s) with a Patch()
operation:
This will prevent any field manager conflict errors until Server-Side Force Apply feature is available
github-actions commented
๐ This issue has been resolved in version 1.5.0 ๐
The release is available on:
Your semantic-release bot ๐ฆ๐