list index out of range

186 views
Skip to first unread message

Alex Maccabi

unread,
Jun 10, 2015, 8:45:33 AM6/10/15
to rundeck...@googlegroups.com
Hey,
Had anyone had or saw this kind of error:
list index out of range
Failed: NonZeroResultCode: Result code was 255

My workflow is like this:
deploy app to remote node on AWS, the node list is generated with aws plugin tags and etc.
create ami with aws api (aws ec2 create-image).
then run a script locally "/bin/bash -c /var/lib/rundeck/tagami.sh"
the script:
#! /bin/bash
AMI_ID=`aws ec2 describe-images --profile $RD_OPTION_NODE_ENV --filters "Name=name,Values=$RD_OPTION_TAG-build-$RD_OPTION_BUILDNUMBER" --query 'Images[*].{ID:ImageId}'`
VERSION=`echo $RD_OPTION_TAG | cut -d '_' -f 3`
aws ec2 create-tags --profile $RD_OPTION_NODE_ENV --resources $AMI_ID  --tags Key=Role,Value=$RD_OPTION_APP_NAME Key=Version,Value=$VERSION
exit 0

basically it tags the instance, so I could continue with the flow (Netflix Asgard).
its mixed success, sometimes it fails with the 'list index out of range' I've added 'exit 0' I though maybe it isn't exiting correctly and sometimes it works.
I've created another job that contains only the script for the tagging and it seems to work.
please advice.

Alex Honor

unread,
Jun 10, 2015, 10:56:59 AM6/10/15
to rundeck...@googlegroups.com
It looks like a bash error to me. It's failing before it gets to the 'exit 0'. 
You might set the shell option, set -eu, to fail faster.

--
You received this message because you are subscribed to the Google Groups "rundeck-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rundeck-discu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rundeck-discuss/afcdedc8-4587-4439-98c6-d5cff0fe9a9d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Alex Honor

[SimplifyOps, Inc | a...@simplifyops.com ]

Be sure to comment and vote on Rundeck Feature Development!

Douglas Held

unread,
Dec 18, 2015, 9:17:44 AM12/18/15
to rundeck-discuss
Yes, I see this error when I run the "create-tags" command and the parameter for --resources is empty because of an error in my bash script's parameter handling.

In this case, check that "$AMI_ID" always resolves to something nonempty.

Doug
Reply all
Reply to author
Forward
0 new messages