diff --git a/pkg/compute/models/guests.go b/pkg/compute/models/guests.go index 6f0319f49a..b989b28ead 100644 --- a/pkg/compute/models/guests.go +++ b/pkg/compute/models/guests.go @@ -5904,7 +5904,7 @@ func (self *SGuest) getSecgroupsBySecgroupExternalIds(externalIds []string) ([]S func (self *SGuest) SyncVMSecgroups(ctx context.Context, userCred mcclient.TokenCredential, externalIds []string) error { // clear secgroup if vm not support security group - if self.GetDriver().GetMaxSecurityGroupCount() == 0 { + if self.GetDriver().GetMaxSecurityGroupCount() == 0 || len(externalIds) == 0 { _, err := db.Update(self, func() error { self.SecgrpId = "" self.AdminSecgrpId = ""