Fix the clean ami script to remove the amis based on date #8146

Merged
jnsamyak merged 2 commits from fix-clean-ami-script into master 2026-06-08 03:11:54 +00:00
Contributor

This fixes #8126.

Additional changes made to the script:

  • You can pass a additional params as days. Earlier it was hardcoded to 10 days. This is beneficial if the script fails to run over 10 days then we can pass the --days param.
  • Removes images which have date in them (treats them as nightly) except for the updates composes because I'm unable to find a way to filter out the 2WA released composes.

Signed-off-by: Sayan Chowdhury sayan.chowdhury2012@gmail.com

This fixes #8126. Additional changes made to the script: - You can pass a additional params as days. Earlier it was hardcoded to 10 days. This is beneficial if the script fails to run over 10 days then we can pass the `--days` param. - Removes images which have date in them (treats them as nightly) except for the updates composes because I'm unable to find a way to filter out the 2WA released composes. Signed-off-by: Sayan Chowdhury <sayan.chowdhury2012@gmail.com>
Member

days=10 is hardcoded here - is that right? I think it should be days=days

days=10 is hardcoded here - is that right? I think it should be `days=days`
Member

can we re-order these two (change perms first and then delete) and then add a nice comment about what is going on?

can we re-order these two (change perms first and then delete) and then add a nice comment about what is going on?
Member

It took me a while to figure out what is going on and I'm still not sure it's entirely right (or maybe I misunderstand).

For each AMI:

  • (2*$days < item < $days) -> DELETE
  • ($days < item < TODAY) -> CHANGE PERMISSIONS

Is that right?

It took me a while to figure out what is going on and I'm still not sure it's entirely right (or maybe I misunderstand). For each AMI: - `(2*$days < item < $days)` -> **DELETE** - `($days < item < TODAY)` -> **CHANGE PERMISSIONS** Is that right?
Author
Contributor

Here, 10 is the number of days the AMIs will stay with the changed perms.

Here, 10 is the number of days the AMIs will stay with the changed perms.
Member

This help message needs more clarity. I don't quite get exactly what value you want me to give it for days.

This help message needs more clarity. I don't quite get exactly what value you want me to give it for days.
Member

we need a comment at the beginning of this if/else that explains how we are determining which AMIs are OK to delete.

we need a comment at the beginning of this if/else that explains how we are determining which AMIs are OK to delete.
Member

actually maybe better to just explain all of the logic before any of the if statements in this function.

actually maybe better to just explain all of the logic before any of the if statements in this function.
Member
REGIONS = (          
    'us-east-1',     
    'us-west-2',     
    'us-west-1',     
    'eu-west-1',     
    'eu-central-1',  
    'ap-south-1',    
    'ap-southeast-1',
    'ap-northeast-1',
    'ap-northeast-2',
    'ap-southeast-2',
    'sa-east-1',     
)                    

Do we have more regions now?

``` REGIONS = ( 'us-east-1', 'us-west-2', 'us-west-1', 'eu-west-1', 'eu-central-1', 'ap-south-1', 'ap-southeast-1', 'ap-northeast-1', 'ap-northeast-2', 'ap-southeast-2', 'sa-east-1', ) ``` Do we have more regions now?
Author
Contributor

rebased onto e8bb003aa24db1ec202545ad378be1553e7eb7a4

rebased onto e8bb003aa24db1ec202545ad378be1553e7eb7a4
Contributor

We have nightly AMIs in two additional regions:
ca-central-1
eu-west-2

We have nightly AMIs in two additional regions: ca-central-1 eu-west-2
Author
Contributor

rebased onto 41b8936aaf72746038704b7b51542ef5367044b8

rebased onto 41b8936aaf72746038704b7b51542ef5367044b8
Author
Contributor

can we re-order these two (change perms first and then delete) and then add a nice comment about what is going on?

Done.

> can we re-order these two (change perms first and then delete) and then add a nice comment about what is going on? Done.
Contributor

