From caeea77878720ef5749d31abe871a5410db86d6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B1=88=E8=BD=A9?= Date: Sat, 7 May 2022 20:07:24 +0800 Subject: [PATCH] fix(region): remove metadata (#14214) --- pkg/cloudcommon/db/db_dispatcher.go | 6 ++++++ pkg/cloudcommon/db/standalone_anon.go | 11 ----------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/pkg/cloudcommon/db/db_dispatcher.go b/pkg/cloudcommon/db/db_dispatcher.go index 8d02d41e8c..facbea1790 100644 --- a/pkg/cloudcommon/db/db_dispatcher.go +++ b/pkg/cloudcommon/db/db_dispatcher.go @@ -1726,6 +1726,12 @@ func DeleteModel(ctx context.Context, userCred mcclient.TokenCredential, item IM if userCred != nil { OpsLog.LogEvent(item, ACT_DELETE, item.GetShortDesc(ctx), userCred) } + if _, ok := item.(IStandaloneModel); ok && len(item.GetId()) > 0 { + err := Metadata.RemoveAll(ctx, item, userCred) + if err != nil { + return errors.Wrapf(err, "Metadata.RemoveAll") + } + } return nil } diff --git a/pkg/cloudcommon/db/standalone_anon.go b/pkg/cloudcommon/db/standalone_anon.go index 2ad531d281..df056208ef 100644 --- a/pkg/cloudcommon/db/standalone_anon.go +++ b/pkg/cloudcommon/db/standalone_anon.go @@ -585,17 +585,6 @@ func (model *SStandaloneAnonResourceBase) applyPolicyTags(ctx context.Context, u } } -func (model *SStandaloneAnonResourceBase) PostDelete(ctx context.Context, userCred mcclient.TokenCredential) { - if model.Deleted { - model.RemoveAllMetadata(ctx, userCred) - } - model.SResourceBase.PostDelete(ctx, userCred) -} - -// func (model *SStandaloneAnonResourceBase) Delete(ctx context.Context, userCred mcclient.TokenCredential) error { -// return DeleteModel(ctx, userCred, model) -// } - func (model *SStandaloneAnonResourceBase) ClearSchedDescCache() error { return nil }