This repository has been archived by the owner on Jun 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 49
packet: improve hardware reservations support using terraform dependencies #299
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 tasks
rata
force-pushed
the
rata/packet-improve-reservations-tf-dep
branch
2 times, most recently
from
April 16, 2020 20:38
ae57e78
to
59d9d4a
Compare
invidian
suggested changes
Apr 17, 2020
assets/lokomotive-kubernetes/packet/flatcar-linux/kubernetes/workers/workers.tf
Outdated
Show resolved
Hide resolved
rata
force-pushed
the
rata/packet-improve-reservations-tf-dep
branch
from
April 20, 2020 20:39
59d9d4a
to
a34c7a5
Compare
invidian
suggested changes
Apr 21, 2020
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.
Just some nits and typos, otherwise LGTM!
assets/lokomotive-kubernetes/packet/flatcar-linux/kubernetes/controllers.tf
Outdated
Show resolved
Hide resolved
rata
force-pushed
the
rata/packet-improve-reservations-tf-dep
branch
2 times, most recently
from
April 21, 2020 21:00
9a8654f
to
7492157
Compare
invidian
suggested changes
Apr 22, 2020
assets/lokomotive-kubernetes/packet/flatcar-linux/kubernetes/controllers.tf
Outdated
Show resolved
Hide resolved
rata
force-pushed
the
rata/packet-improve-reservations-tf-dep
branch
2 times, most recently
from
April 23, 2020 15:57
61a67d4
to
6d94907
Compare
It makes the error clearer, as the pool name is quoted by go now.
This commit adds support for reserved instances, which are already supported in terraform. This patch also fixes a long standing bug where the worker pools use reservations IDs from the controller nodes, instead of workers nodes. Basically, it was totally broken. This was overseen when creating template, and the lack of tests for generated templates didn't help. Fixes: #20
This commit adds tests for the just added functions but also for existing check*() functions. Logic in these functions is getting complicated, so tests are added before it's complex (or even impossible if not split correctly) to do so.
rata
force-pushed
the
rata/packet-improve-reservations-tf-dep
branch
from
April 23, 2020 21:20
6d94907
to
b62b5be
Compare
This is ready for review again, @invidian. PTAL :) When it is ready to merge, I will create the issue mentioned in the PR description (the missing item in the TODO list) |
invidian
approved these changes
Apr 24, 2020
@invidian thanks for review and the patience while I tried different approaches! I think, however, time was well invested and the end result is quite better =) |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR supersedes #119 and adds support for hardware reservations in Packet by adding auto-generated (i.e generated automatically by lokomotive) explicit terraform dependencies.
The need to use explicit dependencies on terraform (
depends_on
) is explained in the code itself, but you can have a look at these two links for more info (also linked in the code):https://github.com/terraform-providers/terraform-provider-packet/issues/176
https://github.com/terraform-providers/terraform-provider-packet/pull/208
To guarantee that nodes with specific hw reservation UUID are created first, terraform dependencies are used and computed automatically in lokomotive. In contrast, PR #119 to achieve the same, did the following:
terraform apply -target=<nodes_to_create_first>
and then finished withterraform apply
to create the rest of the resources.The reasoning to change and rely on terraform for dependencies is simple: terraform already handles dependencies, handling them in different places is confusing and may hit several unexpected issues (as if running
terraform apply -target=<nodes_to_create_first>
we don't expect some resources to be created, but due to dependencies at the terraform layer they might be created if needed).As explained in #119, I first started with the
terraform -target
approach because it was already used for DNS provider manual in packet, seemed simple and supporting all possible combinations ofreservation_ids
andreservation_ids_default
seemed difficult otherwise. While working on #119, I decided that to support all combinations was not sane, and little by little, started to reduce the different combinations accepted. Basically, it was reduced and nowreservation_ids
andreservation_ids_default
are mutually exclusive now. With that simplification in mind, going the terraform dependencies route seems simple. This PR just goes down that route, with this simplification.There are some TODOs in the code, for things that I want to fully understand before merging, but other than that, this is pretty much functional.
Pending things: