mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-06-18 08:32:55 +08:00
lblistener: allow setting http/https listener backendgroup to empty
This commit is contained in:
@@ -355,7 +355,7 @@ func (lblis *SLoadbalancerListener) StartLoadBalancerListenerSyncstatusTask(ctx
|
||||
func (lblis *SLoadbalancerListener) ValidateUpdateData(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data *jsonutils.JSONDict) (*jsonutils.JSONDict, error) {
|
||||
ownerId := lblis.GetOwnerId()
|
||||
backendGroupV := validators.NewModelIdOrNameValidator("backend_group", "loadbalancerbackendgroup", ownerId)
|
||||
backendGroupV.Optional(true)
|
||||
backendGroupV.AllowEmpty(true).Optional(true)
|
||||
if err := backendGroupV.Validate(data); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -577,7 +577,12 @@ func (self *SKVMRegionDriver) ValidateUpdateLoadbalancerListenerData(ctx context
|
||||
}
|
||||
|
||||
{
|
||||
if lbbg, ok := backendGroup.(*models.SLoadbalancerBackendGroup); ok && lbbg.LoadbalancerId != lblis.LoadbalancerId {
|
||||
if backendGroup == nil {
|
||||
if lblis.ListenerType != api.LB_LISTENER_TYPE_HTTP &&
|
||||
lblis.ListenerType != api.LB_LISTENER_TYPE_HTTPS {
|
||||
return nil, httperrors.NewInputParameterError("non http listener must have backend group set")
|
||||
}
|
||||
} else if lbbg, ok := backendGroup.(*models.SLoadbalancerBackendGroup); ok && lbbg.LoadbalancerId != lblis.LoadbalancerId {
|
||||
return nil, httperrors.NewInputParameterError("backend group %s(%s) belongs to loadbalancer %s instead of %s",
|
||||
lbbg.Name, lbbg.Id, lbbg.LoadbalancerId, lblis.LoadbalancerId)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user