Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
each changed object updated once
Signed-off-by: YuChen <[email protected]>
  • Loading branch information
YuChen committed Mar 25, 2024
commit 3a4a1a16c9e8853e71338b9b16cafe935f1ffa90
48 changes: 25 additions & 23 deletions controllers/operandrequest/reconcile_operand.go
Original file line number Diff line number Diff line change
Expand Up @@ -1094,41 +1094,43 @@ func (r *Reconciler) updateK8sResource(ctx context.Context, existingK8sRes unstr
r.EnsureLabel(existingK8sRes, newLabels)

if reflect.DeepEqual(existingK8sRes.Object[key], updatedExistingK8sRes) {
return true, nil
continue
}

CRgeneration := existingK8sRes.GetGeneration()

klog.Infof("updating k8s resource with apiversion: %s, kind: %s, %s/%s", apiversion, kind, namespace, name)

existingK8sRes.Object[key] = updatedExistingK8sRes
err = r.Update(ctx, &existingK8sRes)
}

if err != nil {
return false, errors.Wrapf(err, "failed to update k8s resource -- Kind: %s, NamespacedName: %s/%s", kind, namespace, name)
}
CRgeneration := existingK8sRes.GetGeneration()

UpdatedK8sRes := unstructured.Unstructured{
Object: map[string]interface{}{
"apiVersion": apiversion,
"kind": kind,
},
}
err = r.Update(ctx, &existingK8sRes)

err = r.Client.Get(ctx, types.NamespacedName{
Name: name,
Namespace: namespace,
}, &UpdatedK8sRes)
if err != nil {
return false, errors.Wrapf(err, "failed to update k8s resource -- Kind: %s, NamespacedName: %s/%s", kind, namespace, name)
}

if err != nil {
return false, errors.Wrapf(err, "failed to get k8s resource -- Kind: %s, NamespacedName: %s/%s", kind, namespace, name)
UpdatedK8sRes := unstructured.Unstructured{
Object: map[string]interface{}{
"apiVersion": apiversion,
"kind": kind,
},
}

}
err = r.Client.Get(ctx, types.NamespacedName{
Name: name,
Namespace: namespace,
}, &UpdatedK8sRes)

if err != nil {
return false, errors.Wrapf(err, "failed to get k8s resource -- Kind: %s, NamespacedName: %s/%s", kind, namespace, name)

if UpdatedK8sRes.GetGeneration() != CRgeneration {
klog.Infof("Finish updating the k8s Resource: -- Kind: %s, NamespacedName: %s/%s", kind, namespace, name)
}
}

if UpdatedK8sRes.GetGeneration() != CRgeneration {
klog.Infof("Finish updating the k8s Resource: -- Kind: %s, NamespacedName: %s/%s", kind, namespace, name)
}

}
return true, nil
})
Expand Down