Skip to content
This repository has been archived by the owner on Feb 5, 2020. It is now read-only.

modules/vpc: support re-apply of terraform when aws AZ number changes #3092

Merged
merged 1 commit into from
Mar 14, 2018

Conversation

trawler
Copy link
Contributor

@trawler trawler commented Mar 12, 2018

No description provided.

@coreosbot
Copy link

Can one of the admins verify this patch?

@trawler
Copy link
Contributor Author

trawler commented Mar 12, 2018

ok to test

@trawler
Copy link
Contributor Author

trawler commented Mar 12, 2018

aws green

@trawler trawler force-pushed the recalc_az_subnet_if_changed branch from 8ad9c8b to 732bf75 Compare March 12, 2018 13:27
@trawler
Copy link
Contributor Author

trawler commented Mar 12, 2018

retest this please. govcloud.

@trawler trawler requested review from squat and enxebre March 12, 2018 14:58
Copy link
Contributor

@squat squat left a 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


// 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)}"
Copy link
Contributor

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)}"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

// 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 }"
Copy link
Contributor

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?

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 }"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here as well

@trawler trawler force-pushed the recalc_az_subnet_if_changed branch from 732bf75 to f828666 Compare March 14, 2018 16:40
Copy link
Contributor

@squat squat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@squat squat merged commit cf7db37 into coreos:master Mar 14, 2018
wking added a commit to wking/openshift-installer that referenced this pull request Oct 18, 2018
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.
wking added a commit to wking/openshift-installer that referenced this pull request Nov 30, 2018
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
wking added a commit to wking/openshift-installer that referenced this pull request Oct 1, 2019
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.
jhixson74 pushed a commit to jhixson74/installer that referenced this pull request Dec 6, 2019
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.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants