[Updated] D8465: automation: always use latest Windows AMI

indygreg (Gregory Szorc) phabricator at mercurial-scm.org
Thu Apr 23 18:05:00 UTC 2020


Closed by commit rHG828d3277618a: automation: always use latest Windows AMI (authored by indygreg).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8465?vs=21167&id=21197

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D8465/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D8465

AFFECTED FILES
  contrib/automation/hgautomation/aws.py

CHANGE DETAILS

diff --git a/contrib/automation/hgautomation/aws.py b/contrib/automation/hgautomation/aws.py
--- a/contrib/automation/hgautomation/aws.py
+++ b/contrib/automation/hgautomation/aws.py
@@ -59,7 +59,7 @@
 UBUNTU_ACCOUNT_ID = '099720109477'
 
 
-WINDOWS_BASE_IMAGE_NAME = 'Windows_Server-2019-English-Full-Base-2019.11.13'
+WINDOWS_BASE_IMAGE_NAME = 'Windows_Server-2019-English-Full-Base-*'
 
 
 KEY_PAIRS = {
@@ -464,7 +464,7 @@
             profile.add_role(RoleName=role)
 
 
-def find_image(ec2resource, owner_id, name):
+def find_image(ec2resource, owner_id, name, reverse_sort_field=None):
     """Find an AMI by its owner ID and name."""
 
     images = ec2resource.images.filter(
@@ -476,6 +476,13 @@
         ]
     )
 
+    if reverse_sort_field:
+        images = sorted(
+            images,
+            key=lambda image: getattr(image, reverse_sort_field),
+            reverse=True,
+        )
+
     for image in images:
         return image
 
@@ -1059,7 +1066,7 @@
 
 
 def ensure_windows_dev_ami(
-    c: AWSConnection, prefix='hg-', base_image_name=WINDOWS_BASE_IMAGE_NAME
+    c: AWSConnection, prefix='hg-', base_image_name=WINDOWS_BASE_IMAGE_NAME,
 ):
     """Ensure Windows Development AMI is available and up-to-date.
 
@@ -1078,7 +1085,12 @@
 
     name = '%s%s' % (prefix, 'windows-dev')
 
-    image = find_image(ec2resource, AMAZON_ACCOUNT_ID, base_image_name)
+    image = find_image(
+        ec2resource,
+        AMAZON_ACCOUNT_ID,
+        base_image_name,
+        reverse_sort_field="name",
+    )
 
     config = {
         'BlockDeviceMappings': [



To: indygreg, #hg-reviewers, marmoute
Cc: marmoute, mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20200423/081580cc/attachment-0002.html>


More information about the Mercurial-patches mailing list