diff --git a/cmd/ltctl/reset.go b/cmd/ltctl/reset.go index d8b44e641..75558f148 100644 --- a/cmd/ltctl/reset.go +++ b/cmd/ltctl/reset.go @@ -66,6 +66,7 @@ func RunResetCmdF(cmd *cobra.Command, args []string) error { } binaryPath := "/opt/mattermost/bin/mattermost" + mmctlPath := "/opt/mattermost/bin/mmctl" cmds := []struct { msg string @@ -74,7 +75,7 @@ func RunResetCmdF(cmd *cobra.Command, args []string) error { }{ { msg: "Resetting database", - value: fmt.Sprintf("%s reset --confirm", binaryPath), + value: fmt.Sprintf("%s db reset --confirm", binaryPath), clients: []*ssh.Client{appClients[0]}, }, { @@ -84,8 +85,8 @@ func RunResetCmdF(cmd *cobra.Command, args []string) error { }, { msg: "Creating sysadmin", - value: fmt.Sprintf("%s user create --email %s --username %s --password '%s' --system_admin", - binaryPath, config.AdminEmail, config.AdminUsername, config.AdminPassword), + value: fmt.Sprintf("%s user create --email %s --username %s --password '%s' --system-admin --local", + mmctlPath, config.AdminEmail, config.AdminUsername, config.AdminPassword), clients: []*ssh.Client{appClients[0]}, }, { diff --git a/comparison/loadtest.go b/comparison/loadtest.go index 29eeb068a..bb213dd4e 100644 --- a/comparison/loadtest.go +++ b/comparison/loadtest.go @@ -180,11 +180,11 @@ func initLoadTest(t *terraform.Terraform, buildCfg BuildConfig, dumpFilename str } // do init process - binaryPath := "/opt/mattermost/bin/mattermost" + mmctlPath := "/opt/mattermost/bin/mmctl" createAdminCmd := cmd{ msg: "Creating sysadmin", - value: fmt.Sprintf("%s user create --email %s --username %s --password '%s' --system_admin || true", - binaryPath, dpConfig.AdminEmail, dpConfig.AdminUsername, dpConfig.AdminPassword), + value: fmt.Sprintf("%s user create --email %s --username %s --password '%s' --system-admin --local || true", + mmctlPath, dpConfig.AdminEmail, dpConfig.AdminUsername, dpConfig.AdminPassword), clients: []*ssh.Client{appClients[0]}, } initDataCmd := cmd{ diff --git a/deployment/terraform/create.go b/deployment/terraform/create.go index d3a65fdbd..3e50472d7 100644 --- a/deployment/terraform/create.go +++ b/deployment/terraform/create.go @@ -324,7 +324,7 @@ func (t *Terraform) setupProxyServer(extAgent *ssh.ExtAgent) { } func (t *Terraform) createAdminUser(extAgent *ssh.ExtAgent) error { - cmd := fmt.Sprintf("/opt/mattermost/bin/mmctl user create --email %s --username %s --password %s --system_admin --local", + cmd := fmt.Sprintf("/opt/mattermost/bin/mmctl user create --email %s --username %s --password %s --system-admin --local", t.config.AdminEmail, t.config.AdminUsername, t.config.AdminPassword, @@ -353,15 +353,19 @@ func (t *Terraform) updateAppConfig(ip string, sshc *ssh.Client, jobServerEnable driverName = t.config.ExternalDBSettings.DriverName if t.output.HasDB() { + var err error + clusterDSN, err = t.getClusterDSN() + if err != nil { + return fmt.Errorf("could not update config: %w", err) + } + switch t.config.TerraformDBSettings.InstanceEngine { case "aurora-postgresql": - clusterDSN = "postgres://" + t.config.TerraformDBSettings.UserName + ":" + t.config.TerraformDBSettings.Password + "@" + t.output.DBWriter() + "/" + t.config.DBName() + "?sslmode=disable" for _, rd := range t.output.DBReaders() { readerDSN = append(readerDSN, "postgres://"+t.config.TerraformDBSettings.UserName+":"+t.config.TerraformDBSettings.Password+"@"+rd+"/"+t.config.DBName()+"?sslmode=disable") } driverName = "postgres" case "aurora-mysql": - clusterDSN = t.config.TerraformDBSettings.UserName + ":" + t.config.TerraformDBSettings.Password + "@tcp(" + t.output.DBWriter() + ")/" + t.config.DBName() + "?charset=utf8mb4,utf8\u0026readTimeout=30s\u0026writeTimeout=30s" for _, rd := range t.output.DBReaders() { readerDSN = append(readerDSN, t.config.TerraformDBSettings.UserName+":"+t.config.TerraformDBSettings.Password+"@tcp("+rd+")/"+t.config.DBName()+"?charset=utf8mb4,utf8\u0026readTimeout=30s\u0026writeTimeout=30s") } diff --git a/deployment/terraform/utils.go b/deployment/terraform/utils.go index 57d31624a..5e38851ed 100644 --- a/deployment/terraform/utils.go +++ b/deployment/terraform/utils.go @@ -236,3 +236,15 @@ func (t *Terraform) getParams() []string { "-var", fmt.Sprintf("job_server_instance_type=%s", t.config.JobServerSettings.InstanceType), } } + +func (t *Terraform) getClusterDSN() (string, error) { + switch t.config.TerraformDBSettings.InstanceEngine { + case "aurora-postgresql": + return "postgres://" + t.config.TerraformDBSettings.UserName + ":" + t.config.TerraformDBSettings.Password + "@" + t.output.DBWriter() + "/" + t.config.DBName() + "?sslmode=disable", nil + + case "aurora-mysql": + return t.config.TerraformDBSettings.UserName + ":" + t.config.TerraformDBSettings.Password + "@tcp(" + t.output.DBWriter() + ")/" + t.config.DBName() + "?charset=utf8mb4,utf8\u0026readTimeout=30s\u0026writeTimeout=30s", nil + default: + return "", errors.New("unsupported database engine") + } +}