-
Notifications
You must be signed in to change notification settings - Fork 42
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
MM-57214: Integrate Redis into Terraform deployment #708
Conversation
Just for review. The code is actually pointing to a branch in the server repo, which needs to be updated once it's merged. |
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 looks great! A couple of comments:
- Do we want to support multiple Redis nodes at some point? I see everything hardcoded to one node. 0/5 on this at this point, just curious.
- I understand this is still a WIP, but writing it here so that we don't foget: we need to document the newly added settings.
deployment/terraform/metrics.go
Outdated
redisExporterService := fmt.Sprintf(redisExporterServiceFile, redisEndpoint) | ||
rdr := strings.NewReader(redisExporterService) | ||
if out, err := sshc.Upload(rdr, "/lib/systemd/system/redis-exporter.service", true); err != nil { | ||
return fmt.Errorf("error upload redis exporter service file: output: %s, error: %w", out, 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.
return fmt.Errorf("error upload redis exporter service file: output: %s, error: %w", out, err) | |
return fmt.Errorf("error uploading redis exporter service file: output: %s, error: %w", out, err) |
deployment/terraform/output.go
Outdated
@@ -189,6 +209,11 @@ func (o *Output) HasElasticSearch() bool { | |||
return o.ElasticSearchServer.Endpoint != "" | |||
} | |||
|
|||
// HasRedis returns whether a deployment has ElasticSaearch installed in it or not. |
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.
// HasRedis returns whether a deployment has ElasticSaearch installed in it or not. | |
// HasRedis returns whether a deployment has Redis installed in it or not. |
@@ -85,6 +85,7 @@ resource "aws_instance" "app_server" { | |||
"sudo apt-get install -y mysql-client-8.0", | |||
"sudo apt-get install -y postgresql-client-11", | |||
"sudo apt-get install -y prometheus-node-exporter", | |||
"sudo NEEDRESTART_MODE=a apt-get install -y redis-tools", |
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.
What does NEEDRESTART_MODE=a
mean?
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.
Haha this was a fun one. So if you try to install it manually, a screen comes up and it asks you what services you want to restart post installation. This NEEDRESTART_MODE=a
is the way to automatically say ok to that prompt. -y
does not take care of this case.
@@ -157,6 +159,31 @@ func (t *Terraform) setupMetrics(extAgent *ssh.ExtAgent) error { | |||
} | |||
} | |||
|
|||
if t.output.HasRedis() { | |||
redisEndpoint := fmt.Sprintf("redis://%s", net.JoinHostPort(t.output.RedisServer.Address, strconv.Itoa(t.output.RedisServer.Port))) | |||
redisTargets = append(redisTargets, "metrics:9121") |
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.
Nit:
This is the port of the redis exporter, right? I know the rest of definitions here are similar to this one, but they seem a bit cryptic if one doesn't know what they're defining, so maybe we can start slightly improving things with something like:
redisTargets = append(redisTargets, "metrics:9121") | |
redisExporterPort := "9121" | |
redisTargets = append(redisTargets, "metrics:"+redisExporterPort) |
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.
Isn't the same in the elasticsearch exporter as well?
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.
Most probably, yes, but I noticed it here because it wasn't me the one writing the code 😂 I'm 1/5 here, though,just a nit :)
Nope we don't. Because we don't want to get into handling consistency issues for Redis writer-reader again. One Redis instance is good for now. |
Please add me back when ready for final review. |
@agnivade Now that the main PR is to be merged, should we finalize this? |
Yep, this is next in my queue once the PR gets merged. |
Neat, thanks! |
@agarciamontoro, @streamer45 - Ready for review now. I tested and verified that everything works fine. |
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!
@@ -84,6 +84,7 @@ resource "aws_instance" "app_server" { | |||
"sudo apt-get install -y mysql-client-8.0", | |||
"sudo apt-get install -y postgresql-client-14", | |||
"sudo apt-get install -y prometheus-node-exporter", | |||
# "sudo NEEDRESTART_MODE=a apt-get install -y redis-tools", |
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.
What's the deal with this one?
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 needed to install the redis-cli
. But the thing is there is an UI intervention while installing, which is supposedly fixed with NEEDRESTART_MODE=a
. But that still somehow didn't fix things. So just ignoring for now. If someone needs to connect to Redis, they can install manually.
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.
FWIW, the command worked fine on my end (EC2 running Ubuntu 22.04
).
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.
Hmm .. weird. I will test it again later.
cfg.CacheSettings.CacheType = model.NewString(model.CacheTypeRedis) | ||
redisEndpoint := net.JoinHostPort(t.output.RedisServer.Address, strconv.Itoa(t.output.RedisServer.Port)) | ||
cfg.CacheSettings.RedisAddress = model.NewString(redisEndpoint) | ||
cfg.CacheSettings.RedisDB = model.NewInt(0) |
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.
How about model.NewPointer
? :p We probably need a ticket to review the whole thing, eventually.
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.
Coming soon. I already have it for the drafts PR.
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.
Whoops, missed this one, sorry! All looks good, thank you!
The only thing is the "sudo NEEDRESTART_MODE=a apt-get install -y redis-tools"
line. What are we doing with this one? I'm ok simply removing it and adding it as an improvement later.
@@ -157,6 +159,31 @@ func (t *Terraform) setupMetrics(extAgent *ssh.ExtAgent) error { | |||
} | |||
} | |||
|
|||
if t.output.HasRedis() { | |||
redisEndpoint := fmt.Sprintf("redis://%s", net.JoinHostPort(t.output.RedisServer.Address, strconv.Itoa(t.output.RedisServer.Port))) | |||
redisTargets = append(redisTargets, "metrics:9121") |
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.
Most probably, yes, but I noticed it here because it wasn't me the one writing the code 😂 I'm 1/5 here, though,just a nit :)
Removed it. |
https://mattermost.atlassian.net/browse/MM-57214