File tree Expand file tree Collapse file tree 2 files changed +7
-7
lines changed
Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -63,7 +63,10 @@ func (t *Terraform) configureAndRunAgents(extAgent *ssh.ExtAgent) error {
6363 }
6464
6565 commands := []string {
66- "rm -rf mattermost-load-test-ng*" ,
66+ // Stop and remove are joined with ; so the rm still runs on the first deploy when the services don't exist yet.
67+ // The services must be stopped before removing the directory to avoid a race condition with ltbrowserapi
68+ // writing to browser/node_modules, which causes rm to fail with "Directory not empty".
69+ "sudo systemctl stop ltapi ltbrowserapi 2>/dev/null; sudo rm -rf mattermost-load-test-ng*" ,
6770 "tar xzf tmp.tar.gz" ,
6871 "mv mattermost-load-test-ng* mattermost-load-test-ng" ,
6972 "rm tmp.tar.gz" ,
Original file line number Diff line number Diff line change @@ -12,14 +12,11 @@ PROVEOF
1212chmod +x /tmp/provisioner.sh
1313
1414# Cloud-init runs user_data as root with a minimal environment.
15- # Set HOME to the AMI user's home directory since provisioner scripts
16- # (e.g. nvm) install to $HOME and other code expects files there.
17- export HOME=" /home/${ami_user} "
18- export USER=" ${ami_user} "
19-
15+ # Use runuser -l to execute the provisioner as the AMI user with a full
16+ # login shell so that tools like nvm (sourced via ~/.bashrc) are available.
2017cd /tmp
2118rc=0
22- /tmp/provisioner.sh || rc=$?
19+ runuser -l " ${ami_user} " -c /tmp/provisioner.sh || rc=$?
2320if [ $rc -eq 0 ]; then
2421 touch /var/lib/cloud/instance/provisioning-done
2522else
You can’t perform that action at this time.
0 commit comments