Closed janus-anderwelt closed 2 years ago
Calling "amicleaner -f --from-ids ami-01ba7496a691b0108" for below standing ami
{ "Architecture": "x86_64", "CreationDate": "2022-08-08T08:15:13.000Z", "ImageId": "ami-01ba7496a691b0108", "ImageLocation": "643424300734/DataLake-knime 4.6.1 2022-08-08T07_35_44Z", "ImageType": "machine", "Public": false, "OwnerId": "643424300734", "PlatformDetails": "Linux/UNIX", "UsageOperation": "RunInstances", "State": "pending", "BlockDeviceMappings": [{ "DeviceName": "/dev/xvda", "Ebs": { "DeleteOnTermination": true, "VolumeSize": 50, "VolumeType": "gp2", "Encrypted": true } }], "EnaSupport": true, "Hypervisor": "xen", "Name": "DataLake-knime 4.6.1 2022-08-08T07_35_44Z", "RootDeviceName": "/dev/xvda", "RootDeviceType": "ebs", "SriovNetSupport": "simple", "VirtualizationType": "hvm" }
resulted in:
[2022-08-08T08:18:54.020Z] Traceback (most recent call last): [2022-08-08T08:18:54.020Z] File "/usr/local/bin/amicleaner", line 10, in [2022-08-08T08:18:54.020Z] sys.exit(main()) [2022-08-08T08:18:54.020Z] File "/usr/local/lib/python3.7/site-packages/amicleaner/cli.py", line 195, in main [2022-08-08T08:18:54.020Z] app.run_cli() [2022-08-08T08:18:54.020Z] File "/usr/local/lib/python3.7/site-packages/amicleaner/cli.py", line 159, in run_cli [2022-08-08T08:18:54.020Z] self.prepare_delete_amis(self.from_ids, from_ids=True) [2022-08-08T08:18:54.020Z] File "/usr/local/lib/python3.7/site-packages/amicleaner/cli.py", line 109, in prepare_delete_amis [2022-08-08T08:18:54.020Z] failed = AMICleaner().remove_amis_from_ids(candidates) [2022-08-08T08:18:54.020Z] File "/usr/local/lib/python3.7/site-packages/amicleaner/core.py", line 147, in remove_amis_from_ids [2022-08-08T08:18:54.020Z] return self.remove_amis(amis) [2022-08-08T08:18:54.020Z] File "/usr/local/lib/python3.7/site-packages/amicleaner/core.py", line 120, in remove_amis [2022-08-08T08:18:54.020Z] SnapshotId=block_device.snapshot_id [2022-08-08T08:18:54.020Z] File "/usr/local/lib/python3.7/site-packages/botocore/client.py", line 508, in _api_call [2022-08-08T08:18:54.020Z] return self._make_api_call(operation_name, kwargs) [2022-08-08T08:18:54.020Z] File "/usr/local/lib/python3.7/site-packages/botocore/client.py", line 879, in _make_api_call [2022-08-08T08:18:54.020Z] api_params, operation_model, context=request_context [2022-08-08T08:18:54.020Z] File "/usr/local/lib/python3.7/site-packages/botocore/client.py", line 940, in _convert_to_request_dict [2022-08-08T08:18:54.020Z] api_params, operation_model [2022-08-08T08:18:54.020Z] File "/usr/local/lib/python3.7/site-packages/botocore/validate.py", line 381, in serialize_to_request [2022-08-08T08:18:54.020Z] raise ParamValidationError(report=report.generate_report()) [2022-08-08T08:18:54.020Z] botocore.exceptions.ParamValidationError: Parameter validation failed: [2022-08-08T08:18:54.020Z] Invalid type for parameter SnapshotId, value: None, type: <class 'NoneType'>, valid types: <class 'str'>
amicleaner should realize there is no snapshot on its own and not try to delete it.
fixed in master
Behavior observed
Calling "amicleaner -f --from-ids ami-01ba7496a691b0108" for below standing ami
resulted in:
[2022-08-08T08:18:54.020Z] Traceback (most recent call last): [2022-08-08T08:18:54.020Z] File "/usr/local/bin/amicleaner", line 10, in
[2022-08-08T08:18:54.020Z] sys.exit(main())
[2022-08-08T08:18:54.020Z] File "/usr/local/lib/python3.7/site-packages/amicleaner/cli.py", line 195, in main
[2022-08-08T08:18:54.020Z] app.run_cli()
[2022-08-08T08:18:54.020Z] File "/usr/local/lib/python3.7/site-packages/amicleaner/cli.py", line 159, in run_cli
[2022-08-08T08:18:54.020Z] self.prepare_delete_amis(self.from_ids, from_ids=True)
[2022-08-08T08:18:54.020Z] File "/usr/local/lib/python3.7/site-packages/amicleaner/cli.py", line 109, in prepare_delete_amis
[2022-08-08T08:18:54.020Z] failed = AMICleaner().remove_amis_from_ids(candidates)
[2022-08-08T08:18:54.020Z] File "/usr/local/lib/python3.7/site-packages/amicleaner/core.py", line 147, in remove_amis_from_ids
[2022-08-08T08:18:54.020Z] return self.remove_amis(amis)
[2022-08-08T08:18:54.020Z] File "/usr/local/lib/python3.7/site-packages/amicleaner/core.py", line 120, in remove_amis
[2022-08-08T08:18:54.020Z] SnapshotId=block_device.snapshot_id
[2022-08-08T08:18:54.020Z] File "/usr/local/lib/python3.7/site-packages/botocore/client.py", line 508, in _api_call
[2022-08-08T08:18:54.020Z] return self._make_api_call(operation_name, kwargs)
[2022-08-08T08:18:54.020Z] File "/usr/local/lib/python3.7/site-packages/botocore/client.py", line 879, in _make_api_call
[2022-08-08T08:18:54.020Z] api_params, operation_model, context=request_context
[2022-08-08T08:18:54.020Z] File "/usr/local/lib/python3.7/site-packages/botocore/client.py", line 940, in _convert_to_request_dict
[2022-08-08T08:18:54.020Z] api_params, operation_model
[2022-08-08T08:18:54.020Z] File "/usr/local/lib/python3.7/site-packages/botocore/validate.py", line 381, in serialize_to_request
[2022-08-08T08:18:54.020Z] raise ParamValidationError(report=report.generate_report())
[2022-08-08T08:18:54.020Z] botocore.exceptions.ParamValidationError: Parameter validation failed:
[2022-08-08T08:18:54.020Z] Invalid type for parameter SnapshotId, value: None, type: <class 'NoneType'>, valid types: <class 'str'>
Behavior expected
amicleaner should realize there is no snapshot on its own and not try to delete it.