-
Notifications
You must be signed in to change notification settings - Fork 266
modules/vpc: support re-apply of terraform when aws AZ number changes #3092
Conversation
Can one of the admins verify this patch? |
ok to test |
aws green |
8ad9c8b
to
732bf75
Compare
retest this please. govcloud. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great overall. Just a few small nits
modules/aws/vpc/common.tf
Outdated
|
||
// The base set of ids needs to build rest of vpc data sources | ||
// This is crux of dealing with existing vpc / new vpc incongruity | ||
vpc_id = "${local.external_vpc_mode ? var.external_vpc_id : element(concat(aws_vpc.new_vpc.*.id,list("padding")),0)}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can we remove the word padding
and leave as just ""
as in https://www.terraform.io/upgrade-guides/0-11.html#error-checking-for-output-values
otherwise, we can change this for
vpc_id = "${local.external_vpc_mode ? var.external_vpc_id : join("", aws_vpc.new_vpc.*.id)}"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
modules/aws/vpc/common.tf
Outdated
// When referencing the _ids arrays or data source arrays via count = , always use the *_count variable rather than taking the length of the list | ||
worker_subnet_ids = ["${coalescelist(aws_subnet.worker_subnet.*.id,var.external_worker_subnet_ids)}"] | ||
master_subnet_ids = ["${coalescelist(aws_subnet.master_subnet.*.id,var.external_master_subnet_ids)}"] | ||
worker_subnet_count = "${ local.external_vpc_mode ? length(var.external_worker_subnet_ids) : local.new_worker_az_count }" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am a little surprised this is not accounted for in terraform fmt. can we remove these extra whitespaces?
modules/aws/vpc/common.tf
Outdated
worker_subnet_ids = ["${coalescelist(aws_subnet.worker_subnet.*.id,var.external_worker_subnet_ids)}"] | ||
master_subnet_ids = ["${coalescelist(aws_subnet.master_subnet.*.id,var.external_master_subnet_ids)}"] | ||
worker_subnet_count = "${ local.external_vpc_mode ? length(var.external_worker_subnet_ids) : local.new_worker_az_count }" | ||
master_subnet_count = "${ local.external_vpc_mode ? length(var.external_master_subnet_ids) : local.new_master_az_count }" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and here as well
732bf75
to
f828666
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
It looks like this was (accidentally?) removed in f828666 (modules/vpc: support re-apply of terraform when AZ number changes, 2018-03-12, coreos/tectonic-installer#3092). We need to set it to spread worker subnets over the available zones.
These were added in f828666 (modules/vpc: support re-apply of terraform when AZ number changes, 2018-03-12, coreos/tectonic-installer#3092), and never seem to have had a consumer. Removing them should fix occasional flakes like [1]: level=error msg="Error: Error applying plan:\n\n1 error(s) occurred:\n\n* module.vpc.data.aws_route_table.worker[1]: data.aws_route_table.worker.1: Your query returned no results. Please change your search criteria and try again.\n\nTerraform does not automatically rollback in the face of errors.\nInstead, your Terraform state file has been partially updated with\nany resources that successfully completed. Please address the error\nabove and apply again to incrementally change your infrastructure." I've also removed the data.aws_subnet blocks, whose last consumers were removed in f828666. [1]: https://storage.googleapis.com/origin-ci-test/pr-logs/pull/openshift_installer/737/pull-ci-openshift-installer-master-e2e-aws/1789/build-log.txt
The zone-count variables date back to f828666 (modules/vpc: support re-apply of terraform when AZ number changes, 2018-03-12, coreos/tectonic-installer#3092). But with Terraform 0.12, which we've used since 64c44cd (terraform: bump the vendored version to 0.12-rc.1, 2019-05-14, openshift#1739), we have better array handling, and no longer need count variables. Similarly, there's no need for vpc_id, when we can extract that ID from data.aws_vpc.cluster_vpc.
The zone-count variables date back to f828666 (modules/vpc: support re-apply of terraform when AZ number changes, 2018-03-12, coreos/tectonic-installer#3092). But with Terraform 0.12, which we've used since 64c44cd (terraform: bump the vendored version to 0.12-rc.1, 2019-05-14, openshift#1739), we have better array handling, and no longer need count variables. Similarly, there's no need for vpc_id, when we can extract that ID from data.aws_vpc.cluster_vpc.
No description provided.