Skip to content

Commit

Permalink
[MM-60412] Fix potentially stuck init process (#827)
Browse files Browse the repository at this point in the history
* Fix potentially stuck init process

* Rename
  • Loading branch information
streamer45 authored Oct 14, 2024
1 parent dffb40a commit 147f26e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
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
}

serverURLOverride, err := cmd.Flags().GetString("server-url")
if err != nil {
return err
}

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

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

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("server-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' --server-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' --server-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' --server-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

0 comments on commit 147f26e

Please sign in to comment.