Improve mussel helper retry #572

Merged
merged 3 commits into from May 14, 2015

Projects

None yet

2 participants

@hansode
Member
hansode commented May 8, 2015

Problem

When running set -u enabled script which includes retry.sh, that scripts got following error:

/opt/axsh/wakame-vdc/client/mussel/test/helpers/retry.sh: line 29: chk_cmd: unbound variable

sample script:

$ cat inst-create.sh
#!/bin/bash
#
#
set -e
set -o pipefail
set -u

## include

. /opt/axsh/wakame-vdc/client/mussel/test/helpers/retry.sh

## test

type -P mussel >/dev/null

## shell params

cpu_cores=${cpu_cores:-1}
hypervisor=${hypervisor:-kvm}
image_id=${image_id:-wmi-centos1d64}
memory_size=${memory_size:-256}

ssh_key_id=${ssh_key_id:?"should not be empty"} # ssh-ytzd50zj
vifs=${vifs:-vifs.json}
user_data=${user_data-/dev/null} # user_data_mysqld.txt

## create an instance

instance_id="$(
  mussel instance create \
   --cpu-cores   ${cpu_cores}   \
   --hypervisor  ${hypervisor}  \
   --image-id    ${image_id}    \
   --memory-size ${memory_size} \
   --ssh-key-id  ${ssh_key_id}  \
   --vifs        ${vifs}        \
   --user-data   ${user_data}   \
  | egrep ^:id: | awk '{print $2}'
)"
: ${instance_id:?"instance is empty"}

## wait for the instance to be running

retry_until [[ '"$(mussel instance show "${instance_id}" | egrep -w "^:state: running")"' ]]
echo instance_id="${instance_id}"

Improve

  1. add proper indents
  2. use here-string instead of echo & pipe to remove unnecessary "|"
hansode added some commits May 8, 2015
@hansode hansode make sure to declare "chk_cmd". f55d984
@hansode hansode use here-string instead of echo & pipe. 0fa1149
@hansode hansode add proper indent.
0752d5a
@hansode hansode added the Type : Bug label May 8, 2015
@hansode hansode added this to the v15.03 Mussel release milestone May 8, 2015
@hansode hansode self-assigned this May 8, 2015
@Metallion
Member

Looks good to me. +1

@Metallion Metallion merged commit 8b44121 into master May 14, 2015

7 of 8 checks passed

wakame-ci/lxc.smoke.allowed-failure The build was failure on wakame-ci #20040 (0752d5a9).
wakame-ci/dummy.smoke The build was success on wakame-ci #20037 (0752d5a9).
wakame-ci/kvm.smoke The build was success on wakame-ci #20044 (0752d5a9).
wakame-ci/kvm.smoke.allowed-failure The build was success on wakame-ci #20039 (0752d5a9).
wakame-ci/rpmbuild The build was success on wakame-ci #20022 (0752d5a9).
wakame-ci/rspec The build was success on wakame-ci #20020 (0752d5a9).
wakame-ci/to-s3 The build was success on wakame-ci #20024 (0752d5a9).
wakame-ci/vz.smoke The build was success on wakame-ci #20045 (0752d5a9).
@Metallion Metallion deleted the improve-mussel-helper-retry branch May 14, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment