Merge pull request #13406 from ioito/hotfix/qx-waf-rule-sync

fix(region): skip first sync waf rule
This commit is contained in:
Zexi Li
2022-02-10 18:26:37 +08:00
committed by GitHub
2 changed files with 8 additions and 3 deletions
+7 -2
View File
@@ -207,7 +207,7 @@ func (self *SSkuResourcesMeta) newFromCloudWafGroup(ctx context.Context, userCre
return nil
}
func (self *SSkuResourcesMeta) SyncWafGroups(ctx context.Context, userCred mcclient.TokenCredential, cloudEnv string) compare.SyncResult {
func (self *SSkuResourcesMeta) SyncWafGroups(ctx context.Context, userCred mcclient.TokenCredential, cloudEnv string, isStart bool) compare.SyncResult {
lockman.LockRawObject(ctx, cloudEnv, "waf-rule-group")
defer lockman.ReleaseRawObject(ctx, cloudEnv, "waf-rule-group")
@@ -223,6 +223,11 @@ func (self *SSkuResourcesMeta) SyncWafGroups(ctx context.Context, userCred mccli
return result
}
if isStart && len(dbGroup) > 0 {
log.Infof("%s waf group already synced, skip...", cloudEnv)
return result
}
removed := make([]SWafRuleGroup, 0)
commondb := make([]SWafRuleGroup, 0)
commonext := make([]sWafGroup, 0)
@@ -293,7 +298,7 @@ func SyncWafGroups(ctx context.Context, userCred mcclient.TokenCredential, isSta
log.Infof("%s Waf group not Changed skip syncing", cloudEnv)
continue
}
result := meta.SyncWafGroups(ctx, userCred, cloudEnv)
result := meta.SyncWafGroups(ctx, userCred, cloudEnv, isStart)
log.Infof("sync %s waf group result: %s", cloudEnv, result.Result())
wafIndex[cloudEnv] = newMd5
}
+1 -1
View File
@@ -60,7 +60,7 @@ type SWafRule struct {
// 规则优先级
Priority int `nullable:"false" list:"domain" create:"required"`
// 规则默认行为
Action *cloudprovider.DefaultAction `charset:"utf8" nullable:"false" list:"user" update:"domain" create:"required"`
Action *cloudprovider.DefaultAction `charset:"utf8" nullable:"true" list:"user" update:"domain" create:"required"`
// 条件
StatementConditon cloudprovider.TWafStatementCondition `width:"20" charset:"ascii" nullable:"false" list:"domain" create:"optional"`
// 规则组的id