Skip to content

Commit 0db12c2

Browse files
Foo BarCopilot
andcommitted
fix: restore warn behavior for ApisixTls with missing secrets
When ApisixTls references secrets that do not exist yet, the webhook should warn (not deny). The ADC validator calls PrepareApisixTlsForValidation which in turn calls validateSecret, which returns NotFound and causes admission denial - breaking the original warn-on-missing-secret behavior. Fix: skip ADC validation when collectWarnings already detected missing secrets. The translator cannot load cert/key material in that case, so ADC validation would always fail anyway. The existing warnings are sufficient to inform the user. Also fix initErr fail-open: a validator initialization failure should allow admission (return warnings, nil) rather than hard-deny every write. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 5f3e401 commit 0db12c2

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

internal/webhook/v1/apisixtls_webhook.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,11 @@ func (v *ApisixTlsCustomValidator) ValidateCreate(ctx context.Context, obj runti
8080
}
8181

8282
warnings := v.collectWarnings(ctx, tls)
83-
if v.initErr != nil {
84-
return warnings, v.initErr
83+
// Skip ADC validation when secrets are missing: the translator cannot
84+
// load cert/key material, so validation would always fail. The missing-
85+
// secret warnings are sufficient to inform the user.
86+
if v.initErr != nil || len(warnings) > 0 {
87+
return warnings, nil
8588
}
8689

8790
return warnings, v.adcValidator.Validate(ctx, tls)
@@ -104,8 +107,8 @@ func (v *ApisixTlsCustomValidator) ValidateUpdate(ctx context.Context, oldObj, n
104107
}
105108

106109
warnings := v.collectWarnings(ctx, tls)
107-
if v.initErr != nil {
108-
return warnings, v.initErr
110+
if v.initErr != nil || len(warnings) > 0 {
111+
return warnings, nil
109112
}
110113

111114
return warnings, v.adcValidator.Validate(ctx, tls)

0 commit comments

Comments
 (0)