Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 4 additions & 1 deletion deployment/terraform/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ func (t *Terraform) configureAndRunAgents(extAgent *ssh.ExtAgent) error {
}

commands := []string{
"rm -rf mattermost-load-test-ng*",
// Stop and remove are joined with ; so the rm still runs on the first deploy when the services don't exist yet.
// The services must be stopped before removing the directory to avoid a race condition with ltbrowserapi
// writing to browser/node_modules, which causes rm to fail with "Directory not empty".
"sudo systemctl stop ltapi ltbrowserapi 2>/dev/null; sudo rm -rf mattermost-load-test-ng*",
"tar xzf tmp.tar.gz",
"mv mattermost-load-test-ng* mattermost-load-test-ng",
"rm tmp.tar.gz",
Expand Down
9 changes: 3 additions & 6 deletions deployment/terraform/assets/user_data.sh.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,11 @@ PROVEOF
chmod +x /tmp/provisioner.sh

# Cloud-init runs user_data as root with a minimal environment.
# Set HOME to the AMI user's home directory since provisioner scripts
# (e.g. nvm) install to $HOME and other code expects files there.
export HOME="/home/${ami_user}"
export USER="${ami_user}"

# Use runuser -l to execute the provisioner as the AMI user with a full
# login shell so that tools like nvm (sourced via ~/.bashrc) are available.
cd /tmp
rc=0
/tmp/provisioner.sh || rc=$?
runuser -l "${ami_user}" -c /tmp/provisioner.sh || rc=$?
if [ $rc -eq 0 ]; then
touch /var/lib/cloud/instance/provisioning-done
else
Expand Down