Looks good to me, one minor change may required:
we might want to make NIGHTLY lowercase at pagure.io/fork/sayanchowdhury/releng@0ce51d0036/f/scripts/clean-amis.py (_95) , since result of fedfind is somewhat like this for rawhide and F30 nightly:

>>> compose_info = fedfind.release.get_release(cid='Fedora-Rawhide-20190213.n.0')
>>> print compose_info.type
nightly

Also, this won't delete any of Fedora updates and updates testing AMIs, since for both cases compose_info.label starts with Update-*

Looks good to me, one minor change may required: we might want to make NIGHTLY lowercase at https://pagure.io/fork/sayanchowdhury/releng/blob/0ce51d0036c4b779e71efdc4fdfb0e8bae369107/f/scripts/clean-amis.py#_95 , since result of fedfind is somewhat like this for rawhide and F30 nightly: ``` >>> compose_info = fedfind.release.get_release(cid='Fedora-Rawhide-20190213.n.0') >>> print compose_info.type nightly ``` Also, this won't delete any of Fedora updates and updates testing AMIs, since for both cases compose_info.label starts with Update-*
Author
Contributor

(2*$days < item < $days) -> DELETE
($days < item < TODAY) -> CHANGE PERMISSIONS

for delete, its $days-10 < item < TODAY-10 -> DELETE

> (2*$days < item < $days) -> DELETE > ($days < item < TODAY) -> CHANGE PERMISSIONS for delete, its $days-10 < item < TODAY-10 -> DELETE
Author
Contributor

Looks good to me, one minor change may required:
we might want to make NIGHTLY lowercase at pagure.io/fork/sayanchowdhury/releng@0ce51d0036/f/scripts/clean-amis.py (_95) , since result of fedfind is somewhat like this for rawhide and F30 nightly:

compose_info = fedfind.release.get_release(cid='Fedora-Rawhide-20190213.n.0')
print compose_info.type
nightly

Yeah, NIGHTLY is the variable. The value of it is nightly.

Also, this won't delete any of Fedora updates and updates testing AMIs, since for both cases compose_info.label starts with Update-*

Yes, This is to prevent from deleting the 2WA Host released AMIs. I could not find a way to distinguish from the other AMIs.

> Looks good to me, one minor change may required: > we might want to make NIGHTLY lowercase at https://pagure.io/fork/sayanchowdhury/releng/blob/0ce51d0036c4b779e71efdc4fdfb0e8bae369107/f/scripts/clean-amis.py#_95 , since result of fedfind is somewhat like this for rawhide and F30 nightly: > >>> compose_info = fedfind.release.get_release(cid='Fedora-Rawhide-20190213.n.0') > >>> print compose_info.type > nightly > Yeah, `NIGHTLY` is the variable. The value of it is `nightly`. > > Also, this won't delete any of Fedora updates and updates testing AMIs, since for both cases compose_info.label starts with Update-* Yes, This is to prevent from deleting the 2WA Host released AMIs. I could not find a way to distinguish from the other AMIs.
Contributor

Yeah, NIGHTLY is the variable. The value of it is nightly.

ah yes, missed it.

Also, this won't delete any of Fedora updates and updates testing AMIs, since for both cases compose_info.label starts with Update-*

Yes, This is to prevent from deleting the 2WA Host released AMIs. I could not find a way to distinguish from the other AMIs.

Compose ID of updates are usually Fedora-$releases-updates-$composedate and for updates-testing, it is Fedora-$releases-updates-testing-$composedate .
We do 2WA release from updates compose, so maybe we can filter out at compose ID level to remove AMIs from updates-testing?
@dustymabe WDYT

> Yeah, NIGHTLY is the variable. The value of it is nightly. ah yes, missed it. > Also, this won't delete any of Fedora updates and updates testing AMIs, since for both cases compose_info.label starts with Update-* > > Yes, This is to prevent from deleting the 2WA Host released AMIs. I could not find a way to distinguish from the other AMIs. Compose ID of updates are usually Fedora-$releases-updates-$composedate and for updates-testing, it is Fedora-$releases-updates-testing-$composedate . We do 2WA release from updates compose, so maybe we can filter out at compose ID level to remove AMIs from updates-testing? @dustymabe WDYT
Contributor

