Skip to content

Commit

Permalink
OCTOPUS-532: refactored the resource group, increased the approve and…
Browse files Browse the repository at this point in the history
… issue sleep, and refactored workers aligning to each zone in a greedy fashion related to the subnet

Signed-off-by: Paul Bastide <[email protected]>
  • Loading branch information
prb112 committed Nov 8, 2023
1 parent 00425c9 commit 27e167d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
7 changes: 6 additions & 1 deletion modules/0_vpc/create/create.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@
# SPDX-License-Identifier: Apache-2.0
################################################################

# Dev Note: the resource group id (if not set properly) defaults to the first available in the ResourceGroups list.
data "ibm_resource_group" "group" {
name = var.vpc_resource_group
}

# Dev Note: the dns.enable_hub = false by default, we may consider in the future setting it so we don't
# have to set a machineconfig with resolv.conf.d settings
# Ref https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/is_vpc
resource "ibm_is_vpc" "vpc" {
name = var.vpc_name
resource_group = var.vpc_resource_group
resource_group = data.ibm_resource_group.group.id
}
1 change: 0 additions & 1 deletion modules/1_vpc_prepare/subnets.tf
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,3 @@ resource "ibm_is_subnet_public_gateway_attachment" "attach_pg_worker_zone_3" {
subnet = ibm_is_subnet.subnet_worker_zone_3[0].id
public_gateway = ibm_is_public_gateway.pg_worker_zone_3[0].id
}

13 changes: 9 additions & 4 deletions modules/6_worker/worker.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@ data "ibm_is_subnets" "vpc_subnets" {
routing_table_name = data.ibm_is_vpc.vpc.default_routing_table_name
}

# Dev Note: greedy search for the first matching subnet that uses the worker_1's zone.
locals {
vpc_subnet_id = var.create_custom_subnet == true ? data.ibm_is_subnets.vpc_subnets.subnets[0].id : data.ibm_is_vpc.vpc.subnets[0].id
vpc_subnet_id = var.create_custom_subnet == true ? data.ibm_is_subnets.vpc_subnets.subnets[0].id : data.ibm_is_vpc.vpc.subnets[0].id
subnet_for_zone1 = [for subnet in data.ibm_is_subnets.vpc_subnets.subnets : subnet.id if subnet.zone == var.worker_1["zone"]]
subnet_for_zone2 = [for subnet in data.ibm_is_subnets.vpc_subnets.subnets : subnet.id if subnet.zone == var.worker_2["zone"]]
subnet_for_zone3 = [for subnet in data.ibm_is_subnets.vpc_subnets.subnets : subnet.id if subnet.zone == var.worker_3["zone"]]
}

resource "ibm_is_instance" "workers_1" {
Expand All @@ -29,7 +33,8 @@ resource "ibm_is_instance" "workers_1" {
resource_group = data.ibm_is_vpc.vpc.resource_group

primary_network_interface {
subnet = local.vpc_subnet_id #data.ibm_is_vpc.vpc.subnets[0].id
subnet = local.subnet_for_zone1[0]
# local.vpc_subnet_id
security_groups = [var.target_worker_sg_id]
}

Expand All @@ -51,7 +56,7 @@ resource "ibm_is_instance" "workers_2" {
resource_group = data.ibm_is_vpc.vpc.resource_group

primary_network_interface {
subnet = data.ibm_is_vpc.vpc.subnets[1].id
subnet = local.subnet_for_zone2[0]
security_groups = [var.target_worker_sg_id]
}

Expand All @@ -73,7 +78,7 @@ resource "ibm_is_instance" "workers_3" {
resource_group = data.ibm_is_vpc.vpc.resource_group

primary_network_interface {
subnet = data.ibm_is_vpc.vpc.subnets[2].id
subnet = local.subnet_for_zone3[0]
security_groups = [var.target_worker_sg_id]
}

Expand Down
5 changes: 3 additions & 2 deletions modules/7_post/files/approve_and_issue.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ do
fi
IDX=$(($IDX + 1))

# Wait for 10 seconds before we hammer the system
sleep 10
# Wait for 30 seconds before we hammer the system
echo "Sleeping before re-running - 30 seconds"
sleep 30

# Re-read the 'Ready' count
READY_COUNT=$(oc get nodes -l kubernetes.io/arch=amd64 | grep "${MACHINE_PREFIX}" | grep -v NotReady | grep -c Ready)
Expand Down

0 comments on commit 27e167d

Please sign in to comment.