Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions mantle/cmd/ore/aws/delete-image.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,18 @@ func runDeleteImage(cmd *cobra.Command, args []string) {
}

if snapshotID != "" {
if snapshotID == "detectFromAMI" && amiID != "" {
// Let's try to extract the snapshotID from AMI
snapshot, err := API.FindSnapshot(amiID)
if err != nil {
fmt.Fprintf(os.Stderr, "Warning: Encountered error when searching for snapshot for %s: %s. Continuing..\n", amiID, err)
os.Exit(0)
} else if snapshot == nil {
fmt.Fprintf(os.Stdout, "No valid snapshot found for %s.\n", amiID)
os.Exit(0)
}
snapshotID = snapshot.SnapshotID
}
err := API.RemoveBySnapshotTag(snapshotID, allowMissing)
if err != nil {
fmt.Fprintf(os.Stderr, "Could not delete %v: %v\n", snapshotID, err)
Expand Down
4 changes: 3 additions & 1 deletion src/cmd-cloud-prune
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,9 @@ def deregister_aws_amis(build, cloud_config, dry_run):
for ami in amis:
region_name = ami.get("name")
ami_id = ami.get("hvm")
snapshot_id = ami.get("snapshot")
# If we are dealing with an old manifest where the snapshot ID isn't stored
# then let's instruct ore to detect the snapshot ID from the AMI.
snapshot_id = ami.get("snapshot", "detectFromAMI")
if dry_run:
print(f"Would delete {ami_id} and {snapshot_id} for {build.id}")
continue
Expand Down
Loading