-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Transition to Terraform 0.12 for installer #1739
Transition to Terraform 0.12 for installer #1739
Conversation
using this to get initial testing feedback. |
f2f289f
to
806257a
Compare
/test e2e-libvirt |
/retest |
/test e2e-libvirt |
Terraform community is getting ready for 0.12 release that introduces wide variety of improvements in the language and fixes a lot of the subtle plan and apply bugs. see here [1] for official announcement New platforms like Azure require that installer moves to 0.12 version of terraform as it provides the required `dynamic` blocks in HCL2 [2]. For example, Azure `dns_srv` record requires use of `foreach` to create dynamic count of records for control plane [3]. `RHHI` platform owners have also requested 0.12 terraform version to simplify their terraform templates. Therefore, moving the installer to 0.12-rc.1 sets us up to switch to final release of 0.12 which is very close [4]. This commit, - moves the vendored copy to v0.12.0-rc1 [5] tag revision. - expands the list of required packages from terraform helper packages as these are required by newer terraform-providers - dep is sadly unsuccesful in understanding the correct version for the indirect dependencies, and therefore it was required to add overrides for faulty vendored packages based on upstream go.mod [6] ang go.sum [7] [1]: https://www.hashicorp.com/resources/introducing-terraform-0-12 [2]: https://www.terraform.io/upgrade-guides/0-12.html#attributes-vs-blocks [3]: https://github.com/openshift/installer/pull/1454/files#diff-764adb23dcc0edbbebc09192eb233e9aR46 [4]: https://github.com/hashicorp/terraform/pulls?q=is%3Aopen+is%3Apr+milestone%3Av0.12.0 [5]: https://github.com/hashicorp/terraform/releases/tag/v0.12.0-rc1 [6]: https://github.com/hashicorp/terraform/blob/v0.12.0-rc1/go.mod [7]: https://github.com/hashicorp/terraform/blob/v0.12.0-rc1/go.sum
21292a0
to
c415758
Compare
/test e2e-libvirt |
c415758
to
72c47b0
Compare
The `terraform 0.12upgrade` commands left certain template file in a little undesired format. This commit uses combination of manually fixing the formating and `terraform fmt -recursive .` to fix the formatting for templates.
…g lists Terraform 0.12 language no longer performs the float -> int conversion when indexing on lists. floor [2] function should be used to explicity convert float to int. [1]: https://www.terraform.io/upgrade-guides/0-12.html#integer-vs-float-number-types [2]: https://www.terraform.io/docs/configuration/functions/floor.html
With addition of first-class expressions [1] to language in 0.12, list no longer need to be wrapped in `[]`. As a side-effect, wrapping lists creates a 2-d list and fails validation of a list of string for variables. Therefore, all outputs and variables that are already lists were updated to [2] [1]: https://www.terraform.io/upgrade-guides/0-12.html#first-class-expressions [2]: https://www.terraform.io/upgrade-guides/0-12.html#referring-to-list-variables
Terraform 0.12 adds dynamic blocks [1] [2] to the language specification. This commit updates the network resource to use dynamic blocks for srvs and hosts in dns block. [1]: https://www.terraform.io/upgrade-guides/0-12.html#attributes-vs-blocks [2]: https://www.hashicorp.com/blog/hashicorp-terraform-0-12-preview-for-and-for-each
With terraform 0.12 `init` behavior has changed to re-use the state file when initializing. With the previous override directory set to the working directory of terraform, init would assume initializing has already occured and fail to load the state file, when it should not try to load the state file. Moving the override directory to `<working dir>/.tf` forces terraform to correctly initialize
72c47b0
to
fb9a544
Compare
/test e2e-libvirt |
Installer [1] is in progress to move to terraform version 0.12, which has breaking changes for formatting. To add to that, `upi` terraform templates will be moved over to 0.12 at a later stage. Therefore marking this optional for the time being until we have moved entire code base to 0.12. [1]: openshift/installer#1739
/test e2e-aws-upgrade |
/retest |
1 similar comment
/retest |
Hoping this was a flake e2e-aws
/retest |
libvirt succeed finally 👍 |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: abhinavdahiya, zeenix The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
🥳🥳 |
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.
Terraform community is getting ready for 0.12 release that introduces wide variety of improvements in the language
and fixes a lot of the subtle plan and apply bugs. see here 1 for official announcement
New platforms like Azure require that installer moves to 0.12 version of terraform as it provides the required
dynamic
blocks in HCL2 2. For example,Azure
dns_srv
record requires use offoreach
to create dynamic count of records for control plane 3.RHHI
platform owners have also requested 0.12 terraform version tosimplify their terraform templates. Therefore, moving the installer to 0.12-rc.1 sets us up to switch to final release of 0.12 which is very close 4.
NOTE: This PR is restricted to the minimum set of changes that are required for use to move to 0.12. All work to utilize the new hcl2 specification for current templates is out of scope for this and can be done as a follow-up.
NOTE: I have also left the terraform templates in the
upi
directory for vsphere and metal as is, as we can migrate them to 0.12 at a later stage.