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

Keep old configs, and cleanup completed junk periodic jobs #15

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions cloud.production/cleanup.nomad.periodic.sh
1 change: 1 addition & 0 deletions cloud.staging/cleanup.nomad.periodic.sh
11 changes: 11 additions & 0 deletions share/cleanup.nomad.periodic.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash
set -euxo pipefail

source vars.sh

ips=( "${jump_ips[@]}" )
for N in "${!ips[@]}";
do
ip="${C}.${ips[$N]}"
cleanup_nomad_periodic $ip
done;
14 changes: 13 additions & 1 deletion share/lib.sh
jlubken marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ function patch () {
local ip=$1
ssh -T -i ${ssh_key} "${user}@${ip}" << EOF
set -euxo pipefail
sudo apt-get update && \
export DEBIAN_FRONTEND=noninteractive
sudo apt-get -y upgrade -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" && \
sudo apt-get -y upgrade && \
sudo apt-get -y autoremove
EOF
Expand Down Expand Up @@ -301,6 +302,17 @@ fi;
EOF
}

function cleanup_nomad_periodic () {
# can be run on jump box with access to nomad binary
local ip=$1
ssh -T -i ${ssh_key} "${user}@${ip}" << EOF
set -euxo pipefail
sudo apt-get install parallel
nomad job status | grep 'periodic-' awk '{print $1}' > jobs.txt
cat jobs.txt | parllel -j32 nomad stop -detach -purge
EOF
}

function restart_nomad () {
local ip=$1
ssh -T -i ${ssh_key} "${user}@${ip}" << EOF
Expand Down