-
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): Implement stream controller #211
feat(controller-runtime): Implement stream controller #211
Conversation
Controllers and tests are based on files generated by operator-sdk. Adds a minimal test suite for the controllers with a etcd test env and a test nats jetStream server to test against.
See TODOs on what still needs to be implemented.
Use a single use client on every connection. This should be replaced by a client pool in the future.
Setting CAs: []string{*ca} resulted in []string{""} when no CA was set, leading to an error when creating clients.
- Trigger only on generation changes - Split initialization and create into separate calls to Reconcile
Instead check for preventUpdate. Introduced during refactor.
Prefix with stream to prevent conflict with other resources.
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.
Some very minor comments, but overall looks really good!
We can go ahead and merge this into the feature branch, I'm going to run some tests on my clusters with the new controllers.
- Add note on opts.Account - Add comment on possible feature to expose TLSFirst in the spec.
|
||
// Takes opts values if present | ||
cfg := &NatsConfig{ | ||
CRDConnect: false, |
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 just noticed that CRDConnect
is always false for the clients.
Do you think we need something like this for setting the value according to base config and opts?
Set CRDConnect
to the base config value, but set it to false if spec config should overwrite it:
cfg.CRDConnect = c.config.CRDConnect
if opts.Creds != "" ||
opts.Nkey != "" ||
len(opts.TLS.RootCAs) > 0 ||
opts.TLS.ClientCert != "" ||
opts.TLS.ClientKey != "" {
cfg.CRDConnect = false
}
Reword log messages.
0f218f5
into
nats-io:feature/controller-runtime
* Add account, consumer and stream controller stubs to be implemented Controllers and tests are based on files generated by operator-sdk. Adds a minimal test suite for the controllers with a etcd test env and a test nats jetStream server to test against. * Add logs to Reconcile functions * Add jsClient to test suit variables * Remove format from log string * Make upsertCondition public to be used in new controllers * Implement basic cases for stream reconciliation See TODOs on what still needs to be implemented. * refactor to use shared base controller * Support jetstream connection options in stream spec * implement stream deletion * update observedGeneration of status * check Spec.PreventDelete before stream deletion * remove base js client Use a single use client on every connection. This should be replaced by a client pool in the future. * move asJsonString to jetstream_controller * check namespace read only and prevent update mode * Update comments and log * Fix test docs and check precondition * Add preventUpdate test cases * Add tests for read-only or namespace restricted mode * fix empty ca when no ca set Setting CAs: []string{*ca} resulted in []string{""} when no CA was set, leading to an error when creating clients. * simplify error message * fix error loop when the underlying stream was deleted * refactor each phase into separate method * Fix errors during parallel reconciliation & Refactor tests - Trigger only on generation changes - Split initialization and create into separate calls to Reconcile * make test description strings more uniform * Update docs and log messages * extract configuration to buildNatsConfig method * fix checking for preventDelete in the update step Instead check for preventUpdate. Introduced during refactor. * fix k8s binaries not downloaded for tests * add /bin to gitignore * rename stream helper functions Prefix with stream to prevent conflict with other resources. * update naming as suggested * fix assumed reason in log message * Update todo comments marked with review - Add note on opts.Account - Add comment on possible feature to expose TLSFirst in the spec. * separate CA config from client cert and key * set streamName and consumerName fields once on logger Reword log messages.
Implements reconciliation of stream resources in the stream controller
Adds a base JetstreamController for nats/jetstream functionality shared between controllers, like initializing a jetStream client for the current call.
Adds test suit using envtest and embedded nats servers.
Fixes tests failing due to missing k8s binaries.