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

MM-57214: Integrate Redis into Terraform deployment #708

Merged
merged 8 commits into from
Aug 13, 2024
Merged

MM-57214: Integrate Redis into Terraform deployment #708

merged 8 commits into from
Aug 13, 2024

Conversation

agnivade
Copy link
Member

@agnivade agnivade added the 2: Dev Review Requires review by a core committer label Mar 14, 2024
@agnivade
Copy link
Member Author

Just for review. The code is actually pointing to a branch in the server repo, which needs to be updated once it's merged.

Copy link
Member

@agarciamontoro agarciamontoro left a 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.

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)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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)

@@ -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.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// 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",
Copy link
Member

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?

Copy link
Member Author

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")
Copy link
Member

@agarciamontoro agarciamontoro Mar 14, 2024

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:

Suggested change
redisTargets = append(redisTargets, "metrics:9121")
redisExporterPort := "9121"
redisTargets = append(redisTargets, "metrics:"+redisExporterPort)

Copy link
Member Author

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?

Copy link
Member

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 :)

@agnivade
Copy link
Member Author

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.

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.

@streamer45 streamer45 removed their request for review March 28, 2024 16:54
@streamer45
Copy link
Contributor

Please add me back when ready for final review.

@agarciamontoro
Copy link
Member

agarciamontoro commented Aug 5, 2024

@agnivade Now that the main PR is to be merged, should we finalize this?

@agnivade
Copy link
Member Author

agnivade commented Aug 5, 2024

Yep, this is next in my queue once the PR gets merged.

@agarciamontoro
Copy link
Member

Neat, thanks!

@agnivade agnivade changed the title WIP: MM-57214: Integrate Redis into Terraform deployment MM-57214: Integrate Redis into Terraform deployment Aug 6, 2024
@agnivade agnivade marked this pull request as ready for review August 6, 2024 04:52
@agnivade
Copy link
Member Author

agnivade commented Aug 6, 2024

@agarciamontoro, @streamer45 - Ready for review now. I tested and verified that everything works fine.

Copy link
Contributor

@streamer45 streamer45 left a 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",
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Contributor

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).

Copy link
Member Author

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.

Comment on lines +1036 to +1039
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)
Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Member

@agarciamontoro agarciamontoro left a 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")
Copy link
Member

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 :)

@agnivade
Copy link
Member Author

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.

Removed it.

@agnivade agnivade merged commit 8148e93 into master Aug 13, 2024
1 check passed
@agnivade agnivade deleted the redis branch August 13, 2024 03:29
@agnivade agnivade added 4: Reviews Complete All reviewers have approved the pull request and removed 2: Dev Review Requires review by a core committer labels Aug 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4: Reviews Complete All reviewers have approved the pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants