Skip to content

Commit

Permalink
Add if check back to avoid hitting edge case
Browse files Browse the repository at this point in the history
  • Loading branch information
panyuenlau committed May 11, 2023
1 parent beb55e9 commit 5ce255f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions controllers/kafkauser_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,13 @@ func (r *KafkaUserReconciler) Reconcile(ctx context.Context, request reconcile.R
var kafkaUser string

if instance.Spec.GetIfCertShouldBeCreated() {
// Avoid panic if the user wants to create a kafka user but the cluster is in plaintext mode
if cluster.Spec.ListenersConfig.SSLSecrets == nil && instance.Spec.PKIBackendSpec == nil {
// we should never see this scenario due to the KafkaUser validation webhook
// the only edge case is when cluster.Spec.ListenersConfig.SSLSecrets is set to nil during operator upgrade
return requeueWithError(reqLogger, "could not create kafka user since user specific PKI not configured", errors.New("failed to create kafka user"))
}

var backend v1beta1.PKIBackend
if instance.Spec.PKIBackendSpec != nil {
backend = v1beta1.PKIBackend(instance.Spec.PKIBackendSpec.PKIBackend)
Expand Down

0 comments on commit 5ce255f

Please sign in to comment.