some xenial amis are missing snapshots in aws
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
cloud-images |
Fix Released
|
Undecided
|
Dan Watkins |
Bug Description
This may relate to
#1671194 ec2 stream data images missing at least in us-east-2
For me, it manifests as ami's that exist in ec2, but their snapshots do not.
This is a problem as we are trying to automate ami building based on snapshots.
Eg.
The latest hvm:evs-ssd of xenial released 2017 03 30 for us=west-2 is ami-fa27b39a
This image exists in aws, and you can launch an instance from it.
Its metadata shows a snapshot-id of 'snap-06083cf1c
This snap doesn't appear to exist in AWS EC2 snapshots.
16:10 $ aws ec2 describe-images --image-id ami-fa27b39a
{
"Images": [
{
"Name": "ubuntu/
{
},
{
},
{
}
],
}
]
}
HOWEVER, the snapshot cannot be found.
16:47 $ aws ec2 describe-snapshots --snapshot-id snap-06083cf1c6
An error occurred (InvalidSnapsho
Searching only owner=099720109477 (ubuntu) and xenial string and sort descending on date there are large gaps in snapshot releases
march 17, 16, 11, 8, 3...
Searching the same but for amis, there are a few gaps but it is almost daily.
Changed in cloud-images: | |
status: | New → In Progress |
assignee: | nobody → Dan Watkins (daniel-thewatkins) |
Changed in cloud-images: | |
status: | In Progress → Fix Released |
tags: | added: id-58e4f954c5ad1c5de5aa9c34 |
Here is a script to detect the amis with missing snapshots
---------------
from __future__ import print_function
import boto3
import logging
# See https:/ /boto3. readthedocs. io/en/latest/ reference/ services/ ec2.html# EC2.Client. describe_ snapshots /boto3. readthedocs. io/en/latest/ reference/ services/ ec2.html# EC2.Client. describe_ images
# And https:/
# Limitations: Does not handle paging, so if NextToken is not null, warn and fail
ARGPARSE_ DESCRIPTION = '''
Script to find latest complete ami and report missing snapshots.
Primarily designed to fetch latest ubuntu cloud image, but flexible options for other targets. /bugs.launchpad .net/cloud- images/ +bug/1679855
It turns out that sometimes ubuntu pushes ami's which have snapshots that can't be found.
https:/
We check to make sure that the snapshots used by the ami are present.
'''
DEFAULT_OWNER = "099720109477" # ubuntu
try: ArgumentParser(
description= ARGPARSE_ DESCRIPTION,
config_ file_parser_ class=argparse. YAMLConfigFileP arser) add_argument( '-c', '--config-file', is_config_ file=True, dest='config_file', required=False,
help= 'provide a yaml config file (using dest names) instead of commandline args') CONFIG_ ARGPARSE = True ArgumentParser(
description= ARGPARSE_ DESCRIPTION) CONFIG_ ARGPARSE = False
import configargparse as argparse
import dotmap
parser = argparse.
parser.
HAS_
except:
import argparse
parser = argparse.
HAS_
def get_amis(ec2, args): images( Owners= args.owners,
Filters= args.ami_ filters) amis["Images" ], key=lambda k: k['CreationDate'], reverse=True)
amis = ec2.describe_
return sorted(
def main():
parser. add_argument( '-r', '--region', dest='region', default= 'us-west- 2') add_argument( '-o', '--owner-ids', dest="owners", default= [DEFAULT_ OWNER],
help= """AWS org owner, default is id for ubuntu org, ['string1',]
Use ['self'] for caller's aws org""") add_argument( '-f', '--ami-filters', dest="ami_filters",
default= [{'Name' : 'root-device-type',
'Values' : ['ebs'] },
{'Name' : 'architecture',
'Values' : ['x86_64'] },
{'Name' : 'virtualization -type',
'Values' : ['hvm'] },
{'Name' : 'name',
'Values' : ['*ubuntu- xenial- 16.04-amd64- server* '] }]
) add_argument( '-n', '--num-amis', dest='max_amis', type=int, default=4)
parser.
parser.
parser.
if HAS_CONFIG_ ARGPARSE: parse_known_ args() DotMap( vars(args[ 0]))
args = parser.
args = dotmap.
else:
args = parser.parse_args()
ec2 = boto3.client('ec2')
good_ ami_snap_ map = [] ami_snap_ map = [] args.ami_ filters) ) max_amis] : ami["BlockDevic eMappings" ...
bad_
amis = get_amis(ec2, args)
if not amis:
raise Exception("No amis found. Check your filters {}".format(
for ami in amis[:args.
snaps = []
for i, device in enumerate(