-
Notifications
You must be signed in to change notification settings - Fork 63
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
feat(controller-runtime): Add consumer controller #212
feat(controller-runtime): Add consumer controller #212
Conversation
Checks for the PreventUpdate or readonly mode during creation/update. Skips reconciliation when resource is in namespace not matching restriction.
Set streamName and consumerName fields once. Reword log messages.
Hey. |
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.
Apologies for the holiday delay
Looks very solid, consistent with the stream controller. Comments are pretty much just nits. Thanks!
"k8s.io/apimachinery/pkg/api/errors" | ||
k8serrors "k8s.io/apimachinery/pkg/api/errors" |
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.
Duplicate import
c, err := jsClient.Consumer(ctx, streamName, consumerName) | ||
Expect(c.CachedInfo().Config.Description).To(BeEmpty()) |
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.
c, err := jsClient.Consumer(ctx, streamName, consumerName) | |
Expect(c.CachedInfo().Config.Description).To(BeEmpty()) | |
c, err := jsClient.Consumer(ctx, streamName, consumerName) | |
Expect(err).NotTo(HaveOccurred()) | |
Expect(c.CachedInfo().Config.Description).To(BeEmpty()) |
s, err := jsClient.Consumer(ctx, streamName, consumerName) | ||
Expect(s.CachedInfo().Config.Description).To(BeEmpty()) |
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.
s, err := jsClient.Consumer(ctx, streamName, consumerName) | |
Expect(s.CachedInfo().Config.Description).To(BeEmpty()) | |
s, err := jsClient.Consumer(ctx, streamName, consumerName) | |
Expect(err).NotTo(HaveOccurred()) | |
Expect(s.CachedInfo().Config.Description).To(BeEmpty()) |
func (r *ConsumerReconciler) createOrUpdate(ctx context.Context, log klog.Logger, consumer *api.Consumer) error { | ||
|
||
// Create or Update the stream based on the spec | ||
if consumer.Spec.PreventUpdate || r.ReadOnly() { |
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 believe that we still want to permit a create if PreventUpdate
is true, and only block update operations. It looks like I missed this in the stream controller as well
// Create or Update the stream based on the spec | ||
if consumer.Spec.PreventUpdate || r.ReadOnly() { | ||
log.Info("Skipping consumer creation or update.", | ||
"preventDelete", consumer.Spec.PreventDelete, |
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.
Was this intended to log the preventUpdate
setting in the spec rather than preventDelete
?
Expect(result.IsZero()).To(BeTrue()) | ||
|
||
By("checking that consumer was not updated") | ||
s, err := jsClient.Consumer(ctx, streamName, consumerName) |
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.
s, err := jsClient.Consumer(ctx, streamName, consumerName) | |
s, err := jsClient.Consumer(ctx, streamName, consumerName) | |
Expect(err).NotTo(HaveOccurred()) |
Expect(k8sClient.Update(ctx, consumer)).To(Succeed()) | ||
|
||
By("checking precondition, that the consumer does not yet exist") | ||
got, err := jsClient.Consumer(ctx, streamName, consumerName) |
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.
got, err := jsClient.Consumer(ctx, streamName, consumerName) | |
_, err = jsClient.Consumer(ctx, streamName, consumerName) |
I have a branch based on this branch about ready for merge, so I just went ahead and addressed the few comments there. I will merge this and open a PR with those changes shortly |
88f61b2
into
nats-io:feature/controller-runtime
Adds reconciliation of consumer resources in the consumer controller
Implementation is analogous to the stream controller.