Skip to content

Commit 6b88e29

Browse files
AlinsRanCopilot
andcommitted
refactor: add explicit log when skipping ADC due to initErr in ApisixConsumer webhook
Separate the initErr and warnings checks for better observability: log the init error explicitly when skipping ADC validation due to a failed ADC client initialization. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent f5363b0 commit 6b88e29

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

internal/webhook/v1/apisixconsumer_webhook.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,11 @@ func (v *ApisixConsumerCustomValidator) ValidateCreate(ctx context.Context, obj
7575
}
7676

7777
warnings := v.collectWarnings(ctx, consumer)
78-
if v.initErr != nil || len(warnings) > 0 {
78+
if v.initErr != nil {
79+
apisixConsumerLog.Error(v.initErr, "ADC validator init failed, skipping ADC validation")
80+
return warnings, nil
81+
}
82+
if len(warnings) > 0 {
7983
return warnings, nil
8084
}
8185
return warnings, v.adcValidator.Validate(ctx, consumer)
@@ -92,7 +96,11 @@ func (v *ApisixConsumerCustomValidator) ValidateUpdate(ctx context.Context, oldO
9296
}
9397

9498
warnings := v.collectWarnings(ctx, consumer)
95-
if v.initErr != nil || len(warnings) > 0 {
99+
if v.initErr != nil {
100+
apisixConsumerLog.Error(v.initErr, "ADC validator init failed, skipping ADC validation")
101+
return warnings, nil
102+
}
103+
if len(warnings) > 0 {
96104
return warnings, nil
97105
}
98106
return warnings, v.adcValidator.Validate(ctx, consumer)

0 commit comments

Comments
 (0)