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-60412] Fix potentially stuck init process #827

Merged
merged 2 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions cmd/ltagent/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,20 @@ func RunInitCmdF(cmd *cobra.Command, args []string) error {
return err
}

siteURLOverride, err := cmd.Flags().GetString("site-url")
Copy link
Member

Choose a reason for hiding this comment

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

Can we rename the flag to server-url? Or override-server-url? I ask because there's a SiteURL config already in the deployer, and it's already a bit confusing.

if err != nil {
return err
}

config, err := loadtest.ReadConfig(configFilePath)
if err != nil {
return err
}

if siteURLOverride != "" {
config.ConnectionConfiguration.ServerURL = siteURLOverride
}

if err := defaults.Validate(*config); err != nil {
return fmt.Errorf("could not validate configuration: %w", err)
}
Expand Down Expand Up @@ -215,6 +224,7 @@ func MakeInitCommand() *cobra.Command {
PreRun: SetupLoadTest,
}
cmd.PersistentFlags().StringP("user-prefix", "", "testuser", "prefix used when generating usernames and emails")
cmd.PersistentFlags().StringP("site-url", "", "", "an optional override for ConnectionConfiguration.ServerURL")
return cmd
}

Expand Down
7 changes: 4 additions & 3 deletions cmd/ltctl/reset.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func RunResetCmdF(cmd *cobra.Command, args []string) error {
clients: []*ssh.Client{appClients[0]},
},
{
msg: "Restarting app server...",
msg: "Restarting app servers...",
value: "sudo systemctl restart mattermost && until $(curl -sSf http://localhost:8065 --output /dev/null); do sleep 1; done;",
clients: appClients,
},
Expand All @@ -100,8 +100,9 @@ func RunResetCmdF(cmd *cobra.Command, args []string) error {
clients: []*ssh.Client{appClients[0]},
},
{
msg: "Initializing data...",
value: fmt.Sprintf("cd mattermost-load-test-ng && ./bin/ltagent init --user-prefix '%s'", output.Agents[0].Tags.Name),
msg: "Initializing data...",
value: fmt.Sprintf("cd mattermost-load-test-ng && ./bin/ltagent init --user-prefix '%s' --site-url 'http://%s:8065'",
output.Agents[0].Tags.Name, output.Instances[0].PrivateIP),
clients: []*ssh.Client{agentClient},
},
}
Expand Down
5 changes: 3 additions & 2 deletions comparison/loadtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,9 @@ func initLoadTest(t *terraform.Terraform, buildCfg BuildConfig, dumpFilename str
Clients: []*ssh.Client{appClients[0]},
}
initDataCmd := deployment.Cmd{
Msg: "Initializing data",
Value: fmt.Sprintf("cd mattermost-load-test-ng && ./bin/ltagent init --user-prefix '%s' > /dev/null 2>&1", tfOutput.Agents[0].Tags.Name),
Msg: "Initializing data",
Value: fmt.Sprintf("cd mattermost-load-test-ng && ./bin/ltagent init --user-prefix '%s' --site-url 'http://%s:8065' > /dev/null 2>&1",
tfOutput.Agents[0].Tags.Name, tfOutput.Instances[0].PrivateIP),
Clients: []*ssh.Client{agentClient},
}

Expand Down
3 changes: 2 additions & 1 deletion deployment/terraform/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,8 @@ func (t *Terraform) initLoadtest(extAgent *ssh.ExtAgent, initData bool) error {

if initData && t.config.TerraformDBSettings.ClusterIdentifier == "" {
mlog.Info("Populating initial data for load-test", mlog.String("agent", ip))
cmd := fmt.Sprintf("cd mattermost-load-test-ng && ./bin/ltagent init --user-prefix '%s'", t.output.Agents[0].Tags.Name)
cmd := fmt.Sprintf("cd mattermost-load-test-ng && ./bin/ltagent init --user-prefix '%s' --site-url 'http://%s:8065'",
t.output.Agents[0].Tags.Name, t.output.Instances[0].PrivateIP)
if out, err := sshc.RunCommand(cmd); err != nil {
// TODO: make this fully atomic. See MM-23998.
// ltagent init should drop teams and channels before creating them.
Expand Down
Loading