From 997206d83f40d6d09f91c4bb529f1e2415aff3ba Mon Sep 17 00:00:00 2001 From: zhouhao_yewu Date: Sun, 11 Aug 2024 14:54:16 +0800 Subject: [PATCH] fix leaf pvc storage update Signed-off-by: zhouhao_yewu --- .../controllers/pvc/leaf_pvc_controller.go | 11 ++++++++++- .../controllers/pvc/root_pvc_controller.go | 2 -- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/pkg/clustertree/cluster-manager/controllers/pvc/leaf_pvc_controller.go b/pkg/clustertree/cluster-manager/controllers/pvc/leaf_pvc_controller.go index eb7597af2..9224b133d 100644 --- a/pkg/clustertree/cluster-manager/controllers/pvc/leaf_pvc_controller.go +++ b/pkg/clustertree/cluster-manager/controllers/pvc/leaf_pvc_controller.go @@ -104,7 +104,7 @@ func (l *LeafPVCController) Reconcile(ctx context.Context, request reconcile.Req klog.Errorf("patch pvc error: %v", err) return reconcile.Result{}, err } - _, err = l.RootClientSet.CoreV1().PersistentVolumeClaims(rootPVC.Namespace).Patch(ctx, + updatedRootPvc, err := l.RootClientSet.CoreV1().PersistentVolumeClaims(rootPVC.Namespace).Patch(ctx, rootPVC.Name, mergetypes.MergePatchType, patch, metav1.PatchOptions{}) if err != nil { klog.Errorf("patch pvc namespace: %q, name: %q to root cluster failed, error: %v", @@ -112,6 +112,15 @@ func (l *LeafPVCController) Reconcile(ctx context.Context, request reconcile.Req return reconcile.Result{RequeueAfter: utils.DefaultRequeueTime}, nil } + updatedRootPvc.Status = pvcCopy.Status + updatedRootPvc.ResourceVersion = "0" + err = l.RootClient.Status().Update(ctx, updatedRootPvc) + if err != nil { + klog.Errorf("update pvc status namespace: %q, name: %q to root cluster failed, error: %v", + request.NamespacedName.Namespace, request.NamespacedName.Name, err) + return reconcile.Result{RequeueAfter: utils.DefaultRequeueTime}, nil + } + return reconcile.Result{}, nil } diff --git a/pkg/clustertree/cluster-manager/controllers/pvc/root_pvc_controller.go b/pkg/clustertree/cluster-manager/controllers/pvc/root_pvc_controller.go index 5fbe27855..b9d02bc04 100644 --- a/pkg/clustertree/cluster-manager/controllers/pvc/root_pvc_controller.go +++ b/pkg/clustertree/cluster-manager/controllers/pvc/root_pvc_controller.go @@ -88,8 +88,6 @@ func (r *RootPVCController) Reconcile(ctx context.Context, request reconcile.Req if reflect.DeepEqual(pvcOld.Spec.Resources.Requests, pvc.Spec.Resources.Requests) { return reconcile.Result{}, nil } - pvcOld.Spec.Resources.Requests = pvc.Spec.Resources.Requests - pvc.Spec = pvcOld.Spec pvc.Annotations = pvcOld.Annotations pvc.ObjectMeta.UID = pvcOld.ObjectMeta.UID