Skip to content

Commit 41efbfd

Browse files
committed
CBPS-1162: ability to deploy GCP instances with local NVMEs
Also do some tidying of terraform files Change-Id: Ic24c331da1373f4c21856a0906ed6b48e6de2108 Reviewed-on: https://review.couchbase.org/c/perfrunner/+/191119 Tested-by: Build Bot <[email protected]> Reviewed-by: vikas chaudhary <[email protected]>
1 parent 3727d4f commit 41efbfd

File tree

7 files changed

+270
-247
lines changed

7 files changed

+270
-247
lines changed

perfrunner/utils/terraform.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from argparse import ArgumentParser
55
from collections import Counter
66
from time import sleep, time
7+
from typing import Dict
78
from uuid import uuid4
89

910
import requests
@@ -49,7 +50,7 @@ def raise_for_status(resp: requests.Response):
4950
resp.raise_for_status()
5051
except HTTPError as e:
5152
logger.error('HTTP Error {}: response content: {}'.format(resp.status_code, resp.content))
52-
raise(e)
53+
raise e
5354

5455

5556
def format_datadog_link(cluster_id: str = None, dataplane_id: str = None,
@@ -151,7 +152,7 @@ def deploy(self):
151152
def destroy(self):
152153
self.terraform_destroy(self.provider)
153154

154-
def create_tfvar_nodes(self):
155+
def create_tfvar_nodes(self) -> Dict[str, Dict]:
155156
tfvar_nodes = {
156157
'clusters': {},
157158
'clients': {},
@@ -189,6 +190,7 @@ def create_tfvar_nodes(self):
189190

190191
parameters['image'] = image
191192

193+
# Set disk size and type
192194
parameters['volume_size'] = int(parameters.get('volume_size', 0))
193195

194196
storage_class = parameters.get('storage_class', parameters.get('volume_type', None))
@@ -197,14 +199,18 @@ def create_tfvar_nodes(self):
197199
storage_class = node_cluster_config.get('storage_class')
198200
parameters['storage_class'] = storage_class
199201

200-
if 'disk_tier' not in parameters and cloud_provider == 'azure':
201-
parameters['disk_tier'] = ""
202-
203-
if cloud_provider in ('aws', 'gcp'):
202+
# Set CSP-specific options
203+
if cloud_provider == 'azure':
204+
parameters['disk_tier'] = parameters.get('disk_tier', '')
205+
else:
206+
# AWS and GCP
204207
parameters['iops'] = int(parameters.get('iops', 0))
205208
if cloud_provider == 'aws':
206209
parameters['volume_throughput'] = int(parameters.get('volume_throughput',
207210
0))
211+
else:
212+
# GCP
213+
parameters['local_nvmes'] = int(parameters.get('local_nvmes', 0))
208214

209215
del parameters['instance_capacity']
210216

terraform/aws/Terraform.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,16 +293,19 @@ resource "aws_instance" "cluster_instance" {
293293
subnet_id = aws_subnet.public.id
294294
ami = data.aws_ami.cluster_ami[each.key].id
295295
instance_type = each.value.instance_type
296+
296297
root_block_device {
297298
volume_size = 32
298299
}
300+
299301
ebs_block_device {
300302
device_name = "/dev/sdb"
301303
volume_size = each.value.volume_size
302304
volume_type = lower(each.value.storage_class)
303305
throughput = each.value.volume_throughput > 0 ? each.value.volume_throughput : null
304306
iops = each.value.iops > 0 ? each.value.iops : null
305307
}
308+
306309
tags = {
307310
Name = var.global_tag != "" ? var.global_tag : "ClusterNode${each.key}"
308311
role = "cluster"
@@ -317,13 +320,15 @@ resource "aws_instance" "client_instance" {
317320
subnet_id = aws_subnet.public.id
318321
ami = data.aws_ami.client_ami[each.key].id
319322
instance_type = each.value.instance_type
323+
320324
ebs_block_device {
321325
device_name = "/dev/sdb"
322326
volume_size = each.value.volume_size
323327
volume_type = lower(each.value.storage_class)
324328
throughput = each.value.volume_throughput > 0 ? each.value.volume_throughput : null
325329
iops = each.value.iops > 0 ? each.value.iops : null
326330
}
331+
327332
tags = {
328333
Name = var.global_tag != "" ? var.global_tag : "ClientNode${each.key}"
329334
role = "client"
@@ -338,13 +343,15 @@ resource "aws_instance" "utility_instance" {
338343
subnet_id = aws_subnet.public.id
339344
ami = data.aws_ami.utility_ami[each.key].id
340345
instance_type = each.value.instance_type
346+
341347
ebs_block_device {
342348
device_name = "/dev/sdb"
343349
volume_size = each.value.volume_size
344350
volume_type = lower(each.value.storage_class)
345351
throughput = each.value.volume_throughput > 0 ? each.value.volume_throughput : null
346352
iops = each.value.iops > 0 ? each.value.iops : null
347353
}
354+
348355
tags = {
349356
Name = var.global_tag != "" ? var.global_tag : "UtilityNode${each.key}"
350357
role = "utility"
@@ -359,13 +366,15 @@ resource "aws_instance" "syncgateway_instance" {
359366
subnet_id = aws_subnet.public.id
360367
ami = data.aws_ami.syncgateway_ami[each.key].id
361368
instance_type = each.value.instance_type
369+
362370
ebs_block_device {
363371
device_name = "/dev/sdb"
364372
volume_size = each.value.volume_size
365373
volume_type = lower(each.value.storage_class)
366374
throughput = each.value.volume_throughput > 0 ? each.value.volume_throughput : null
367375
iops = each.value.iops > 0 ? each.value.iops : null
368376
}
377+
369378
tags = {
370379
Name = var.global_tag != "" ? var.global_tag : "SyncGatewayNode${each.key}"
371380
role = "syncgateway"

terraform/aws/outputs.tf

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,49 @@
11
output "cluster_instance_ips" {
2-
value = {
3-
for k, v in aws_instance.cluster_instance: k => {
4-
node_group = v.tags_all["node_group"]
5-
public_ip = v.public_dns
6-
}
2+
value = {
3+
for k, v in aws_instance.cluster_instance: k => {
4+
node_group = v.tags_all["node_group"]
5+
public_ip = v.public_dns
76
}
7+
}
88
}
99

1010
output "client_instance_ips" {
11-
value = {
12-
for k, v in aws_instance.client_instance: k => {
13-
node_group = v.tags_all["node_group"]
14-
public_ip = v.public_dns
15-
}
11+
value = {
12+
for k, v in aws_instance.client_instance: k => {
13+
node_group = v.tags_all["node_group"]
14+
public_ip = v.public_dns
1615
}
16+
}
1717
}
1818

1919
output "utility_instance_ips" {
20-
value = {
21-
for k, v in aws_instance.utility_instance: k => {
22-
node_group = v.tags_all["node_group"]
23-
public_ip = v.public_dns
24-
}
20+
value = {
21+
for k, v in aws_instance.utility_instance: k => {
22+
node_group = v.tags_all["node_group"]
23+
public_ip = v.public_dns
2524
}
25+
}
2626
}
2727

2828
output "syncgateway_instance_ips" {
29-
value = {
30-
for k, v in aws_instance.syncgateway_instance: k => {
31-
node_group = v.tags_all["node_group"]
32-
public_ip = v.public_dns
33-
}
29+
value = {
30+
for k, v in aws_instance.syncgateway_instance: k => {
31+
node_group = v.tags_all["node_group"]
32+
public_ip = v.public_dns
3433
}
34+
}
3535
}
3636

3737
output "network" {
38-
value = {
39-
vpc_id = aws_vpc.main.id
40-
subnet_cidr = aws_subnet.public.cidr_block
41-
route_table_id = aws_route_table.public.id
42-
}
38+
value = {
39+
vpc_id = aws_vpc.main.id
40+
subnet_cidr = aws_subnet.public.cidr_block
41+
route_table_id = aws_route_table.public.id
42+
}
4343
}
4444

4545
output "cloud_storage" {
46-
value = {
47-
storage_bucket = length(aws_s3_bucket.perf-storage-bucket) != 0 ? "s3://${one(aws_s3_bucket.perf-storage-bucket).id}" : null
48-
}
46+
value = {
47+
storage_bucket = length(aws_s3_bucket.perf-storage-bucket) != 0 ? "s3://${one(aws_s3_bucket.perf-storage-bucket).id}" : null
48+
}
4949
}

terraform/azure/Terraform.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ resource "azurerm_virtual_network" "perf-vn" {
6666
resource_group_name = "perf-resources-eastus"
6767

6868
tags = {
69-
deployment = var.global_tag != "" ? var.global_tag : null
69+
deployment = var.global_tag != "" ? var.global_tag : null
7070
}
7171
}
7272

terraform/azure/outputs.tf

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,48 @@
11
output "cluster_instance_ips" {
2-
value = {
3-
for k, v in azurerm_virtual_machine.perf-cluster-vm: k => {
4-
node_group = v.tags["node_group"]
5-
public_ip = azurerm_public_ip.perf-public-cluster[k].ip_address
6-
private_ip = azurerm_network_interface.perf-cluster-ni[k].private_ip_address
7-
}
2+
value = {
3+
for k, v in azurerm_virtual_machine.perf-cluster-vm: k => {
4+
node_group = v.tags["node_group"]
5+
public_ip = azurerm_public_ip.perf-public-cluster[k].ip_address
6+
private_ip = azurerm_network_interface.perf-cluster-ni[k].private_ip_address
87
}
8+
}
99
}
1010

1111
output "client_instance_ips" {
12-
value = {
13-
for k, v in azurerm_virtual_machine.perf-client-vm: k => {
14-
node_group = v.tags["node_group"]
15-
public_ip = azurerm_public_ip.perf-public-client[k].ip_address
16-
private_ip = azurerm_network_interface.perf-client-ni[k].private_ip_address
17-
}
12+
value = {
13+
for k, v in azurerm_virtual_machine.perf-client-vm: k => {
14+
node_group = v.tags["node_group"]
15+
public_ip = azurerm_public_ip.perf-public-client[k].ip_address
16+
private_ip = azurerm_network_interface.perf-client-ni[k].private_ip_address
1817
}
18+
}
1919
}
2020

2121
output "utility_instance_ips" {
22-
value = {
23-
for k, v in azurerm_virtual_machine.perf-utility-vm: k => {
24-
node_group = v.tags["node_group"]
25-
public_ip = azurerm_public_ip.perf-public-utility[k].ip_address
26-
private_ip = azurerm_network_interface.perf-utility-ni[k].private_ip_address
27-
}
22+
value = {
23+
for k, v in azurerm_virtual_machine.perf-utility-vm: k => {
24+
node_group = v.tags["node_group"]
25+
public_ip = azurerm_public_ip.perf-public-utility[k].ip_address
26+
private_ip = azurerm_network_interface.perf-utility-ni[k].private_ip_address
2827
}
28+
}
2929
}
3030

3131
output "syncgateway_instance_ips" {
32-
value = {
33-
for k, v in azurerm_virtual_machine.perf-syncgateway-vm: k => {
34-
node_group = v.tags["node_group"]
35-
public_ip = azurerm_public_ip.perf-public-syncgateway[k].ip_address
36-
private_ip = azurerm_network_interface.perf-syncgateway-ni[k].private_ip_address
37-
}
32+
value = {
33+
for k, v in azurerm_virtual_machine.perf-syncgateway-vm: k => {
34+
node_group = v.tags["node_group"]
35+
public_ip = azurerm_public_ip.perf-public-syncgateway[k].ip_address
36+
private_ip = azurerm_network_interface.perf-syncgateway-ni[k].private_ip_address
3837
}
38+
}
3939
}
4040

4141
output "network" {
42-
value = {
43-
vpc_id = azurerm_virtual_network.perf-vn.id
44-
subnet_cidr = one(azurerm_subnet.perf-sn.address_prefixes)
45-
}
42+
value = {
43+
vpc_id = azurerm_virtual_network.perf-vn.id
44+
subnet_cidr = one(azurerm_subnet.perf-sn.address_prefixes)
45+
}
4646
}
4747

4848
output "cloud_storage" {

0 commit comments

Comments
 (0)