7 echo >&2 "usage: $0 [options] <identifier>"
9 echo >&2 " <identifier> Arvados cluster name"
11 echo >&2 "$0 options:"
12 echo >&2 " -d, --debug Enable debug output"
13 echo >&2 " -h, --help Display this help and exit"
17 # NOTE: This requires GNU getopt (part of the util-linux package on Debian-based distros).
22 if [ $? != 0 ] ; then echo "Use -h for help"; exit 1 ; fi
23 # Note the quotes around `$TEMP': they are essential!
46 if [[ "$IDENTIFIER" == '' ]]; then
56 date=`date +'%Y-%m-%d %H:%M:%S'`
60 function run_puppet() {
64 title "Running puppet on $node"
66 if [[ "$DEBUG" != "0" ]]; then
67 ssh -t -p2222 -o "StrictHostKeyChecking no" -o "ConnectTimeout 5" root@$node -C "/usr/bin/puppet agent -t" | tee $TMP_FILE
69 ssh -t -p2222 -o "StrictHostKeyChecking no" -o "ConnectTimeout 5" root@$node -C "/usr/bin/puppet agent -t" > $TMP_FILE 2>&1
73 RESULT=$(cat $TMP_FILE)
75 if [[ "$ECODE" != "255" && ! ("$RESULT" =~ 'already in progress') && "$ECODE" != "2" && "$ECODE" != "0" ]]; then
76 # Ssh exits 255 if the connection timed out. Just ignore that.
77 # Puppet exits 2 if there are changes. For real!
78 # Puppet prints 'Notice: Run of Puppet configuration client already in progress' if another puppet process
80 echo "ERROR running puppet on $node: exit code $ECODE"
81 if [[ "$DEBUG" == "0" ]]; then
82 title "Command output follows:"
86 if [[ "$ECODE" == "255" ]]; then
87 title "Connection timed out"
90 if [[ "$ECODE" == "2" ]]; then
94 eval "$return_var=$ECODE"
97 function run_command() {
102 title "Running '$command' on $node"
104 if [[ "$DEBUG" != "0" ]]; then
105 ssh -t -p2222 -o "StrictHostKeyChecking no" -o "ConnectTimeout 5" root@$node -C "$command" | tee $TMP_FILE
107 ssh -t -p2222 -o "StrictHostKeyChecking no" -o "ConnectTimeout 5" root@$node -C "$command" > $TMP_FILE 2>&1
111 RESULT=$(cat $TMP_FILE)
113 if [[ "$ECODE" != "255" && "$ECODE" != "0" ]]; then
114 # Ssh exists 255 if the connection timed out. Just ignore that, it's possible that this node is
115 # a shell node that is down.
116 title "ERROR running command on $node: exit code $ECODE"
117 if [[ "$DEBUG" == "0" ]]; then
118 title "Command output follows:"
122 if [[ "$ECODE" == "255" ]]; then
123 title "Connection timed out"
127 eval "$return_var=$ECODE"
130 title "Loading ARVADOS_API_HOST and ARVADOS_API_TOKEN"
131 if [[ -f "$HOME/.config/arvados/$IDENTIFIER.arvadosapi.com.conf" ]]; then
132 . $HOME/.config/arvados/$IDENTIFIER.arvadosapi.com.conf
134 title "WARNING: $HOME/.config/arvados/$IDENTIFIER.arvadosapi.com.conf not found."
136 if [[ "$ARVADOS_API_HOST" == "" ]] || [[ "$ARVADOS_API_TOKEN" == "" ]]; then
137 title "ERROR: ARVADOS_API_HOST and/or ARVADOS_API_TOKEN environment variables are not set."
141 title "Gathering list of shell and Keep nodes"
142 SHELL_NODES=`ARVADOS_API_HOST=$ARVADOS_API_HOST ARVADOS_API_TOKEN=$ARVADOS_API_TOKEN arv virtual_machine list |jq .items[].hostname -r`
143 KEEP_NODES=`ARVADOS_API_HOST=$ARVADOS_API_HOST ARVADOS_API_TOKEN=$ARVADOS_API_TOKEN arv keep_service list |jq .items[].service_host -r`
145 title "Updating API server"
147 run_puppet $IDENTIFIER ECODE
148 SUM_ECODE=$(($SUM_ECODE + $ECODE))
149 run_command $IDENTIFIER ECODE "/usr/local/bin/arvados-api-server-upgrade.sh"
150 SUM_ECODE=$(($SUM_ECODE + $ECODE))
151 run_command $IDENTIFIER ECODE "dpkg -L arvados-mailchimp-plugin 2>/dev/null && apt-get install arvados-mailchimp-plugin --reinstall || echo"
152 SUM_ECODE=$(($SUM_ECODE + $ECODE))
154 if [[ "$SUM_ECODE" != "0" ]]; then
155 title "ERROR: Updating API server FAILED"
156 EXITCODE=$(($EXITCODE + $SUM_ECODE))
160 title "Updating workbench"
162 if [[ `host workbench.$ARVADOS_API_HOST` != `host $ARVADOS_API_HOST` ]]; then
163 # Workbench runs on a separate host. We need to run puppet there too.
164 run_puppet workbench.$IDENTIFIER ECODE
165 SUM_ECODE=$(($SUM_ECODE + $ECODE))
168 run_command workbench.$IDENTIFIER ECODE "/usr/local/bin/arvados-workbench-upgrade.sh"
169 SUM_ECODE=$(($SUM_ECODE + $ECODE))
171 if [[ "$SUM_ECODE" != "0" ]]; then
172 title "ERROR: Updating workbench FAILED"
173 EXITCODE=$(($EXITCODE + $SUM_ECODE))
177 for n in manage $SHELL_NODES $KEEP_NODES; do
179 if [[ $n =~ $ARVADOS_API_HOST$ ]]; then
180 # e.g. keep.qr1hi.arvadosapi.com
184 node=$n.$ARVADOS_API_HOST
188 node=${node%.arvadosapi.com}
190 title "Updating $node"
191 run_puppet $node ECODE
192 if [[ "$ECODE" != "0" ]]; then
193 title "ERROR: Updating $node node FAILED: exit code $ECODE"
194 EXITCODE=$(($EXITCODE + $ECODE))