@sayanchowdhury One question for my clarity, does using topic org.fedoraproject.prod.fedimg.image.upload gets us to fetch AMIs for all desired regions we want AMIs to make private or delete or we should move to org.fedoraproject.prod.fedimg.image.publish topic where we have AMI IDs for all regions available?

@sayanchowdhury One question for my clarity, does using topic [org.fedoraproject.prod.fedimg.image.upload]( https://pagure.io/fork/sayanchowdhury/releng/blob/a7487345d6a3aa1af50acb6dad116fddd93a55c2/f/scripts/clean-amis.py#_93) gets us to fetch AMIs for all desired regions we want AMIs to make private or delete or we should move to `org.fedoraproject.prod.fedimg.image.publish` topic where we have AMI IDs for all regions available?
Author
Contributor

Yeah, NIGHTLY is the variable. The value of it is nightly.

ah yes, missed it.

Also, this won't delete any of Fedora updates and updates testing AMIs, since for both cases compose_info.label starts with Update-*
Yes, This is to prevent from deleting the 2WA Host released AMIs. I could not find a way to distinguish from the other AMIs.

Compose ID of updates are usually Fedora-$releases-updates-$composedate and for updates-testing, it is Fedora-$releases-updates-testing-$composedate .
We do 2WA release from updates compose, so maybe we can filter out at compose ID level to remove AMIs from updates-testing?
@dustymabe WDYT

We can do this. But still updates composes would stay.

> > Yeah, NIGHTLY is the variable. The value of it is nightly. > > ah yes, missed it. > > Also, this won't delete any of Fedora updates and updates testing AMIs, since for both cases compose_info.label starts with Update-* > Yes, This is to prevent from deleting the 2WA Host released AMIs. I could not find a way to distinguish from the other AMIs. > > Compose ID of updates are usually Fedora-$releases-updates-$composedate and for updates-testing, it is Fedora-$releases-updates-testing-$composedate . > We do 2WA release from updates compose, so maybe we can filter out at compose ID level to remove AMIs from updates-testing? > @dustymabe WDYT We can do this. But still updates composes would stay.
Member

Let's define a new variable at the top of the script (WAIT_PERIOD=10)

Let's define a new variable at the top of the script (`WAIT_PERIOD=10`)
Member

i'm not sure if we should use days here at all. we basically want any AMIs that have had launch permissions removed for more than 10 days right? I almost wonder if we should be using fedmsg at all and not pure ec2 commands for this.

i'm not sure if we should use `days` here at all. we basically want any AMIs that have had launch permissions removed for more than 10 days right? I almost wonder if we should be using fedmsg at all and not pure ec2 commands for this.
Member

we should be able to remove updates-testing AMIs IMHO. Can we use any other identifying information?

looks like @sinnykumari already said this above :) - sorry @sinnykumari

