cosalib/aws: check for 'amis' key in buildmeta#1299
cosalib/aws: check for 'amis' key in buildmeta#1299openshift-merge-robot merged 1 commit intocoreos:masterfrom miabbott:ami_key_error
Conversation
|
/lgtm |
|
Rebased to pull in #1303 |
| build.refresh_meta() | ||
| buildmeta = build.meta | ||
| if len(buildmeta['amis']) < 1: | ||
| if 'amis' not in buildmeta: |
There was a problem hiding this comment.
Hmm, I think we do want to check that there's at least one source AMI though, no? I mean, we'll error out anyway later on at:
args.source_region = buildmeta['amis'][0]['name']But the error message here is nicer than what IndexError will print. :) So maybe just:
if len(buildmeta.get('amis', [])) < 1:?
There was a problem hiding this comment.
I'll go this path, but I wonder how someone would end up with an empty amis list?
There was a problem hiding this comment.
Ah nevermind, I see why checking length makes sense now.
| if len(buildmeta['amis']) < 1: | ||
| if 'amis' not in buildmeta: | ||
| raise SystemExit(("buildmeta doesn't contain source AMIs." | ||
| " Run buildextend-aws first")) |
There was a problem hiding this comment.
And maybe here "Run buildextend-aws --upload first." to be more accurate.
|
Sorry, didn't mean to also approve. (I started using https://github.com/sindresorhus/refined-github in my Firefox and it's really good for the most part, but still getting used to some of the changes.) |
Noticed this when I did `cosa buildextend-aws` (without `--upload`) and then tried to do `cosa aws-replicate`. Without this change, it would blow up with a KeyError since the AMIs were never uploaded.
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: bgilbert, cgwalters, jlebon, miabbott The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Noticed this when I did
cosa buildextend-aws(without--upload)and then tried to do
cosa aws-replicate. Without this change, itwould blow up with a KeyError since the AMIs were never uploaded.