From df81a7b18eb911c37dc1fdd33798cd1edfcc1e55 Mon Sep 17 00:00:00 2001 From: ioito Date: Mon, 17 Jul 2023 17:47:27 +0800 Subject: [PATCH] fix(region): skip sync resource when account created --- pkg/compute/models/cloudaccounts.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/pkg/compute/models/cloudaccounts.go b/pkg/compute/models/cloudaccounts.go index 3e463a324f..c6af60a6cc 100644 --- a/pkg/compute/models/cloudaccounts.go +++ b/pkg/compute/models/cloudaccounts.go @@ -29,6 +29,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/gotypes" "yunion.io/x/pkg/tristate" "yunion.io/x/pkg/util/compare" "yunion.io/x/pkg/util/httputils" @@ -836,9 +837,18 @@ func (self *SCloudaccount) StartSyncCloudAccountInfoTask(ctx context.Context, us if data != nil { params.Update(data) } - if syncRange != nil { - params.Add(jsonutils.Marshal(syncRange), "sync_range") + if gotypes.IsNil(syncRange) { + syncRange = &SSyncRange{} + syncRange.FullSync = true + syncRange.DeepSync = true } + syncRange.SkipSyncResources = []string{} + if self.SkipSyncResources != nil { + for _, res := range *self.SkipSyncResources { + syncRange.SkipSyncResources = append(syncRange.SkipSyncResources, res) + } + } + params.Add(jsonutils.Marshal(syncRange), "sync_range") task, err := taskman.TaskManager.NewTask(ctx, "CloudAccountSyncInfoTask", self, userCred, params, "", "", nil) if err != nil {