Disable ec2 mirror for non aws instances#390
Conversation
blackboxsw
left a comment
There was a problem hiding this comment.
I think we may need to revisit this and have a discussion.
I'm actually not certain that this bug is valid anymore.
the %(ec2_region)s mirror lines should have failed to be included on any cloud platform unless their region names happened to be something like eu-west-[0-9][a-z]
because we would have raised a KeyError (and continued instead of appending)
That said, I think we can still cleanup the platform_type matching using your platform_type == "ec2" and then provide such ec2_region and region keys.
One other thing I'm thinking about is that ubuntu cloudimage for azure adds the following custom config
primary:
- http://azure.archive.ubuntu.com/ubuntu/
so I wonder if it's worth considering adding a %(platform)s.archive.ubuntu.com as well as adapting the original %(ec2_region)s.%(platform)s.archive.ubuntu,com
| # list of mirrors to try to resolve | ||
| mirror = util.search_for_mirror(mcfg.get("search", None)) | ||
| search_mirrors = None | ||
| params = {'REGION': cloud.datasource.region} |
There was a problem hiding this comment.
I think I'd like to reject this 'feature' to provide REGION magic template string in user cloud-config. I'd like to support one-way to do things, and that's with jinja templates which already provide this feature. We should instead add a documentation example to this json schema definition that shows how to do this
Without a magic REGION template string , a user can override this on their instance by providing the following cloud-config:
#template: jinja
#cloud-config
apt:
primary:
- arches: [default]
search:
- http://{{ region }}.ec2.archive.ubuntu.com/ubuntu/
| if (ALLOW_EC2_MIRRORS_ON_NON_AWS_INSTANCE_TYPES | ||
| and data_source.platform_type == "ec2"): | ||
| subst['ec2_region'] = "%s" % ec2_region | ||
| elif not ALLOW_EC2_MIRRORS_ON_NON_AWS_INSTANCE_TYPES: |
There was a problem hiding this comment.
This elif is incorrect isn't it? We only want to set subst[ec2_region'] if any([ data_source.platform_type == "ec2", ALLOW_EC2_MIRRORS_ON_NON_AWS_INSTANCE_TYPES] ?
There was a problem hiding this comment.
Yes, it is incorrect 🤦 I will update the logic to fix this
| @@ -845,7 +848,13 @@ def _get_package_mirror_info(mirror_info, data_source=None, | |||
| # ec2 availability zones are named cc-direction-[0-9][a-d] (us-east-1b) | |||
| # the region is us-east-1. so region = az[0:-1] | |||
| if _EC2_AZ_RE.match(data_source.availability_zone): | |||
There was a problem hiding this comment.
I think maybe we can just drop this re.match and instead just specificall check data_source.platform_type == "ec2".
There was a problem hiding this comment.
But wouldn't that interfere with past release ? We would like to have past releases still being able to user ec2 mirrors, right ?
There was a problem hiding this comment.
You are right, darn backward compatibility.
|
Hello! Thank you for this proposed change to cloud-init. This pull request is now marked as stale as it has not seen any activity in 14 days. If no activity occurs within the next 7 days, this pull request will automatically close. If you are waiting for code review and you are seeing this message, apologies! Please reply, tagging powersj, and he will ensure that someone takes a look soon. (If the pull request is closed, please do feel free to reopen it if you wish to continue working on it.) |
6d59994 to
0cf79cd
Compare
|
@blackboxsw I have update the PR with the suggested changes. There is just some things that I have some doubts about:
|
blackboxsw
left a comment
There was a problem hiding this comment.
Thank @lucasmoura minor text update request (or something similar to the suggestion). Also can you please update the description of the PR to the commit message you would like to see when we squash merge this branch?
| @@ -845,7 +848,13 @@ def _get_package_mirror_info(mirror_info, data_source=None, | |||
| # ec2 availability zones are named cc-direction-[0-9][a-d] (us-east-1b) | |||
| # the region is us-east-1. so region = az[0:-1] | |||
| if _EC2_AZ_RE.match(data_source.availability_zone): | |||
There was a problem hiding this comment.
You are right, darn backward compatibility.
| the use of ec2 mirrors if the user region matches one | ||
| of the possible aws regions. We are now updating that to only | ||
| the use of ec2 mirror for aws instances, unless the user specifically | ||
| sets that on the userdata config. |
There was a problem hiding this comment.
| the use of ec2 mirrors if the user region matches one | |
| of the possible aws regions. We are now updating that to only | |
| the use of ec2 mirror for aws instances, unless the user specifically | |
| sets that on the userdata config. | |
| the use of ec2 mirrors if the datasource availability_zone format | |
| matches one of the possible aws ec2 regions. After the 20.2 release, we | |
| no longer publish ec2 region mirror urls on non-AWS cloud platforms. | |
| Besides feature_overrides.py, users can override this by providing | |
| #cloud-config apt directives. |
|
@blackboxsw Done, I have updated both descriptions |
For versions before 20.2, we allowed the use of ec2 mirrors if the datasource availability_zone matches one of the ec2 regions. We are now updating that behavior to allow allow the use of ec2 mirrors on ec2 instances or if the user directly passes an an ec2 mirror url through #cloud-config apt directives.
LP: #1456277