Skip to content
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

Nats kv config #156

Merged
merged 3 commits into from
Sep 25, 2023
Merged

Nats kv config #156

merged 3 commits into from
Sep 25, 2023

Conversation

joelrebel
Copy link
Member

  • Fixes a bug - create consumer when it doesn't exist, instead of returning an error
  • Declare NATS kv config parameter

@joelrebel joelrebel requested review from a team as code owners September 5, 2023 10:04
@codecov
Copy link

codecov bot commented Sep 5, 2023

Codecov Report

Patch coverage has no change and project coverage change: -0.07% ⚠️

Comparison is base (6e778f6) 66.99% compared to head (58da1c8) 66.92%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #156      +/-   ##
==========================================
- Coverage   66.99%   66.92%   -0.07%     
==========================================
  Files          17       17              
  Lines        1027     1028       +1     
==========================================
  Hits          688      688              
- Misses        286      287       +1     
  Partials       53       53              
Flag Coverage Δ
unittests 66.92% <0.00%> (-0.07%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
events/nats.go 39.35% <0.00%> (-0.16%) ⬇️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@DoctorVin DoctorVin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what the goal is here. Let’s discuss?

events/nats.go Show resolved Hide resolved
@@ -66,6 +66,14 @@ type NatsOptions struct {

// Setting Stream parameters will cause a NATS stream to be added.
Stream *NatsStreamOptions `mapstructure:"stream"`

// Nats KV parameters
KV *NatsKVOptions `mapstructure:"kv"`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why add this here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mainly for consistency in loading the NATS config from the env/config file
https://github.com/metal-toolbox/sandbox/pull/26/files#diff-4d55b7b2bd04c8f271ca9fb638669a82d8d00aba55ccc6bde46aafd0c72e9236R32

Also I'd like to remove the --replica-count cli flag since its an internal thing and I don't want all controllers to have to specify this through the cli - https://github.com/metal-toolbox/flasher/blob/aa6c0eb71ddafea5878008d0ad8c193c75580464/cmd/run.go#L119

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only reason we'd change replica count is to support running in the sandbox or in other integration tests. I don't think this should be configurable.

@joelrebel joelrebel requested a review from DoctorVin September 13, 2023 18:08
@@ -66,6 +66,14 @@ type NatsOptions struct {

// Setting Stream parameters will cause a NATS stream to be added.
Stream *NatsStreamOptions `mapstructure:"stream"`

// Nats KV parameters
KV *NatsKVOptions `mapstructure:"kv"`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only reason we'd change replica count is to support running in the sandbox or in other integration tests. I don't think this should be configurable.

@joelrebel
Copy link
Member Author

Ack, how do you suggest we proceed here.

I would prefer if it wasn't a CLI parameter since a user of flasher/other controller should not have to care about this detail, and if we want to keep all the NATs options in one place, it made sense to be here - so its managed in one place.

@DoctorVin
Copy link
Collaborator

Ack, how do you suggest we proceed here.

I would prefer if it wasn't a CLI parameter since a user of flasher/other controller should not have to care about this detail, and if we want to keep all the NATs options in one place, it made sense to be here - so its managed in one place.

This feels like we’re supporting a mostly-unnecessary code path. Replica count isn’t a property of Alloy (or flasher or condition-orchestrator), it’s a property of the KVs they connect to, and the workers need to know about it in the case that they need to create the nats infrastructure on a fresh install. If we remove that responsibility from the workers, we can instead have the workers fail if they can’t reach a NATS consumer or KV that is required. Then we put all NATS setup in code that runs prior to the workers being deployed. Thus we’re covered for a “new site turn-up” scenario where NATS is only freshly available, and we remove complexity and extraneous detail from the controllers.

@joelrebel
Copy link
Member Author

Ack, to make sure I understand this correctly - we ditch all the NATS JS/KV/Consumer init configuration parameters and code from all the controllers for a single controller that is responsible for the NATS init, and has all the parameters in code and not in a configuration file?

I'm curious if this is going to work out well if we want to roll out changes to these parameters quickly, given how involved a code change + deployment to k8s is..

To be clear - Im on board with idea of a controller/cronjob ensuring the configuration parameters in question, Im not totally convinced having all the JS/KV/Consumer parameters in code will allow us to be flexible. I'm fine with taking that approach and seeing where it leads us though.

@joelrebel joelrebel requested a review from DoctorVin September 20, 2023 13:12
@joelrebel
Copy link
Member Author

reverted kv config param commit based on slack discussion

@joelrebel joelrebel merged commit cd7478a into main Sep 25, 2023
2 of 4 checks passed
@joelrebel joelrebel deleted the nats-kv-config branch September 25, 2023 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants