-
Notifications
You must be signed in to change notification settings - Fork 743
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: jetstream eventbus controller implementation #1705
Conversation
Signed-off-by: Derek Wang <[email protected]>
Signed-off-by: Derek Wang <[email protected]>
@@ -0,0 +1,21 @@ | |||
package common |
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.
We should refactor all those util functions under several common
across the project.
// See https://docs.nats.io/running-a-nats-service/configuration#jetstream. | ||
// Only configure "max_memory_store" or "max_file_store", do not set "store_dir" as it has been hardcoded. | ||
// +optional | ||
Settings *string `json:"settings,omitempty" protobuf:"bytes,15,opt,name=settings"` |
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.
This is nice and generic. I'll update my design document to reflect this.
if j.Replicas == nil { | ||
return 3 | ||
} | ||
if *j.Replicas < 3 { |
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, interesting. We don't let them have less than 3. Ideally maybe we'd warn them (log message or whatever) but not critical.
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.
Cluster setting has a different configuration from single node setting, it's not worth supporting that for us.
For a cluster setting, it needs at least 2 nodes to make it work. JetStream uses a RAFT algorithm for clustering, which does not make sense to use an even number. So a reasonable cluster node number is 3 or 5.
In order to ensure data consistency across complete restarts, a quorum of servers is required. A quorum is ½ cluster size + 1. This is the minimum number of nodes to ensure at least one node has the most recent data and state after a catastrophic failure. So for a cluster size of 3, you’ll need at least two JetStream enabled NATS servers available to store new messages. For a cluster size of 5, you’ll need at least 3 NATS servers, and so forth.
https://docs.nats.io/running-a-nats-service/configuration/clustering/jetstream_clustering#the-quorum
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.
Okay. Just wondering if we might want to log something so it's not a silent change. But I'm good with whatever - probably rare that somebody would set replicas to 1 or 2.
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.
Adding a log sounds good.
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.
It seems to be awkward to add a log in the model, skip it for now.
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.
Nice. Left a few comments but didn't really see any issues.
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.
Overall looks great! left few small comments/questions
controllers/config.go
Outdated
return &r, nil | ||
} | ||
} | ||
return nil, fmt.Errorf("no nats streaming configuration found for %q", version) |
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.
Maybe it would be better to let the user know which versions are currently supported so the user would have a better indication on how to fix this error, WDYT?
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.
Same goes for GetJetStreamVersion
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.
Good point!
return nil | ||
} | ||
|
||
func (r *jetStreamInstaller) buildStatefulSetSpec(jeVersion *controllers.JetStreamVersion) appv1.StatefulSetSpec { |
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.
can we have a default version here (like we have in the NATS installer) to make the Version field optional for the user?
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.
Having a default version will cause future upgrade issue - if version
is not specified, we use a default version, that will prevent us from updating the default version later, otherwise if the default one is changed, those installation with default versions will be automatically updated. This is a problem for current nats streaming implementation.
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 it, thanks for the clarification
- version: 2.7.3 | ||
natsImage: nats:2.7.3 | ||
metricsExporterImage: natsio/prometheus-nats-exporter:0.9.1 | ||
startCommand: /nats-server |
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.
shouldn't it be nats-server
(without the /
) ?
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.
This image is built from scratch
, the binary is put under /
, so we have to use /nats-server
.
Signed-off-by: Derek Wang <[email protected]>
Signed-off-by: Derek Wang <[email protected]>
} | ||
if x := eb.Spec.JetStream; x != nil { | ||
if x.Version == "" { | ||
return fmt.Errorf("invalid spec: a version for jetstream needs to be specified") |
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.
Can we add replicas
validation here?
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.
sounds good, done.
Signed-off-by: Derek Wang <[email protected]>
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.
LGTM
Signed-off-by: Derek Wang <[email protected]>
Signed-off-by: Derek Wang [email protected]
This PR is part of the effort of JetStream EventBus implementation.
A JetStream EventBus spec looks like below, where
version
is a required field in the spec.TLS enabling is not done in this PR, it should be implemented before we do an official release.
Current
Nats Streaming
image configuration is also moved into a configmap, together with JetStream image configs. This configmap is now only used byeventbus-controller
. As one of the follow-up tasks, all of the 3 controllers will be merged to one #1564.Checklist: