Skip to content

Commit

Permalink
Fix loading resource checked status when created
Browse files Browse the repository at this point in the history
  • Loading branch information
wzshiming authored and k8s-infra-cherrypick-robot committed Feb 6, 2024
1 parent af1fea2 commit 26d626f
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions pkg/kwokctl/snapshot/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,19 +311,19 @@ func (l *Loader) apply(ctx context.Context, obj *unstructured.Unstructured) *uns
return nil
}
logger.Debug("Updated")
} else {
logger.Debug("Created")
}

if newObj != nil {
status, ok, _ := unstructured.NestedFieldNoCopy(obj.Object, "status")
if ok && !reflect.DeepEqual(newObj.Object["status"], status) {
newObj.Object["status"] = status
newObj, err = ri.UpdateStatus(ctx, newObj, metav1.UpdateOptions{FieldValidation: "Ignore"})
if err != nil {
logger.Error("Failed to update status", err)
if newObj != nil {
status, ok, _ := unstructured.NestedFieldNoCopy(obj.Object, "status")
if ok && !reflect.DeepEqual(newObj.Object["status"], status) {
newObj.Object["status"] = status
newObj, err = ri.UpdateStatus(ctx, newObj, metav1.UpdateOptions{FieldValidation: "Ignore"})
if err != nil {
logger.Error("Failed to update resource status", err)
}
}
}
} else {
logger.Debug("Created")
}

l.successCounter++
Expand Down

0 comments on commit 26d626f

Please sign in to comment.