From d37ba49257f3a71fa3d0456580996d69fe0a20ff Mon Sep 17 00:00:00 2001 From: "kevin.qiao" Date: Mon, 25 Apr 2022 22:48:28 +0800 Subject: [PATCH] fix reconcile bug --- pkg/controller/component/storaged_scaler.go | 20 ++++++++++++-------- pkg/nebula/meta_client.go | 6 +++--- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/pkg/controller/component/storaged_scaler.go b/pkg/controller/component/storaged_scaler.go index bf3bfa83..4ddb3db0 100644 --- a/pkg/controller/component/storaged_scaler.go +++ b/pkg/controller/component/storaged_scaler.go @@ -210,12 +210,14 @@ func (ss *storageScaler) balanceSpace(mc nebula.MetaInterface, nc *v1alpha1.Nebu } jobID, err := mc.BalanceData(spaceID) if err != nil { + if jobID > 0 { + nc.Status.Storaged.LastBalanceJob = &v1alpha1.BalanceJob{ + SpaceID: spaceID, + JobID: jobID, + } + } return err } - nc.Status.Storaged.LastBalanceJob = &v1alpha1.BalanceJob{ - SpaceID: spaceID, - JobID: jobID, - } return nil } @@ -229,12 +231,14 @@ func (ss *storageScaler) removeHost( } jobID, err := mc.RemoveHost(spaceID, hosts) if err != nil { + if jobID > 0 { + nc.Status.Storaged.LastBalanceJob = &v1alpha1.BalanceJob{ + SpaceID: spaceID, + JobID: jobID, + } + } return err } - nc.Status.Storaged.LastBalanceJob = &v1alpha1.BalanceJob{ - SpaceID: spaceID, - JobID: jobID, - } return nil } diff --git a/pkg/nebula/meta_client.go b/pkg/nebula/meta_client.go index 06ef56b2..98f506c9 100644 --- a/pkg/nebula/meta_client.go +++ b/pkg/nebula/meta_client.go @@ -326,12 +326,12 @@ func (m *metaClient) balance(req *meta.AdminJobReq) (int32, error) { return 0, errors.Errorf("retry balance code %d", resp.Code) } log.Info("balance job running now") - return resp.GetResult_().GetJobID(), nil + return resp.GetResult_().GetJobID(), utilerrors.ReconcileErrorf("waiting for balance job %d finished", resp.GetResult_().GetJobID()) } - return resp.GetResult_().GetJobID(), errors.Errorf("balance code %d", resp.Code) + return 0, errors.Errorf("balance code %d", resp.Code) } log.Info("balance job running now") - return resp.GetResult_().GetJobID(), nil + return resp.GetResult_().GetJobID(), utilerrors.ReconcileErrorf("waiting for balance job %d finished", resp.GetResult_().GetJobID()) } func (m *metaClient) BalanceData(spaceID nebula.GraphSpaceID) (int32, error) {