Skip to content

Commit a0b4530

Browse files
authored
Merge pull request #20 from stackhpc/prod2312-state
Add state volume
2 parents 67419be + 483edd8 commit a0b4530

File tree

7 files changed

+100
-9
lines changed

7 files changed

+100
-9
lines changed

environments/lab/terraform/main.tf

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,29 @@ resource "openstack_networking_port_v2" "control_control" {
8181
resource "openstack_compute_instance_v2" "control" {
8282

8383
name = "${var.cluster_name}-control"
84-
image_name = var.control_image
84+
image_id = data.openstack_images_image_v2.control.id
8585
flavor_name = var.control_flavor
8686
key_pair = var.key_pair
8787
config_drive = true
8888
availability_zone = var.cluster_availability_zone
8989

90+
# root device:
91+
block_device {
92+
uuid = data.openstack_images_image_v2.control.id
93+
source_type = "image"
94+
destination_type = "local"
95+
boot_index = 0
96+
delete_on_termination = true
97+
}
98+
99+
# state volume:
100+
block_device {
101+
destination_type = "volume"
102+
source_type = "volume"
103+
boot_index = -1
104+
uuid = data.openstack_blockstorage_volume_v3.state.id
105+
}
106+
90107
network {
91108
port = openstack_networking_port_v2.control_cluster.id
92109
}
@@ -100,6 +117,14 @@ resource "openstack_compute_instance_v2" "control" {
100117
access_network = true
101118
}
102119

120+
user_data = <<-EOF
121+
#cloud-config
122+
bootcmd:
123+
- BLKDEV=$(readlink -f $(ls /dev/disk/by-id/*${substr(data.openstack_blockstorage_volume_v3.state.id, 0, 20)}* | head -n1 )); blkid -o value -s TYPE $BLKDEV || mke2fs -t ext4 -L state $BLKDEV
124+
125+
mounts:
126+
- [LABEL=state, /var/lib/state]
127+
EOF
103128
}
104129

105130
# --- slurm logins ---

environments/lab/terraform/prereqs/prereqs.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ terraform {
99
}
1010
}
1111

12+
locals {
13+
cluster_name = regex("cluster_name = \"([a-z]+)\"", file("${path.module}/../terraform.tfvars"))[0]
14+
}
15+
1216
resource "openstack_networking_network_v2" "storage" {
1317
name = "lab-storage"
1418
admin_state_up = "true"
@@ -32,3 +36,10 @@ resource "openstack_networking_subnet_v2" "compute" {
3236
cidr = "192.168.101.0/24"
3337
no_gateway = true
3438
}
39+
40+
resource "openstack_blockstorage_volume_v3" "state" {
41+
# read cluster_name from main tfvars file:
42+
name = "${local.cluster_name}-state"
43+
description = "State for control node"
44+
size = 10 # GB, doesn't matter for lab
45+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
appliances_state_dir: /var/lib/state # see volume mount in environments/*/terraform/main.tf:openstack_compute_instance_v2.control:userdata

environments/nrel/inventory/group_vars/openhpc/overrides.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ openhpc_generic_packages:
111111

112112
# Additional parameters to set in slurm.conf - use yaml format
113113
openhpc_slurmd_spool_dir: /var/spool/slurm/slurmd
114-
openhpc_state_save_location: /var/spool/slurm/slurmctld # TODO: move to persistent storage
115114
openhpc_config_extra:
116115
LaunchParameters: use_interactive_step
117116
FirstJobId: '50000000'

environments/prod/terraform/datasources.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,11 @@ data "openstack_networking_subnet_v2" "cluster" {
2525
data "openstack_networking_subnet_v2" "control" {
2626
name = var.control_subnet
2727
}
28+
29+
data "openstack_images_image_v2" "control" {
30+
name = var.control_image
31+
}
32+
33+
data "openstack_blockstorage_volume_v3" "state" {
34+
name = "${var.cluster_name}-state"
35+
}

environments/prod/terraform/main.tf

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,29 @@ resource "openstack_networking_port_v2" "control_control" {
8181
resource "openstack_compute_instance_v2" "control" {
8282

8383
name = "${var.cluster_name}-control"
84-
image_name = var.control_image
84+
image_id = data.openstack_images_image_v2.control.id
8585
flavor_name = var.control_flavor
8686
key_pair = var.key_pair
8787
config_drive = true
8888
availability_zone = var.cluster_availability_zone
8989

90+
# root device:
91+
block_device {
92+
uuid = data.openstack_images_image_v2.control.id
93+
source_type = "image"
94+
destination_type = "local"
95+
boot_index = 0
96+
delete_on_termination = true
97+
}
98+
99+
# state volume:
100+
block_device {
101+
destination_type = "volume"
102+
source_type = "volume"
103+
boot_index = -1
104+
uuid = data.openstack_blockstorage_volume_v3.state.id
105+
}
106+
90107
network {
91108
port = openstack_networking_port_v2.control_cluster.id
92109
}
@@ -100,6 +117,14 @@ resource "openstack_compute_instance_v2" "control" {
100117
access_network = true
101118
}
102119

120+
user_data = <<-EOF
121+
#cloud-config
122+
bootcmd:
123+
- BLKDEV=$(readlink -f $(ls /dev/disk/by-id/*${substr(data.openstack_blockstorage_volume_v3.state.id, 0, 20)}* | head -n1 )); blkid -o value -s TYPE $BLKDEV || mke2fs -t ext4 -L state $BLKDEV
124+
125+
mounts:
126+
- [LABEL=state, /var/lib/state]
127+
EOF
103128
}
104129

105130
# --- slurm logins ---

environments/vtest/terraform/main.tf

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,29 @@ resource "openstack_networking_port_v2" "control_control" {
8181
resource "openstack_compute_instance_v2" "control" {
8282

8383
name = "${var.cluster_name}-vtcontrol"
84-
image_name = var.control_image
84+
image_id = data.openstack_images_image_v2.control.id
8585
flavor_name = var.control_flavor
8686
key_pair = var.key_pair
8787
config_drive = true
8888
availability_zone = var.cluster_availability_zone
8989

90+
# root device:
91+
block_device {
92+
uuid = data.openstack_images_image_v2.control.id
93+
source_type = "image"
94+
destination_type = "local"
95+
boot_index = 0
96+
delete_on_termination = true
97+
}
98+
99+
# state volume:
100+
block_device {
101+
destination_type = "volume"
102+
source_type = "volume"
103+
boot_index = -1
104+
uuid = data.openstack_blockstorage_volume_v3.state.id
105+
}
106+
90107
network {
91108
port = openstack_networking_port_v2.control_cluster.id
92109
}
@@ -100,6 +117,14 @@ resource "openstack_compute_instance_v2" "control" {
100117
access_network = true
101118
}
102119

120+
user_data = <<-EOF
121+
#cloud-config
122+
bootcmd:
123+
- BLKDEV=$(readlink -f $(ls /dev/disk/by-id/*${substr(data.openstack_blockstorage_volume_v3.state.id, 0, 20)}* | head -n1 )); blkid -o value -s TYPE $BLKDEV || mke2fs -t ext4 -L state $BLKDEV
124+
125+
mounts:
126+
- [LABEL=state, /var/lib/state]
127+
EOF
103128
}
104129

105130
# --- slurm logins ---
@@ -179,12 +204,14 @@ resource "openstack_networking_port_v2" "login_control" {
179204
}
180205
}
181206

207+
# flavor_name = each.value
182208
resource "openstack_compute_instance_v2" "logins" {
183209

184210
for_each = var.login_names
185211

186212
name = "${var.cluster_name}-${each.key}"
187213
image_name = var.login_image
214+
188215
flavor_name = var.control_flavor
189216
key_pair = var.key_pair
190217
config_drive = true
@@ -204,7 +231,6 @@ resource "openstack_compute_instance_v2" "logins" {
204231
}
205232

206233
}
207-
# flavor_name = each.value
208234

209235
# --- slurm compute ---
210236

@@ -296,22 +322,18 @@ resource "openstack_compute_instance_v2" "computes" {
296322
key_pair = var.key_pair
297323
config_drive = true
298324
availability_zone = var.cluster_availability_zone
299-
#availability_zone_hints = "{{ var.cluster_availability_zone }}:vs-0519-u03a"
300325

301326
network {
302327
port = openstack_networking_port_v2.compute_control[each.key].id
303-
#name = "control"
304328
}
305329

306330
network {
307331
port = openstack_networking_port_v2.compute_cluster[each.key].id
308-
#name = "compute"
309332
access_network = true
310333
}
311334

312335
network {
313336
port = openstack_networking_port_v2.compute_storage[each.key].id
314-
#name = "storage"
315337
}
316338

317339
}

0 commit comments

Comments
 (0)