4 read -rd "\000" helpmessage <<EOF
5 $(basename $0): Deploy Arvados to a cluster
8 $(basename $0) <identifier>
12 identifier Arvados cluster name
19 if [[ "$IDENTIFIER" == '' ]]; then
20 echo >&2 "$helpmessage"
30 printf "\n%*s\n\n" $(((${#title}+$COLUMNS)/2)) "********** $1 **********"
35 function run_puppet() {
40 ssh -t -p2222 -o "StrictHostKeyChecking no" -o "ConnectTimeout 5" root@$node.$IDENTIFIER -C "/usr/bin/puppet agent -t" | tee $TMP_FILE
43 RESULT=$(cat $TMP_FILE)
45 if [[ "$ECODE" != "255" && ! ("$RESULT" =~ 'already in progress') && "$ECODE" != "2" && "$ECODE" != "0" ]]; then
46 # Puppet exists 255 if the connection timed out. Just ignore that, it's possible that this node is
47 # a compute node that was being shut down.
48 # Puppet exits 2 if there are changes. For real!
49 # Puppet prints 'Notice: Run of Puppet configuration client already in progress' if another puppet process
51 echo "ERROR updating $node.$IDENTIFIER: exit code $ECODE"
55 eval "$return_var=$ECODE"
59 title "Deploying API server"
63 # Install updated debian packages
64 title "Deploying updated arvados debian packages"
66 ssh -p2222 root@$IDENTIFIER.arvadosapi.com -C "apt-get update && apt-get -qqy install arvados-src python-arvados-fuse python-arvados-python-client arvados-api-server"
69 SUM_ECODE=$(($SUM_ECODE + $ECODE))
71 ssh -p2222 root@$IDENTIFIER.arvadosapi.com -C "/usr/local/bin/arvados-api-server-upgrade.sh"
74 SUM_ECODE=$(($SUM_ECODE + $ECODE))
76 if [[ "$SUM_ECODE" != "0" ]]; then
77 title "!!!!!! DEPLOYING DEBIAN PACKAGES FAILED !!!!!!"
78 EXITCODE=$(($EXITCODE + $SUM_ECODE))
82 title "Deploying updated arvados debian packages complete"
84 # Install updated arvados gems
85 title "Deploying updated arvados gems"
87 ssh -p2222 root@$IDENTIFIER.arvadosapi.com -C "/usr/local/rvm/bin/rvm default do gem install arvados arvados-cli && /usr/local/rvm/bin/rvm default do gem clean arvados arvados-cli"
91 if [[ "$ECODE" != "0" ]]; then
92 title "!!!!!! DEPLOYING ARVADOS GEMS FAILED !!!!!!"
93 EXITCODE=$(($EXITCODE + $ECODE))
97 title "Deploying updated arvados gems complete"
98 title "Deploying API server complete"
101 title "Deploying workbench"
103 # Install updated debian packages
104 title "Deploying updated arvados debian packages"
106 ssh -p2222 root@workbench.$IDENTIFIER.arvadosapi.com -C "apt-get update && apt-get -qqy install python-arvados-fuse python-arvados-python-client arvados-workbench"
109 SUM_ECODE=$(($SUM_ECODE + $ECODE))
111 ssh -p2222 root@workbench.$IDENTIFIER.arvadosapi.com -C "/usr/local/bin/arvados-workbench-upgrade.sh"
114 SUM_ECODE=$(($SUM_ECODE + $ECODE))
116 if [[ "$SUM_ECODE" != "0" ]]; then
117 title "!!!!!! DEPLOYING DEBIAN PACKAGES FAILED !!!!!!"
118 EXITCODE=$(($EXITCODE + $SUM_ECODE))
122 title "Deploying updated arvados debian packages complete"
124 title "Deploying workbench complete"
126 # Update compute node(s)
127 title "Update compute node(s)"
129 # Get list of nodes that are up
130 COMPRESSED_NODE_LIST=`ssh -p2222 root@$IDENTIFIER -C "sinfo --long -p crypto -r -o "%N" -h"`
132 if [[ "$COMPRESSED_NODE_LIST" != '' ]]; then
133 COMPUTE_NODES=`ssh -p2222 root@$IDENTIFIER -C "scontrol show hostname $COMPRESSED_NODE_LIST"`
136 for node in $COMPUTE_NODES; do
137 echo "Updating $node.$IDENTIFIER"
138 run_puppet $node ECODE
139 SUM_ECODE=$(($SUM_ECODE + $ECODE))
142 if [[ "$SUM_ECODE" != "0" ]]; then
143 title "!!!!!! Update compute node(s) FAILED !!!!!!"
144 EXITCODE=$(($EXITCODE + $SUM_ECODE))
148 title "Update compute node(s) complete"
152 run_puppet shell ECODE
154 if [[ "$ECODE" == "2" ]]; then
155 # Puppet exits '2' if there are changes. For real!
159 if [[ "$ECODE" != "0" ]]; then
160 title "!!!!!! Update shell FAILED !!!!!!"
161 EXITCODE=$(($EXITCODE + $ECODE))
164 title "Update shell complete"
168 run_puppet keep0 ECODE
170 if [[ "$ECODE" == "2" ]]; then
171 # Puppet exits '2' if there are changes. For real!
175 if [[ "$ECODE" != "0" ]]; then
176 title "!!!!!! Update keep0 FAILED !!!!!!"
177 EXITCODE=$(($EXITCODE + $ECODE))
180 title "Update keep0 complete"