Skip to content
Snippets Groups Projects
Commit d80edcb0 authored by Gregory Szorc's avatar Gregory Szorc
Browse files

automation: make Windows base image name configurable

Since automation broke in the middle of the 5.0 release cycle,
there's a good chance it will break again in the future. While
a robust solution might be to search for all available images and
choose the newest one, it does seem useful to be able to explicitly
choose the name of the image to find and use so users can opt in
to using a different image.

This commit implements that functionality.

Differential Revision: https://phab.mercurial-scm.org/D6673
parent 8804aa6c
No related branches found
No related tags found
No related merge requests found
......@@ -1032,7 +1032,8 @@
instance.ssh_client.close()
def ensure_windows_dev_ami(c: AWSConnection, prefix='hg-'):
def ensure_windows_dev_ami(c: AWSConnection, prefix='hg-',
base_image_name=WINDOWS_BASE_IMAGE_NAME):
"""Ensure Windows Development AMI is available and up-to-date.
If necessary, a modern AMI will be built by starting a temporary EC2
......@@ -1050,7 +1051,7 @@
name = '%s%s' % (prefix, 'windows-dev')
image = find_image(ec2resource, AMAZON_ACCOUNT_ID, WINDOWS_BASE_IMAGE_NAME)
image = find_image(ec2resource, AMAZON_ACCOUNT_ID, base_image_name)
config = {
'BlockDeviceMappings': [
......@@ -1103,6 +1104,7 @@
'user_data': WINDOWS_USER_DATA,
'initial_bootstrap': WINDOWS_BOOTSTRAP_POWERSHELL,
'bootstrap_commands': commands,
'base_image_name': base_image_name,
})
existing_image = find_and_reconcile_image(ec2resource, name, fingerprint)
......
......@@ -52,5 +52,5 @@
aws.ensure_linux_dev_ami(c, distro=distro)
def bootstrap_windows_dev(hga: HGAutomation, aws_region):
def bootstrap_windows_dev(hga: HGAutomation, aws_region, base_image_name):
c = hga.aws_connection(aws_region)
......@@ -56,5 +56,5 @@
c = hga.aws_connection(aws_region)
image = aws.ensure_windows_dev_ami(c)
image = aws.ensure_windows_dev_ami(c, base_image_name=base_image_name)
print('Windows development AMI available as %s' % image.id)
......@@ -58,5 +58,6 @@
print('Windows development AMI available as %s' % image.id)
def build_inno(hga: HGAutomation, aws_region, arch, revision, version):
def build_inno(hga: HGAutomation, aws_region, arch, revision, version,
base_image_name):
c = hga.aws_connection(aws_region)
......@@ -62,5 +63,5 @@
c = hga.aws_connection(aws_region)
image = aws.ensure_windows_dev_ami(c)
image = aws.ensure_windows_dev_ami(c, base_image_name=base_image_name)
DIST_PATH.mkdir(exist_ok=True)
with aws.temporary_windows_dev_instances(c, image, 't3.medium') as insts:
......@@ -74,5 +75,6 @@
version=version)
def build_wix(hga: HGAutomation, aws_region, arch, revision, version):
def build_wix(hga: HGAutomation, aws_region, arch, revision, version,
base_image_name):
c = hga.aws_connection(aws_region)
......@@ -78,5 +80,5 @@
c = hga.aws_connection(aws_region)
image = aws.ensure_windows_dev_ami(c)
image = aws.ensure_windows_dev_ami(c, base_image_name=base_image_name)
DIST_PATH.mkdir(exist_ok=True)
with aws.temporary_windows_dev_instances(c, image, 't3.medium') as insts:
......@@ -89,5 +91,6 @@
DIST_PATH, version=version)
def build_windows_wheel(hga: HGAutomation, aws_region, arch, revision):
def build_windows_wheel(hga: HGAutomation, aws_region, arch, revision,
base_image_name):
c = hga.aws_connection(aws_region)
......@@ -93,5 +96,5 @@
c = hga.aws_connection(aws_region)
image = aws.ensure_windows_dev_ami(c)
image = aws.ensure_windows_dev_ami(c, base_image_name=base_image_name)
DIST_PATH.mkdir(exist_ok=True)
with aws.temporary_windows_dev_instances(c, image, 't3.medium') as insts:
......@@ -104,5 +107,5 @@
def build_all_windows_packages(hga: HGAutomation, aws_region, revision,
version):
version, base_image_name):
c = hga.aws_connection(aws_region)
......@@ -108,5 +111,5 @@
c = hga.aws_connection(aws_region)
image = aws.ensure_windows_dev_ami(c)
image = aws.ensure_windows_dev_ami(c, base_image_name=base_image_name)
DIST_PATH.mkdir(exist_ok=True)
with aws.temporary_windows_dev_instances(c, image, 't3.medium') as insts:
......@@ -169,5 +172,5 @@
def run_tests_windows(hga: HGAutomation, aws_region, instance_type,
python_version, arch, test_flags):
python_version, arch, test_flags, base_image_name):
c = hga.aws_connection(aws_region)
......@@ -173,5 +176,5 @@
c = hga.aws_connection(aws_region)
image = aws.ensure_windows_dev_ami(c)
image = aws.ensure_windows_dev_ami(c, base_image_name=base_image_name)
with aws.temporary_windows_dev_instances(c, image, instance_type,
disable_antivirus=True) as insts:
......@@ -217,6 +220,11 @@
'bootstrap-windows-dev',
help='Bootstrap the Windows development environment',
)
sp.add_argument(
'--base-image-name',
help='AMI name of base image',
default=aws.WINDOWS_BASE_IMAGE_NAME,
)
sp.set_defaults(func=bootstrap_windows_dev)
sp = subparsers.add_parser(
......@@ -232,6 +240,11 @@
'--version',
help='Mercurial version string to use',
)
sp.add_argument(
'--base-image-name',
help='AMI name of base image',
default=aws.WINDOWS_BASE_IMAGE_NAME,
)
sp.set_defaults(func=build_all_windows_packages)
sp = subparsers.add_parser(
......@@ -254,6 +267,11 @@
'--version',
help='Mercurial version string to use in installer',
)
sp.add_argument(
'--base-image-name',
help='AMI name of base image',
default=aws.WINDOWS_BASE_IMAGE_NAME,
)
sp.set_defaults(func=build_inno)
sp = subparsers.add_parser(
......@@ -272,6 +290,11 @@
help='Mercurial revision to build',
default='.',
)
sp.add_argument(
'--base-image-name',
help='AMI name of base image',
default=aws.WINDOWS_BASE_IMAGE_NAME,
)
sp.set_defaults(func=build_windows_wheel)
sp = subparsers.add_parser(
......@@ -294,6 +317,11 @@
'--version',
help='Mercurial version string to use in installer',
)
sp.add_argument(
'--base-image-name',
help='AMI name of base image',
default=aws.WINDOWS_BASE_IMAGE_NAME,
)
sp.set_defaults(func=build_wix)
sp = subparsers.add_parser(
......@@ -368,6 +396,11 @@
'--test-flags',
help='Extra command line flags to pass to run-tests.py',
)
sp.add_argument(
'--base-image-name',
help='AMI name of base image',
default=aws.WINDOWS_BASE_IMAGE_NAME,
)
sp.set_defaults(func=run_tests_windows)
return parser
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment