Skip to content

Commit 611400b

Browse files
authored
fix: dependency issues in deploy module (#128)
Signed-off-by: matttrach <[email protected]>
1 parent 201f75e commit 611400b

File tree

9 files changed

+72
-264
lines changed

9 files changed

+72
-264
lines changed

.github/workflows/release.yaml

Lines changed: 8 additions & 243 deletions
Large diffs are not rendered by default.

examples/downstream/modules/downstream/main.tf

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,26 @@ locals {
1515
subnet_id = var.subnet_id
1616
security_group_id = var.security_group_id
1717
lbsg = sort(var.load_balancer_security_groups)
18+
# load balancers only have 2 security groups, the project and its own
19+
# this eliminates the project security group to just return the load balancer's security group
1820
load_balancer_security_group_id = [
1921
for i in range(length(local.lbsg)) :
2022
local.lbsg[i] if local.lbsg[i] != local.security_group_id
21-
# load balancers only have 2 security groups, the project and its own
22-
# this eliminates the project security group to just return the load balancer's security group
2323
][0]
2424
downstream_security_group_name = "${local.cluster_name}-sgroup"
2525
# node info
2626
aws_instance_type = var.aws_instance_type
2727
ami_id = var.ami_id
2828
ami_ssh_user = var.ami_ssh_user
2929
node_count = var.node_count
30-
node_ips = { for i in range(local.node_count) : tostring(i) => data.aws_instances.rke2_instance_nodes.public_ips[i] }
31-
node_id = "${local.cluster_name}-nodes"
32-
ami_admin_group = (var.ami_admin_group != "" ? var.ami_admin_group : "tty")
33-
runner_ip = (var.direct_node_access != null ? var.direct_node_access.runner_ip : "10.1.1.1") # the IP running Terraform
34-
ssh_access_key = (var.direct_node_access != null ? var.direct_node_access.ssh_access_key : "fake123abc")
35-
ssh_access_user = (var.direct_node_access != null ? var.direct_node_access.ssh_access_user : "fake")
30+
# if the IPs aren't found, then this should fail
31+
node_ips = { for i in range(local.node_count) : tostring(i) => data.aws_instances.rke2_instance_nodes.public_ips[i] }
32+
node_id = "${local.cluster_name}-nodes"
33+
node_wait_time = "${tostring(local.node_count * 60)}s" # 60 seconds per node
34+
ami_admin_group = (var.ami_admin_group != "" ? var.ami_admin_group : "tty")
35+
runner_ip = (var.direct_node_access != null ? var.direct_node_access.runner_ip : "10.1.1.1") # the IP running Terraform
36+
ssh_access_key = (var.direct_node_access != null ? var.direct_node_access.ssh_access_key : "fake123abc")
37+
ssh_access_user = (var.direct_node_access != null ? var.direct_node_access.ssh_access_user : "fake")
3638
# rke2 info
3739
rke2_version = var.rke2_version
3840
}
@@ -207,7 +209,7 @@ resource "time_sleep" "wait_for_nodes" {
207209
rancher2_machine_config_v2.all_in_one,
208210
terraform_data.patch_machine_configs,
209211
]
210-
create_duration = "120s"
212+
create_duration = local.node_wait_time
211213
}
212214

213215
data "aws_instances" "rke2_instance_nodes" {

examples/downstream_splitrole/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ locals {
4141
email = (var.email != "" ? var.email : "${local.identifier}@${local.zone}")
4242
helm_chart_values = {
4343
"hostname" = "${local.domain}.${local.zone}"
44-
"replicas" = "1"
44+
"replicas" = "1" # because we are only deploying one Rancher node
4545
"bootstrapPassword" = "admin"
4646
"ingress.enabled" = "true"
4747
"ingress.tls.source" = "letsEncrypt"

examples/downstream_splitrole/modules/downstream/main.tf

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ locals {
1616
downstream_security_group_name = var.downstream_security_group_name
1717
load_balancer_security_group_id = var.load_balancer_security_group_id
1818
# node info
19-
node_info = var.node_info
20-
node_count = sum([for i in range(length(local.node_info)) : local.node_info[keys(local.node_info)[i]].quantity])
19+
node_info = var.node_info
20+
node_count = sum([for i in range(length(local.node_info)) : local.node_info[keys(local.node_info)[i]].quantity])
21+
# if the IPs aren't found, then this should fail
2122
node_ips = { for i in range(local.node_count) : tostring(i) => data.aws_instances.rke2_instance_nodes.public_ips[i] }
2223
node_id = "${local.cluster_name}-nodes"
24+
node_wait_time = "${tostring(local.node_count * 60)}s" # 60 seconds per node
2325
runner_ip = (var.direct_node_access != null ? var.direct_node_access.runner_ip : "10.1.1.1") # the IP running Terraform
2426
ssh_access_key = (var.direct_node_access != null ? var.direct_node_access.ssh_access_key : "fake123abc")
2527
ssh_access_user = (var.direct_node_access != null ? var.direct_node_access.ssh_access_user : "fake")
@@ -118,7 +120,7 @@ resource "time_sleep" "wait_for_nodes" {
118120
rancher2_machine_config_v2.nodes,
119121
terraform_data.patch_machine_configs,
120122
]
121-
create_duration = "120s"
123+
create_duration = local.node_wait_time
122124
}
123125

124126
data "aws_instances" "rke2_instance_nodes" {

examples/prod/main.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ locals {
3232
local_file_path = var.file_path
3333
runner_ip = chomp(data.http.myip.response_body) # "runner" is the server running Terraform
3434
rancher_version = var.rancher_version
35-
cert_manager_version = "1.18.1"
35+
cert_manager_version = "1.18.3"
3636
os = "sle-micro-61"
3737
helm_chart_values = {
3838
"hostname" = "${local.domain}.${local.zone}"
@@ -88,7 +88,7 @@ module "rancher" {
8888
size = "xl"
8989
os = local.os
9090
indirect_access = false
91-
initial = true # this will set the first server as the inital node
91+
initial = true # this will set the first server as the initial node
9292
}
9393
"db2" = {
9494
type = "database"
@@ -145,15 +145,15 @@ module "rancher" {
145145
os = local.os
146146
indirect_access = true
147147
initial = false
148-
},
148+
}
149149
}
150150
# rancher
151151
cert_manager_version = local.cert_manager_version
152152
cert_use_strategy = "rancher"
153153
cert_manager_configuration = local.cert_manager_config
154154
rancher_version = local.rancher_version
155-
acme_server_url = local.acme_server_url
156155
rancher_helm_chart_values = local.helm_chart_values
156+
acme_server_url = local.acme_server_url
157157
}
158158

159159
provider "rancher2" {

modules/deploy/main.tf

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ resource "file_local_directory" "tf_data_dir" {
3939

4040
### Template Files ###
4141
data "file_local" "template_files" {
42+
depends_on = [
43+
file_local_directory.deploy_path,
44+
file_local_directory.tf_data_dir,
45+
]
4246
for_each = local.template_file_map
4347
directory = dirname(each.value)
4448
name = each.key
@@ -138,6 +142,8 @@ resource "file_local" "instantiate_envrc_snapshot" {
138142
## Deploy ##
139143
resource "file_local" "generate_destroy" {
140144
depends_on = [
145+
file_local_directory.deploy_path,
146+
file_local_directory.tf_data_dir,
141147
file_local.instantiate_envrc_snapshot,
142148
file_local.instantiate_inputs_snapshot,
143149
file_local.instantiate_tpl_snapshot,
@@ -153,6 +159,8 @@ resource "file_local" "generate_destroy" {
153159
}
154160
resource "terraform_data" "destroy" {
155161
depends_on = [
162+
file_local_directory.deploy_path,
163+
file_local_directory.tf_data_dir,
156164
file_local.instantiate_envrc_snapshot,
157165
file_local.instantiate_inputs_snapshot,
158166
file_local.instantiate_tpl_snapshot,
@@ -174,6 +182,8 @@ resource "terraform_data" "destroy" {
174182

175183
resource "file_local" "generate_create" {
176184
depends_on = [
185+
file_local_directory.deploy_path,
186+
file_local_directory.tf_data_dir,
177187
file_local.instantiate_envrc_snapshot,
178188
file_local.instantiate_inputs_snapshot,
179189
file_local.instantiate_tpl_snapshot,
@@ -192,6 +202,8 @@ resource "file_local" "generate_create" {
192202
}
193203
resource "terraform_data" "create" {
194204
depends_on = [
205+
file_local_directory.deploy_path,
206+
file_local_directory.tf_data_dir,
195207
file_local.instantiate_envrc_snapshot,
196208
file_local.instantiate_inputs_snapshot,
197209
file_local.instantiate_tpl_snapshot,
@@ -215,6 +227,11 @@ resource "terraform_data" "create" {
215227

216228
resource "file_local_snapshot" "persist_state" {
217229
depends_on = [
230+
file_local_directory.deploy_path,
231+
file_local_directory.tf_data_dir,
232+
file_local.instantiate_envrc_snapshot,
233+
file_local.instantiate_inputs_snapshot,
234+
file_local.instantiate_tpl_snapshot,
218235
terraform_data.destroy,
219236
terraform_data.create,
220237
]
@@ -224,6 +241,11 @@ resource "file_local_snapshot" "persist_state" {
224241
}
225242
resource "file_local" "instantiate_state" {
226243
depends_on = [
244+
file_local_directory.deploy_path,
245+
file_local_directory.tf_data_dir,
246+
file_local.instantiate_envrc_snapshot,
247+
file_local.instantiate_inputs_snapshot,
248+
file_local.instantiate_tpl_snapshot,
227249
terraform_data.destroy,
228250
terraform_data.create,
229251
file_local_snapshot.persist_state,
@@ -235,6 +257,11 @@ resource "file_local" "instantiate_state" {
235257

236258
resource "file_local_snapshot" "persist_outputs" {
237259
depends_on = [
260+
file_local_directory.deploy_path,
261+
file_local_directory.tf_data_dir,
262+
file_local.instantiate_envrc_snapshot,
263+
file_local.instantiate_inputs_snapshot,
264+
file_local.instantiate_tpl_snapshot,
238265
terraform_data.destroy,
239266
terraform_data.create,
240267
]
@@ -244,6 +271,11 @@ resource "file_local_snapshot" "persist_outputs" {
244271
}
245272
resource "file_local" "instantiate_outputs" {
246273
depends_on = [
274+
file_local_directory.deploy_path,
275+
file_local_directory.tf_data_dir,
276+
file_local.instantiate_envrc_snapshot,
277+
file_local.instantiate_inputs_snapshot,
278+
file_local.instantiate_tpl_snapshot,
247279
terraform_data.destroy,
248280
terraform_data.create,
249281
file_local_snapshot.persist_outputs,
@@ -258,6 +290,8 @@ resource "file_local" "instantiate_outputs" {
258290
# to rebuild the template and state file before running the create script
259291
resource "terraform_data" "create_after_persist" {
260292
depends_on = [
293+
file_local_directory.deploy_path,
294+
file_local_directory.tf_data_dir,
261295
file_local.instantiate_envrc_snapshot,
262296
file_local.instantiate_inputs_snapshot,
263297
file_local.instantiate_tpl_snapshot,
@@ -281,6 +315,8 @@ resource "terraform_data" "create_after_persist" {
281315

282316
resource "terraform_data" "destroy_end" {
283317
depends_on = [
318+
file_local_directory.deploy_path,
319+
file_local_directory.tf_data_dir,
284320
file_local.instantiate_envrc_snapshot,
285321
file_local.instantiate_inputs_snapshot,
286322
file_local.instantiate_tpl_snapshot,

run_tests.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,17 +85,20 @@ EOF
8585
else
8686
package_pattern="..."
8787
fi
88+
# We need both -p and -parallel, as -p sets the number of packages to test in parallel, and -parallel sets the number of tests to run in parallel.
89+
# By setting both to 1, we ensure that tests are run sequentially, which can help avoid AWS rate limiting issues. I does increase the runtime significantly though.
8890
# shellcheck disable=SC2086
8991
gotestsum \
9092
--format=standard-verbose \
9193
--jsonfile "/tmp/${IDENTIFIER}_test.log" \
9294
--post-run-command "sh /tmp/${IDENTIFIER}_test-processor" \
9395
--packages "$REPO_ROOT/$TEST_DIR/$package_pattern" \
9496
-- \
95-
-parallel=2 \
9697
-count=1 \
97-
-failfast=1 \
98+
-p=1 \
99+
-parallel=1 \
98100
-timeout=300m \
101+
-failfast \
99102
$rerun_flag \
100103
$specific_test_flag
101104

test/tests/three/basic_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package one
1+
package three
22

33
import (
44
"os"

test/tests/three/state_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package one
1+
package three
22

33
import (
44
"os"

0 commit comments

Comments
 (0)