Skip to content

Commit

Permalink
fix consumers cases
Browse files Browse the repository at this point in the history
  • Loading branch information
czeslavo committed Nov 2, 2023
1 parent bba05b5 commit 0781c3b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ Nothing yet.
- Error logs emitted from Gateway Discovery readiness checker that should be
logged at `debug` level are now logged at that level.
[#5029](https://github.com/Kong/kubernetes-ingress-controller/pull/5029)
- Fixed `HTTPRoute` and `KongConsumer` admission webhook validators to properly
signal validation failures, resulting in returning responses with `AdmissionResponse`
filled instead of 500 status codes. It will make them work as expected in cases where the
`ValidatingWebhookConfiguration` is configured with `failurePolicy: Ignore`.

### Changed

Expand Down
4 changes: 2 additions & 2 deletions internal/admission/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,15 @@ func (validator KongHTTPValidator) ValidateConsumer(
// testing them against themselves.
credentialsIndex, err := globalValidationIndexForCredentials(ctx, validator.ManagerClient, managedConsumers, ignoredSecrets)
if err != nil {
return false, ErrTextConsumerCredentialValidationFailed, err
return false, fmt.Sprintf("%s: %s", ErrTextConsumerCredentialValidationFailed, err), nil
}

// validate the consumer's credentials against the index of all managed
// credentials to ensure they're not in violation of any unique constraints.
for _, secret := range credentials {
// do the unique constraints validation of the credentials using the credentials index
if err := credentialsIndex.ValidateCredentialsForUniqueKeyConstraints(secret); err != nil {
return false, ErrTextConsumerCredentialValidationFailed, err
return false, fmt.Sprintf("%s: %s", ErrTextConsumerCredentialValidationFailed, err), nil
}
}

Expand Down

0 comments on commit 0781c3b

Please sign in to comment.