6 if [[ "$IDENTIFIER" == '' ]]; then
7 echo "Syntax: $0 <identifier> <deploy_repo_name>"
11 if [[ "$DEPLOY_REPO" == '' ]]; then
12 echo "Syntax: $0 <identifier> <deploy_repo_name>"
21 printf "\n%*s\n\n" $(((${#title}+$COLUMNS)/2)) "********** $1 **********"
24 # We only install capistrano in dev mode
25 export RAILS_ENV=development
27 source /etc/profile.d/rvm.sh
30 # Weirdly, jenkins/rvm ties itself in a knot.
33 # Just say what version of ruby we're running
36 function ensure_symlink() {
37 if [[ ! -L $WORKSPACE/$1 ]]; then
38 ln -s $WORKSPACE/$DEPLOY_REPO/$1 $WORKSPACE/$1
42 # Check out/update the $DEPLOY_REPO repository
43 if [[ ! -d $DEPLOY_REPO ]]; then
45 git clone git@git.curoverse.com:$DEPLOY_REPO.git
51 # Make sure the necessary symlinks are in place
53 ensure_symlink "apps/workbench/Capfile.workbench.$IDENTIFIER"
54 ensure_symlink "apps/workbench/config/deploy.common.rb"
55 ensure_symlink "apps/workbench/config/deploy.curoverse.rb"
56 ensure_symlink "apps/workbench/config/deploy.workbench.$IDENTIFIER.rb"
58 ensure_symlink "services/api/Capfile.$IDENTIFIER"
59 ensure_symlink "services/api/config/deploy.common.rb"
60 ensure_symlink "services/api/config/deploy.$IDENTIFIER.rb"
63 title "Deploying API server"
67 bundle install --deployment
69 # make sure we do not print the output of config:check
70 sed -i'' -e "s/RAILS_ENV=production #{rake} config:check/RAILS_ENV=production QUIET=true #{rake} config:check/" $WORKSPACE/$DEPLOY_REPO/services/api/config/deploy.common.rb
72 bundle exec cap deploy -f Capfile.$IDENTIFIER
76 # restore unaltered deploy.common.rb
77 cd $WORKSPACE/$DEPLOY_REPO
78 git checkout services/api/config/deploy.common.rb
80 if [[ "$ECODE" != "0" ]]; then
81 title "!!!!!! DEPLOYING API SERVER FAILED !!!!!!"
82 EXITCODE=$(($EXITCODE + $ECODE))
86 title "Deploying API server complete"
88 # Install updated debian packages
89 title "Deploying updated arvados debian packages"
91 ssh -p2222 root@$IDENTIFIER.arvadosapi.com -C "apt-get update && apt-get -qqy install arvados-src python-arvados-fuse python-arvados-python-client"
93 if [[ "$ECODE" != "0" ]]; then
94 title "!!!!!! DEPLOYING DEBIAN PACKAGES FAILED !!!!!!"
95 EXITCODE=$(($EXITCODE + $ECODE))
99 title "Deploying updated arvados debian packages complete"
101 # Install updated arvados gems
102 title "Deploying updated arvados gems"
104 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"
106 if [[ "$ECODE" != "0" ]]; then
107 title "!!!!!! DEPLOYING ARVADOS GEMS FAILED !!!!!!"
108 EXITCODE=$(($EXITCODE + $ECODE))
112 title "Deploying updated arvados gems complete"
115 title "Deploying workbench"
118 bundle install --deployment
120 # make sure we do not print the output of config:check
121 sed -i'' -e "s/RAILS_ENV=production #{rake} config:check/RAILS_ENV=production QUIET=true #{rake} config:check/" $WORKSPACE/$DEPLOY_REPO/apps/workbench/config/deploy.common.rb
123 bundle exec cap deploy -f Capfile.workbench.$IDENTIFIER
127 # restore unaltered deploy.common.rb
128 cd $WORKSPACE/$DEPLOY_REPO
129 git checkout apps/workbench/config/deploy.common.rb
131 if [[ "$ECODE" != "0" ]]; then
132 title "!!!!!! DEPLOYING WORKBENCH FAILED !!!!!!"
133 EXITCODE=$(($EXITCODE + $ECODE))
137 title "Deploying workbench complete"
139 # Update compute node(s)
140 title "Update compute node(s)"
142 # Get list of nodes that are up
143 COMPRESSED_NODE_LIST=`ssh -p2222 root@$IDENTIFIER -C "sinfo --long -p crypto -r -o "%N" -h"`
145 if [[ "$COMPRESSED_NODE_LIST" != '' ]]; then
146 COMPUTE_NODES=`ssh -p2222 root@$IDENTIFIER -C "scontrol show hostname $COMPRESSED_NODE_LIST"`
149 for node in $COMPUTE_NODES; do
150 echo "Updating $node.$IDENTIFIER"
151 ssh -p2222 -o "StrictHostKeyChecking no" -o "ConnectTimeout 5" root@$node.$IDENTIFIER -C "/usr/bin/puppet agent -t"
153 if [[ "$ECODE" != "255" && "$ECODE" != "2" && "$ECODE" != "0" ]]; then
154 # 255 -> connection timed out. Just ignore that, it's possible the compute node was being shut down.
155 # Puppet exits '2' if there are changes. For real!
156 SUM_ECODE=$(($SUM_ECODE + $ECODE))
157 echo "ERROR updating $node.$IDENTIFIER: exit code $ECODE"
161 if [[ "$SUM_ECODE" != "0" ]]; then
162 title "!!!!!! Update compute node(s) FAILED !!!!!!"
163 EXITCODE=$(($EXITCODE + $SUM_ECODE))
167 title "Update compute node(s) complete"
171 ssh -p2222 root@shell.$IDENTIFIER -C "/usr/bin/puppet agent -t"
175 if [[ "$ECODE" == "2" ]]; then
176 # Puppet exits '2' if there are changes. For real!
180 if [[ "$ECODE" != "0" ]]; then
181 title "!!!!!! Update shell FAILED !!!!!!"
182 EXITCODE=$(($EXITCODE + $ECODE))
185 title "Update shell complete"
189 ssh -p2222 root@keep0.$IDENTIFIER -C "/usr/bin/puppet agent -t"
193 if [[ "$ECODE" == "2" ]]; then
194 # Puppet exits '2' if there are changes. For real!
198 if [[ "$ECODE" != "0" ]]; then
199 title "!!!!!! Update keep0 FAILED !!!!!!"
200 EXITCODE=$(($EXITCODE + $ECODE))
203 title "Update keep0 complete"