mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-21 14:19:49 +08:00
fix: update lb cluster with patch params (#18695)
Co-authored-by: Qiu Jian <qiujian@yunionyun.com>
This commit is contained in:
@@ -685,24 +685,21 @@ type sPolicyTags struct {
|
||||
func (model *SStandaloneAnonResourceBase) PostUpdate(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) {
|
||||
model.SResourceBase.PostUpdate(ctx, userCred, query, data)
|
||||
|
||||
meta := make(map[string]string)
|
||||
err := data.Unmarshal(&meta, "__meta__")
|
||||
if err == nil {
|
||||
model.PerformMetadata(ctx, userCred, nil, meta)
|
||||
}
|
||||
|
||||
model.applyPolicyTags(ctx, userCred, data)
|
||||
model.TrySaveMetadataInput(ctx, userCred, data)
|
||||
}
|
||||
|
||||
func (model *SStandaloneAnonResourceBase) PostCreate(ctx context.Context, userCred mcclient.TokenCredential, ownerId mcclient.IIdentityProvider, query jsonutils.JSONObject, data jsonutils.JSONObject) {
|
||||
model.SResourceBase.PostCreate(ctx, userCred, ownerId, query, data)
|
||||
|
||||
model.TrySaveMetadataInput(ctx, userCred, data)
|
||||
}
|
||||
|
||||
func (model *SStandaloneAnonResourceBase) TrySaveMetadataInput(ctx context.Context, userCred mcclient.TokenCredential, data jsonutils.JSONObject) {
|
||||
meta := make(map[string]string)
|
||||
err := data.Unmarshal(&meta, "__meta__")
|
||||
if err == nil {
|
||||
model.PerformMetadata(ctx, userCred, nil, meta)
|
||||
}
|
||||
|
||||
model.applyPolicyTags(ctx, userCred, data)
|
||||
}
|
||||
|
||||
|
||||
@@ -578,8 +578,25 @@ func (cluster *SLoadbalancerCluster) PerformParamsPatch(ctx context.Context, use
|
||||
}
|
||||
}
|
||||
{
|
||||
// save name, description, params
|
||||
input := apis.StandaloneResourceBaseUpdateInput{}
|
||||
err := data.Unmarshal(&input)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "Unmarshal update input")
|
||||
}
|
||||
input, err = cluster.SStandaloneResourceBase.ValidateUpdateData(ctx, userCred, query, input)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "SStandaloneResourceBase.ValidateUpdateData")
|
||||
}
|
||||
|
||||
diff, err := db.Update(cluster, func() error {
|
||||
cluster.Params = ¶ms
|
||||
if len(input.Name) > 0 {
|
||||
cluster.Name = input.Name
|
||||
}
|
||||
if len(input.Description) > 0 {
|
||||
cluster.Description = input.Description
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
@@ -587,6 +604,10 @@ func (cluster *SLoadbalancerCluster) PerformParamsPatch(ctx context.Context, use
|
||||
}
|
||||
db.OpsLog.LogEvent(cluster, db.ACT_UPDATE, diff, userCred)
|
||||
}
|
||||
{
|
||||
// save metadata
|
||||
cluster.TrySaveMetadataInput(ctx, userCred, data)
|
||||
}
|
||||
{
|
||||
// populate changes to underlying lbagents
|
||||
lbagents, err := LoadbalancerAgentManager.getByClusterId(cluster.Id)
|
||||
|
||||
Reference in New Issue
Block a user