we should be able to remove updates-testing AMIs IMHO. Can we use any other identifying information? looks like @sinnykumari already said this above :) - sorry @sinnykumari - [updates compose metadata](https://kojipkgs.fedoraproject.org/compose/updates/Fedora-29-updates-20190221.0/compose/metadata/composeinfo.json) - [updates-testing compose metadata](https://kojipkgs.fedoraproject.org/compose/updates/Fedora-29-updates-testing-20190221.0/compose/metadata/composeinfo.json)
Member

If I upload an AMI today and this gets run today does that AMI get its launch permissions removed?

If I upload an AMI today and this gets run today does that AMI get its launch permissions removed?
Author
Contributor

rebased onto 6a46caca939ed6620d2ed022b5b4bcbb097093a7

rebased onto 6a46caca939ed6620d2ed022b5b4bcbb097093a7
Author
Contributor

rebased onto 731affa16d9b413f1539a475d23b9180a2df87bc

rebased onto 731affa16d9b413f1539a475d23b9180a2df87bc
Author
Contributor

rebased onto d41e4dabfbd4734f828decae3e3dadffbdaed7d7

rebased onto d41e4dabfbd4734f828decae3e3dadffbdaed7d7
Author
Contributor

@dustymabe I fixed the issue that you pointed out. Now AMIs $((today-5)-$days) < item < $(today-5) will be deleted.

@dustymabe I fixed the issue that you pointed out. Now AMIs $((today-5)-$days) < item < $(today-5) will be deleted.
Author
Contributor

Since the AMIs will be deleted after 10 days, so the $(today-15)-days < item < today -15

Since the AMIs will be deleted after 10 days, so the $(today-15)-days < item < today -15
Member

The benefit of using this doesn't seem to be worth it to me. We define more twice and we call it twice and all but one argument is static. Let's just call get_page() instead rather than making readers lookup what functools.partial does?

The benefit of using this doesn't seem to be worth it to me. We define more twice and we call it twice and all but one argument is static. Let's just call get_page() instead rather than making readers lookup what `functools.partial` does?
Member

add comment above this.

add comment above this.
Member

why should we include AMIs that have the date in them? What does it mean if they do have the date in them?

why should we include AMIs that have the date in them? What does it mean if they do have the date in them?
Member

What does this mean? Add comment

What does this mean? Add comment
Member

these should be useful for the dry-run case, no?

these should be useful for the dry-run case, no?
Member

Here are some slight modifications that would make this more useful I think:

diff --git a/scripts/clean-amis.py b/scripts/clean-amis.py
index 31d069c..b518089 100755
--- a/scripts/clean-amis.py
+++ b/scripts/clean-amis.py
@@ -265,8 +265,16 @@ if __name__ == '__main__':
         help="Delete the AMIs whose launch permissions have been removed",
         action="store_true", default=False)
     argument_parser.add_argument(
-        "--days",
-        help="Specify the number of days to run the operation",
+        "--howfarback",
+        help="How far back should we search for AMIs that need to be deleted",
+        type=int)
+    argument_parser.add_argument(
+        "--deletewaitperiod",
+        help="How long to wait after launch perms were removed before deleting",
+        type=int)
+    argument_parser.add_argument(
+        "--permswaitperiod",
+        help="Specify the number of days to wait before removing permissions",
         type=int)
     argument_parser.add_argument(
         "--change-perms",
@@ -284,9 +292,22 @@ if __name__ == '__main__':
     if args.delete and args.change_perms:
         print('Both the argument delete and change permission is not allowed')
 
-    days = 10
-    if args.days:
-        days = args.days
+    # Default to waiting 10 days after launch permissions have been
+    # removed before deleting
+    deletewaitperiod = 10
+    if args.deletewaitperiod:
+        deletewaitperiod
+
+    permswaitperiod = 10
+    if args.permswaitperiod:
+        permswaitperiod = args.permswaitperiod
+
+    # Ideally we could search through all the AMIs that ever were
+    # created but this would create quite the load on datagrepper.
+    # default to 4 weeks
+    howfarback = 28 # 4 weeks
+    if args.howfarback:
+        howfarback = args.howfarback
 
     # The AMIs deleted are the nightly AMIs that are uploaded via fedimg everyday.
     # The clean up of the AMIs happens through a cron job.
@@ -296,12 +317,20 @@ if __name__ == '__main__':
     # - If no issues are reported in 10 days, the AMIs are deleted permanently.
 
     if args.change_perms:
-        end = (datetime.now() - timedelta(days=5)).strftime('%s')
-        amis = _get_nightly_amis_nd(delta=86400 * days, end=int(end))
+        if howfarback < permswaitperiod:
+            raise Exception # shouldn't happen
+        end = (datetime.now() - timedelta(days=permswaitperiod)).strftime('%s')
+        amis = _get_nightly_amis_nd(delta=86400 * howfarback, end=int(end))
         change_amis_permission_nd(amis, dry_run=args.dry_run)
 
     if args.delete:
-        end = (datetime.now() - timedelta(days=15)).strftime('%s')
-        amis = _get_nightly_amis_nd(delta=86400 * days, end=int(end))
+        if howfarback < deletewaitperiod:
+            raise Exception # shouldn't happen
+        end = (datetime.now() - timedelta(days=deletewaitperiod)).strftime('%s')
+        amis = _get_nightly_amis_nd(delta=86400 * howfarback, end=int(end))
+        # Here we need to see how long it's been since we removed the
+        # permissions. If it has been deletewaitperiod days then we can
+        # delete. If there is no way to tell this organically then we
+        # could add a tag to the AMI with a timestamp at the same time
+        # we remove the permissions.
         delete_amis_nd(amis, dry_run=args.dry_run)
-

note the comment about possibly using tags set on the AMIs to determine when
the launch permissions were removed.

Here are some slight modifications that would make this more useful I think: ```patch diff --git a/scripts/clean-amis.py b/scripts/clean-amis.py index 31d069c..b518089 100755 --- a/scripts/clean-amis.py +++ b/scripts/clean-amis.py @@ -265,8 +265,16 @@ if __name__ == '__main__': help="Delete the AMIs whose launch permissions have been removed", action="store_true", default=False) argument_parser.add_argument( - "--days", - help="Specify the number of days to run the operation", + "--howfarback", + help="How far back should we search for AMIs that need to be deleted", + type=int) + argument_parser.add_argument( + "--deletewaitperiod", + help="How long to wait after launch perms were removed before deleting", + type=int) + argument_parser.add_argument( + "--permswaitperiod", + help="Specify the number of days to wait before removing permissions", type=int) argument_parser.add_argument( "--change-perms", @@ -284,9 +292,22 @@ if __name__ == '__main__': if args.delete and args.change_perms: print('Both the argument delete and change permission is not allowed') - days = 10 - if args.days: - days = args.days + # Default to waiting 10 days after launch permissions have been + # removed before deleting + deletewaitperiod = 10 + if args.deletewaitperiod: + deletewaitperiod + + permswaitperiod = 10 + if args.permswaitperiod: + permswaitperiod = args.permswaitperiod + + # Ideally we could search through all the AMIs that ever were + # created but this would create quite the load on datagrepper. + # default to 4 weeks + howfarback = 28 # 4 weeks + if args.howfarback: + howfarback = args.howfarback # The AMIs deleted are the nightly AMIs that are uploaded via fedimg everyday. # The clean up of the AMIs happens through a cron job. @@ -296,12 +317,20 @@ if __name__ == '__main__': # - If no issues are reported in 10 days, the AMIs are deleted permanently. if args.change_perms: - end = (datetime.now() - timedelta(days=5)).strftime('%s') - amis = _get_nightly_amis_nd(delta=86400 * days, end=int(end)) + if howfarback < permswaitperiod: + raise Exception # shouldn't happen + end = (datetime.now() - timedelta(days=permswaitperiod)).strftime('%s') + amis = _get_nightly_amis_nd(delta=86400 * howfarback, end=int(end)) change_amis_permission_nd(amis, dry_run=args.dry_run) if args.delete: - end = (datetime.now() - timedelta(days=15)).strftime('%s') - amis = _get_nightly_amis_nd(delta=86400 * days, end=int(end)) + if howfarback < deletewaitperiod: + raise Exception # shouldn't happen + end = (datetime.now() - timedelta(days=deletewaitperiod)).strftime('%s') + amis = _get_nightly_amis_nd(delta=86400 * howfarback, end=int(end)) + # Here we need to see how long it's been since we removed the + # permissions. If it has been deletewaitperiod days then we can + # delete. If there is no way to tell this organically then we + # could add a tag to the AMI with a timestamp at the same time + # we remove the permissions. delete_amis_nd(amis, dry_run=args.dry_run) - ``` note the comment about possibly using tags set on the AMIs to determine when the launch permissions were removed.
Member

any updates for today for me to review?

any updates for today for me to review?
Author
Contributor

1 new commit added

  • Tmp commit
**1 new commit added** * ``Tmp commit``
Author
Contributor

rebased onto 95aca465273674f9b47c12160c620a317fe02d72

rebased onto 95aca465273674f9b47c12160c620a317fe02d72
Author
Contributor

rebased onto 28179f2189a3dd32b5b2cfefa9a12d476f413139

rebased onto 28179f2189a3dd32b5b2cfefa9a12d476f413139
Author
Contributor

rebased onto 2d0a536a680e1899acccad7a2e22bd8ac22d4efc

rebased onto 2d0a536a680e1899acccad7a2e22bd8ac22d4efc
Author
Contributor

rebased onto 68aafd7315ccbfa5f51215b1a5a6db26b6bafa06

rebased onto 68aafd7315ccbfa5f51215b1a5a6db26b6bafa06
Author
Contributor

rebased onto 9beff8aacd778409a724b1845be4cb24a815668f

rebased onto 9beff8aacd778409a724b1845be4cb24a815668f
Member

Specify the number of days worth of AMI fedmsg information to fetch from datagrepper.

Specify the number of days worth of AMI fedmsg information to fetch from datagrepper.
Member

probably need to raise an exception here?

probably need to raise an exception here?
Member

I don't understand the 2nd if statement here and below for deletewaitperiod.

I don't understand the 2nd if statement here and below for deletewaitperiod.
Member

need description error message here

need description error message here
Member

Need to fix function description and arg descrition here

Need to fix function description and arg descrition here
Member

This is a tag key/value pair we are defining here right? I would do something like Key=LaunchPermissionRevoked and Value=todaystimestamp.

This is a tag key/value pair we are defining here right? I would do something like `Key=LaunchPermissionRevoked` and `Value=todaystimestamp`.
Member

this seems limiting - we will only delete images that were deleted on that day. We want to delete all the ones with permissions revoked before that day. I'm thinking we should get all images with this tag (key) and then filter the list of AMIs based on the timestamp (value).

this seems limiting - we will only delete images that were deleted on that day. We want to delete all the ones with permissions revoked *before* that day. I'm thinking we should get all images with this tag (key) and then filter the list of AMIs based on the timestamp (value).
Author
Contributor

"on or before that day" or "before that day"

"on or before that day" or "before that day"
Author
Contributor

This is when you want to delete same day images.

This is when you want to delete same day images.
Member

I don't know if I support deleting same day images but I guess it makes sense for development. The user should be able to pass --permswaitperiod 0, right? We should not need a special if statement for this.

I don't know if I support deleting same day images but I guess it makes sense for development. The user should be able to pass `--permswaitperiod 0`, right? We should not need a special if statement for this.
Member

"on or before that day" works for me if it does for you. but in general "off by one" shouldn't matter too much here.

"on or before that day" works for me if it does for you. but in general "off by one" shouldn't matter too much here.
Author
Contributor

I don't know if I support deleting same day images but I guess it makes sense for development. The user should be able to pass --permswaitperiod 0, right? We should not need a special if statement for this.

since it's 0, the if condition evaluated to false and the default value of 10 is set. And yes it's needed for development purpose.

> I don't know if I support deleting same day images but I guess it makes sense for development. The user should be able to pass --permswaitperiod 0, right? We should not need a special if statement for this. since it's 0, the if condition evaluated to false and the default value of 10 is set. And yes it's needed for development purpose.
Author
Contributor

"on or before that day" works for me if it does for you. but in general "off by one" shouldn't matter too much here.

+1

> "on or before that day" works for me if it does for you. but in general "off by one" shouldn't matter too much here. +1
Member

I don't know if I support deleting same day images but I guess it makes sense for development. The user should be able to pass --permswaitperiod 0, right? We should not need a special if statement for this.

since it's 0, the if condition evaluated to false and the default value of 10 is set. And yes it's needed for development purpose.

I see. In that case we should change things up a bit. Let's set the defaults for these values in argparse calls above and then just use args.days args.permswaitperiod and args.deletewaitperiod everywhere - WDYT?

> > I don't know if I support deleting same day images but I guess it makes sense for development. The user should be able to pass --permswaitperiod 0, right? We should not need a special if statement for this. > > since it's 0, the if condition evaluated to false and the default value of 10 is set. And yes it's needed for development purpose. I see. In that case we should change things up a bit. Let's set the defaults for these values in argparse calls above and then just use `args.days` `args.permswaitperiod` and `args.deletewaitperiod` everywhere - WDYT?
Author
Contributor

I see. In that case we should change things up a bit. Let's set the defaults for these values in argparse calls above and then just use args.days args.permswaitperiod and args.deletewaitperiod everywhere - WDYT?

Sounds good to me

> I see. In that case we should change things up a bit. Let's set the defaults for these values in argparse calls above and then just use args.days args.permswaitperiod and args.deletewaitperiod everywhere - WDYT? Sounds good to me
Author
Contributor

1 new commit added

  • Temp commit before squash
**1 new commit added** * ``Temp commit before squash``
Member

just checking - not sure what ami['Tags'] returns but i would think this should be tag.keys() and not tag.values.. Do you have an example of what tags=ami['Tags'] returns?

just checking - not sure what `ami['Tags']` returns but i would think this should be `tag.keys()` and not tag.values.. Do you have an example of what `tags=ami['Tags']` returns?
Member

i would make the function args here generic.. ie timestamp1, timestamp2 and add a description: eturns true if timestamp1 is greater than or equal to timestamp2

i would make the function args here generic.. ie timestamp1, timestamp2 and add a description: `eturns true if timestamp1 is greater than or equal to timestamp2`
Member

maybe rename the function to _timestamp_greater() the readability of the later code benefits from this

maybe rename the function to `_timestamp_greater()` the readability of the later code benefits from this
Member

this shouldn't happen. I would at least print out a warning message with information

this shouldn't happen. I would at least print out a warning message with information
Author
Contributor

just checking - not sure what ami['Tags'] returns but i would think this should be tag.keys() and not tag.values.. Do you have an example of what tags=ami['Tags'] returns?

[{'Key': 'LaunchPermissionRevoked', 'Value': '27022019'}]

List of dictionaries

> just checking - not sure what ami['Tags'] returns but i would think this should be tag.keys() and not tag.values.. Do you have an example of what tags=ami['Tags'] returns? [{'Key': 'LaunchPermissionRevoked', 'Value': '27022019'}] List of dictionaries
Author
Contributor

1 new commit added

  • Another temp commit
**1 new commit added** * ``Another temp commit``
Member

add a comment before this if statement - something like

# The revoke timestamp allows us to tell how long ago an image had permissions removed
# If the permissions have been removed for shorter than the waiting period then we can't
# delete it yet.  

maybe we should change the function to be titled is_timestamp_older()

add a comment before this if statement - something like ``` # The revoke timestamp allows us to tell how long ago an image had permissions removed # If the permissions have been removed for shorter than the waiting period then we can't # delete it yet. ``` maybe we should change the function to be titled `is_timestamp_older()`
Author
Contributor

3 new commits added

  • Another temp commit
  • Temp commit before squash
  • Fix the clean ami script to remove the amis based on date
**3 new commits added** * ``Another temp commit`` * ``Temp commit before squash`` * ``Fix the clean ami script to remove the amis based on date``
Author
Contributor

1 new commit added

  • Temp commit
**1 new commit added** * ``Temp commit``
Member

i may have given you a bug - not sure if the string can span two lines here. maybe test it and see.

i may have given you a bug - not sure if the string can span two lines here. maybe test it and see.
Member

LGTM - other than the one comment.

@sinnykumari - can you review this in the morning?

LGTM - other than the one comment. @sinnykumari - can you review this in the morning?
Author
Contributor

1 new commit added

  • Format the script with black
**1 new commit added** * ``Format the script with black``
Author
Contributor

rebased onto 9abfb34f4f2539febcb09ee4f608caae73f7e11f

rebased onto 9abfb34f4f2539febcb09ee4f608caae73f7e11f
Author
Contributor

i may have given you a bug - not sure if the string can span two lines here. maybe test it and see.

Yeah I had fixed that in the next commit.

> i may have given you a bug - not sure if the string can span two lines here. maybe test it and see. Yeah I had fixed that in the next commit.
Author
Contributor

rebased onto ba567ec22576d6304a0d6f028f2fbe7cb942ef43

rebased onto ba567ec22576d6304a0d6f028f2fbe7cb942ef43
Contributor

Note that by this method we will be able to fetch TwoWeek compose id only for recent ones (from the time we added multi-arch support in twoweek.complete fedmsg topic). If we are interested to deleting most of the older composes, then we will have to add another condition to get composeID, sample json is https://apps.fedoraproject.org/datagrepper/id?id=2018-01994496-c703-49d6-8ffc-e99afd07c406&is_raw=true&size=extra-large

Note that by this method we will be able to fetch TwoWeek compose id only for recent ones (from the time we added multi-arch support in twoweek.complete fedmsg topic). If we are interested to deleting most of the older composes, then we will have to add another condition to get composeID, sample json is https://apps.fedoraproject.org/datagrepper/id?id=2018-01994496-c703-49d6-8ffc-e99afd07c406&is_raw=true&size=extra-large
Contributor

This idea came to my mind today as well, nice to see that this is already taken care of!

This idea came to my mind today as well, nice to see that this is already taken care of!
Contributor

Added one concern above, other than that LGTM.

Added one concern above, other than that LGTM.
Author
Contributor

rebased onto 1d716c707effae0a0542a397eec5e74ab1a5beb6

rebased onto 1d716c707effae0a0542a397eec5e74ab1a5beb6
Author
Contributor

2 new commits added

  • Format the script with black
  • Fix the clean ami script to remove the amis based on date
**2 new commits added** * ``Format the script with black`` * ``Fix the clean ami script to remove the amis based on date``
Contributor

LGTM, have re-looked only into the modified content which I believe would be the "older-format fedmsg messages" section

LGTM, have re-looked only into the modified content which I believe would be the "older-format fedmsg messages" section
Member

need to set default value here

need to set default value here
Member

need to set default value here right?

need to set default value here right?
Member

can you verify that changing this from '-(\d{8}).' to "-(\d{8})." doesn't cause any problems?

can you verify that changing this from `'-(\d{8}).'` to `"-(\d{8})."` doesn't cause any problems?
Author
Contributor

1 new commit added

  • fixup! Fix the clean ami script to remove the amis based on date
**1 new commit added** * ``fixup! Fix the clean ami script to remove the amis based on date``
Contributor

Why is this seperated? Cant it be joined in the for loop below?

Why is this seperated? Cant it be joined in the for loop below?
Contributor

Use elif since same arch wont be repeated and less checks 😄

Use elif since same arch wont be repeated and less checks :smile:
Contributor

Same as above

Same as above
Member

these changes LGTM - can you address mohan's comments?

these changes LGTM - can you address mohan's comments?
Contributor

Same as the one that I asked above, why separated, rather than being the for loop below?

Same as the one that I asked above, why separated, rather than being the for loop below?
Contributor

I have no idea on how delete amis and change ami permissions work, but other than that and the above comments I made, its LGTM.

I have no idea on how delete amis and change ami permissions work, but other than that and the above comments I made, its LGTM.
Author
Contributor

No because the first query returns the number of pages. which is utilized in the next loop

No because the first query returns the number of pages. which is utilized in the next loop
Author
Contributor

1 new commit added

  • fixup! Fix the clean ami script to remove the amis based on date
**1 new commit added** * ``fixup! Fix the clean ami script to remove the amis based on date``
Member

LGTM. Let's squash and merge and then can you:

  1. do a test against dev account
  2. do a dry-run against prod account and share output with us in IRC?
LGTM. Let's squash and merge and then can you: 1. do a test against dev account 2. do a dry-run against prod account and share output with us in IRC?
Author
Contributor

rebased onto 44e1c85878

rebased onto 44e1c85878d1834fcc423fa82d5d56ca4e6abfe8
Contributor

Pull-Request has been merged by mohanboddu

Pull-Request has been merged by mohanboddu
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
4 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
releng/tickets!8146
No description provided.