-
Notifications
You must be signed in to change notification settings - Fork 199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Koperator can handle intermediate and leaf certificates in generated kafkaUser's TLS certificate #843
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, this was a surprisingly straightforward fix.
controllers/kafkauser_controller.go
Outdated
@@ -238,7 +238,13 @@ func (r *KafkaUserReconciler) Reconcile(ctx context.Context, request reconcile.R | |||
return requeueWithError(reqLogger, "failed to reconcile user secret", err) | |||
} | |||
} | |||
kafkaUser = user.DN() | |||
kafkaUser, err = user.DN() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: we need to rename that function for public interface clarity purposes....
return cert.Subject.String() | ||
cert, err := certutil.DecodeCertificate(u.Certificate) | ||
if err != nil { | ||
return "", err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: wouldn't it be better to wrap the error with some content information (we are doing this in KafkaUser DistinguishedName retrieval), IMO it would help with debug clarification.
(These cases I always have the os.Open()
errors in mind where the non-existing path object error is no such file or directory
, but the path itself is not included - although that would be a detail, not a wrapping, but I mean the contextual information in general).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if any useful information is available here that could be added to the error context. The caller can add more details to the error like the KafkaUser
custom resources name (https://github.com/banzaicloud/koperator/pull/843/files#diff-2b2cc6c6efb0a3a4b49078c08a64ff936f6d02a73543d0c8f98a7b9b0c4f2a2eR243)
Maybe a more descriptive error message could help here errors.WrapIfWithDetails(err, "couldn't decode KafkaUser certificate", "cert", string(u.Certificate))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I meant an error message to narrow the context from generic certificate error to KafkaUser DistringuishedName determination certificate error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error log message already contains the kafkauser name, namespace.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reconciler dumps the stacktrace.
What's in this PR?
It fixes bug in the kafkaUser reconcile when trying to get Distinguish Name from the generated TLS certificate.
Why?
When the generated TLS certificate contains intermediate certificates, not only the leaf certificate, the Koperator gets panic because of nil pointer dereference.
Checklist