Skip to content

Commit 532a022

Browse files
committed
fix validation for port pool
Signed-off-by: roc <[email protected]>
1 parent 5c4586c commit 532a022

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

internal/webhook/v1alpha1/clbportpool_webhook.go

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -107,19 +107,18 @@ func (v *CLBPortPoolCustomValidator) ValidateUpdate(ctx context.Context, oldObj,
107107
}
108108

109109
func (v *CLBPortPoolCustomValidator) validate(pool *networkingv1alpha1.CLBPortPool) error {
110-
// 确保要有CLB,自动创建或使用已有 CLB,至少有一个指定
111-
if len(pool.Spec.ExsistedLoadBalancerIDs) > 0 {
112-
return nil
113-
}
114110
var allErrs field.ErrorList
115-
if pool.Spec.AutoCreate == nil || !pool.Spec.AutoCreate.Enabled {
116-
allErrs = append(
117-
allErrs,
118-
field.Invalid(
119-
field.NewPath("spec").Child("autoCreate").Child("enabled"), nil,
120-
"autoCreate should be enabled if there is no exsistedLoadBalancerIDs",
121-
),
122-
)
111+
// 确保要有CLB,自动创建或使用已有 CLB,至少有一个指定
112+
if len(pool.Spec.ExsistedLoadBalancerIDs) == 0 {
113+
if pool.Spec.AutoCreate == nil || !pool.Spec.AutoCreate.Enabled {
114+
allErrs = append(
115+
allErrs,
116+
field.Invalid(
117+
field.NewPath("spec").Child("autoCreate").Child("enabled"), nil,
118+
"autoCreate should be enabled if there is no exsistedLoadBalancerIDs",
119+
),
120+
)
121+
}
123122
}
124123

125124
// startPort 必须大于 0
@@ -162,7 +161,7 @@ func (v *CLBPortPoolCustomValidator) validate(pool *networkingv1alpha1.CLBPortPo
162161
allErrs = append(
163162
allErrs,
164163
field.Invalid(
165-
field.NewPath("spec").Child("listenerQuota"), *pool.Spec.EndPort,
164+
field.NewPath("spec").Child("listenerQuota"), *pool.Spec.ListenerQuota,
166165
"autoCreate should not be enabled if listenerQuota is specified",
167166
),
168167
)

0 commit comments

Comments
 (0)