Fix the issue that ownerref is not set with ignorefields (#794)
Scorecard supply-chain security / Scorecard analysis (push) Failing after 45s
Post / images (amd64) (push) Failing after 5m38s
Post / images (arm64) (push) Failing after 5m35s
Post / image manifest (push) Has been skipped
Post / trigger clusteradm e2e (push) Has been skipped
Post / coverage (push) Failing after 26m35s
Close stale issues and PRs / stale (push) Successful in 25s

Signed-off-by: Jian Qiu <jqiu@redhat.com>
This commit is contained in:
Jian Qiu
2025-01-10 03:19:59 +00:00
committed by GitHub
parent 0acf030cdb
commit 11896ccda1
2 changed files with 51 additions and 9 deletions
+2 -6
View File
@@ -95,12 +95,8 @@ func (c *ServerSideApply) Apply(
ctx, required.GetName(), metav1.GetOptions{})
switch {
case errors.IsNotFound(err):
// if object is not found, directly apply without removing ignore fields in the object.
obj, createErr := c.client.
Resource(gvr).
Namespace(required.GetNamespace()).
Apply(ctx, required.GetName(), requiredOriginal, metav1.ApplyOptions{FieldManager: fieldManager, Force: force})
return obj, createErr
// if object is not found, use requiredOriginal to apply so the ignore fields are kept when create
required = requiredOriginal
case err != nil:
return nil, err
case len(existing.GetAnnotations()) > 0: