Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding image cleanup for clouds #101

Merged
merged 3 commits into from
Aug 8, 2023

Conversation

akhil-jha
Copy link
Contributor

@akhil-jha akhil-jha commented Jun 29, 2023

Links HMS-2043


(cloudwash) ➜  cloudwash git:(support_image_removal) ✗ swach -d aws --all

<<<<<<< Running the cleanup script in DRY RUN mode >>>>>>>
The AWS providers settings are initialized and validated !

Resources from the region: us-east-1

=========== DRY SUMMARY ============

IMAGES:
	Deletable: ['ami-0ba22849118c7101a', 'ami-03d1c1aee99de0c58']

====================================

(cloudwash) ➜  cloudwash git:(support_image_removal) ✗ swach -d azure --all

<<<<<<< Running the cleanup script in DRY RUN mode >>>>>>>
The AZURE providers settings are initialized and validated !

Resources from the region and resource group: eastus/redhat-deployed

=========== DRY SUMMARY ============

DISCs:
	Deletable: ['composer-api-qwd_disk1_9556a6aca0324ac5adf7e4a700f1c09b']
NICs:
	Deletable: ['composer-api-qwd96']
IMAGES:
	Deletable: ['composer-api-985124e5-b8a9-4969-98ec-400b6af7c924']

====================================

(cloudwash) ➜  cloudwash git:(support_image_removal) ✗ swach azure --all 

<<<<<<< Running the cleanup script in ACTION RUN mode >>>>>>>
The AZURE providers settings are initialized and validated !

Resources from the region and resource group: eastus/redhat-deployed
Stopped VMs: 
[]
Removed VMs: 
[]
Skipped VMs: 
[]
Removed NICs: 
['composer-api-qwd96']
Removed Discs: 
['composer-api-qwd_disk1_9556a6aca0324ac5adf7e4a700f1c09b']
Removed PIPs: 
['composer-api-qwd-ip']
Removed Images: 
['composer-api-985124e5-b8a9-4969-98ec-400b6af7c924']

Can't run on aws as we need those images :P

@akhil-jha akhil-jha force-pushed the support_image_removal branch from be67ef6 to 870de19 Compare June 30, 2023 06:43
@akhil-jha akhil-jha force-pushed the support_image_removal branch 2 times, most recently from bab89e4 to 97e979e Compare July 26, 2023 08:57
@akhil-jha akhil-jha force-pushed the support_image_removal branch from 97e979e to ae69b21 Compare July 26, 2023 14:45
@akhil-jha akhil-jha changed the title [Draft] Adding image cleanup for clouds Adding image cleanup for clouds Jul 26, 2023
@akhil-jha
Copy link
Contributor Author

@jyejare @mshriver

@mshriver mshriver requested review from jyejare and shubhamsg199 July 26, 2023 18:58
@mshriver mshriver added the RFE New Feature Request label Jul 26, 2023
@akhil-jha akhil-jha force-pushed the support_image_removal branch from 821c7be to fe1b870 Compare July 31, 2023 09:08
@akhil-jha
Copy link
Contributor Author

swach azure --all

<<<<<<< Running the cleanup script in ACTION RUN mode >>>>>>>
The AZURE providers settings are initialized and validated !

Resources from the region and resource group: eastus/redhat-deployed
Stopped VMs: 
[]
Removed VMs: 
[]
Skipped VMs: 
[]
Removed Images: 
['composer-api-0b2a4123-68d5-4be7-9b71-e88401f90b4c', 'composer-api-48b46ce3-0e8d-42f4-ae35-f3e8a84167c3', 'composer-api-4d3c79dc-bebe-4688-971d-1baa9498c92f', 'composer-api-5181f605-0e5f-4a4e-9a9d-3f5b5de8ea7b', 'composer-api-596f8347-ea4e-447a-87b6-deff11ad6e7c', 'composer-api-5cb99b06-f685-46ba-9270-5c6cdc70401a', 'composer-api-6a46dda6-ef02-43f5-9973-1dd77a9e1578', 'composer-api-717af3b9-4c60-4f1e-be22-9af703fff0fe', 'composer-api-83731b17-41a0-446d-b56b-e56a0ddaeafd', 'composer-api-9947ab7a-5ef9-4041-bb64-316d156436cf', 'composer-api-ab2aa738-d362-4ebb-8388-9ab5c62d9a69', 'composer-api-c544f5c2-7ab0-428e-a085-fad79c1c559e', 'composer-api-d821a29f-c06d-442e-ad1c-df5b36464bff', 'composer-api-d942293b-1a80-4516-9f43-b08892a4acd7', 'composer-api-daf2fb61-8621-49ca-867e-1e75af0c2e41', 'composer-api-e2ee5537-a969-4d33-bf2b-7b34a4bc8501', 'composer-api-e471154d-50bf-4899-8c86-dbb5f3d522a6', 'composer-api-e4fadca4-41ab-4323-ba38-d8ff8421115a', 'composer-api-fc0d890a-896c-489b-892a-6ba136d940d3', 'composer-api-fed68239-5d7e-43f8-ab89-003fedd25e81']
(cloudwash) ➜  cloudwash git:(support_image_removal) ✗ swach -d aws --all

<<<<<<< Running the cleanup script in DRY RUN mode >>>>>>>
The AWS providers settings are initialized and validated !

Resources from the region: us-east-1

=========== DRY SUMMARY ============

IMAGES:
	Deletable: ['ami-03d1c1aee99de0c58', 'ami-0ba22849118c7101a']

====================================


Comment on lines 63 to 72
remove_images = [
image
for image in free_images
if image not in settings.aws.exceptions.images
]
if settings.aws.criteria.image.delete_pattern:
remove_images = [
image
for image in remove_images
if not image.startswith(settings.aws.criteria.image.delete_pattern)
Copy link
Collaborator

@shubhamsg199 shubhamsg199 Aug 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar can be done to azure

Suggested change
remove_images = [
image
for image in free_images
if image not in settings.aws.exceptions.images
]
if settings.aws.criteria.image.delete_pattern:
remove_images = [
image
for image in remove_images
if not image.startswith(settings.aws.criteria.image.delete_pattern)
if settings.aws.criteria.image.delete_pattern:
remove_images = [
image
for image in free_images
if image.startswith(settings.aws.criteria.image.delete_pattern) and image not in exception_images

Copy link
Collaborator

@jyejare jyejare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK pending comments!

cloudwash/providers/azure.py Show resolved Hide resolved
cloudwash/providers/azure.py Outdated Show resolved Hide resolved
cloudwash/providers/azure.py Outdated Show resolved Hide resolved
@akhil-jha akhil-jha force-pushed the support_image_removal branch from fe1b870 to f366146 Compare August 3, 2023 09:04
@akhil-jha akhil-jha requested review from jyejare and mshriver August 3, 2023 09:09
@dpulls
Copy link

dpulls bot commented Aug 7, 2023

🎉 All dependencies have been resolved !

@jyejare jyejare merged commit 7a68770 into RedHatQE:master Aug 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFE New Feature Request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants