Skip to content

Commit 0901297

Browse files
committed
fix: add network interface to htcondor execute point module + update install ansible script
1 parent bf18385 commit 0901297

File tree

8 files changed

+111
-15
lines changed

8 files changed

+111
-15
lines changed

community/modules/compute/htcondor-execute-point/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,9 @@ limitations under the License.
212212
213213
| Name | Source | Version |
214214
|------|--------|---------|
215-
| <a name="module_execute_point_instance_template"></a> [execute\_point\_instance\_template](#module\_execute\_point\_instance\_template) | terraform-google-modules/vm/google//modules/instance_template | ~> 12.1 |
215+
| <a name="module_execute_point_instance_template"></a> [execute\_point\_instance\_template](#module\_execute\_point\_instance\_template) | terraform-google-modules/vm/google//modules/instance_template | ~> 14.0 |
216216
| <a name="module_gpu"></a> [gpu](#module\_gpu) | ../../../../modules/internal/gpu-definition | n/a |
217-
| <a name="module_mig"></a> [mig](#module\_mig) | terraform-google-modules/vm/google//modules/mig | ~> 12.1 |
217+
| <a name="module_mig"></a> [mig](#module\_mig) | terraform-google-modules/vm/google//modules/mig | ~> 14.0 |
218218
| <a name="module_startup_script"></a> [startup\_script](#module\_startup\_script) | ../../../../modules/scripts/startup-script | n/a |
219219
220220
## Resources
@@ -249,6 +249,7 @@ limitations under the License.
249249
| <a name="input_metadata"></a> [metadata](#input\_metadata) | Metadata to add to HTCondor execute points | `map(string)` | `{}` | no |
250250
| <a name="input_min_idle"></a> [min\_idle](#input\_min\_idle) | Minimum number of idle VMs in the HTCondor pool (if pool reaches var.max\_size, this minimum is not guaranteed); set to ensure jobs beginning run more quickly. | `number` | `0` | no |
251251
| <a name="input_name_prefix"></a> [name\_prefix](#input\_name\_prefix) | Name prefix given to hostnames in this group of execute points; must be unique across all instances of this module | `string` | n/a | yes |
252+
| <a name="input_network_interfaces"></a> [network\_interfaces](#input\_network\_interfaces) | A list of network interfaces to attach to HTCondor execute point instances.<br/>Each network interface should have the following fields:<br/>- network (required): The self link of the network<br/>- subnetwork (optional): The self link of the subnetwork<br/>- nic\_type (optional): "GVNIC" or "VIRTIO\_NET"<br/>- stack\_type (optional): "IPV4\_ONLY" or "IPV4\_IPV6"<br/>- network\_ip (optional): Specific IP address to assign<br/>- queue\_count (optional): Queue count for multiqueue NIC<br/>- access\_config (optional): List of NAT config objects<br/>- ipv6\_access\_config (optional): List of IPv6 access config objects<br/>- alias\_ip\_range (optional): List of alias IP ranges<br/><br/>If the list is empty, the module will fall back to using var.network\_self\_link<br/>and var.subnetwork\_self\_link for backward compatibility.<br/><br/>NB: If you update the current setup with network interfaces, you may need to delete the current mig to apply the new network interface configuration | <pre>list(object({<br/> network = string<br/> subnetwork = optional(string)<br/> nic_type = optional(string)<br/> stack_type = optional(string)<br/> network_ip = optional(string, "")<br/> queue_count = optional(number)<br/> access_config = optional(list(object({<br/> nat_ip = optional(string)<br/> network_tier = optional(string)<br/> })), [])<br/> ipv6_access_config = optional(list(object({<br/> network_tier = optional(string)<br/> })), [])<br/> alias_ip_range = optional(list(object({<br/> ip_cidr_range = string<br/> subnetwork_range_name = string<br/> })), [])<br/> }))</pre> | `[]` | no |
252253
| <a name="input_network_self_link"></a> [network\_self\_link](#input\_network\_self\_link) | The self link of the network HTCondor execute points will join | `string` | `"default"` | no |
253254
| <a name="input_network_storage"></a> [network\_storage](#input\_network\_storage) | An array of network attached storage mounts to be configured | <pre>list(object({<br/> server_ip = string,<br/> remote_mount = string,<br/> local_mount = string,<br/> fs_type = string,<br/> mount_options = string,<br/> client_install_runner = map(string)<br/> mount_runner = map(string)<br/> }))</pre> | `[]` | no |
254255
| <a name="input_project_id"></a> [project\_id](#input\_project\_id) | Project in which the HTCondor execute points will be created | `string` | n/a | yes |

community/modules/compute/htcondor-execute-point/main.tf

Lines changed: 54 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,39 @@ locals {
115115
)
116116

117117
name_prefix = "${var.deployment_name}-${var.name_prefix}-ep"
118+
119+
# Handle backward compatibility for network configuration
120+
# If var.network_interfaces is provided, use it directly.
121+
# Otherwise, fall back to the older vars var.network_self_link and var.subnetwork_self_link
122+
network_interfaces = (
123+
length(var.network_interfaces) > 0
124+
? [
125+
for ni in var.network_interfaces : {
126+
network = ni.network
127+
subnetwork = ni.subnetwork
128+
nic_type = ni.nic_type
129+
stack_type = ni.stack_type
130+
network_ip = ni.network_ip
131+
queue_count = ni.queue_count
132+
access_config = ni.access_config
133+
ipv6_access_config = ni.ipv6_access_config
134+
alias_ip_range = ni.alias_ip_range
135+
}
136+
]
137+
: [
138+
{
139+
network = var.network_self_link
140+
subnetwork = var.subnetwork_self_link
141+
nic_type = null
142+
stack_type = null
143+
network_ip = ""
144+
queue_count = null
145+
access_config = []
146+
ipv6_access_config = []
147+
alias_ip_range = []
148+
}
149+
]
150+
)
118151
}
119152

120153
data "google_compute_zones" "available" {
@@ -147,12 +180,29 @@ module "startup_script" {
147180

148181
module "execute_point_instance_template" {
149182
source = "terraform-google-modules/vm/google//modules/instance_template"
150-
version = "~> 12.1"
183+
version = "~> 14.0"
151184

152185
name_prefix = local.name_prefix
153186
project_id = var.project_id
154-
network = var.network_self_link
155-
subnetwork = var.subnetwork_self_link
187+
region = var.region
188+
network = local.network_interfaces[0].network
189+
subnetwork = local.network_interfaces[0].subnetwork
190+
191+
additional_networks = [
192+
for network_interface in slice(local.network_interfaces, 1, length(local.network_interfaces)) : {
193+
network = network_interface.network
194+
subnetwork = network_interface.subnetwork
195+
subnetwork_project = network_interface.subnetwork != null ? var.project_id : null
196+
nic_type = network_interface.nic_type
197+
stack_type = network_interface.stack_type
198+
network_ip = network_interface.network_ip
199+
queue_count = network_interface.queue_count
200+
access_config = network_interface.access_config
201+
ipv6_access_config = network_interface.ipv6_access_config
202+
alias_ip_range = network_interface.alias_ip_range
203+
}
204+
]
205+
156206
service_account = {
157207
email = var.execute_point_service_account_email
158208
scopes = var.service_account_scopes
@@ -175,7 +225,7 @@ module "execute_point_instance_template" {
175225

176226
module "mig" {
177227
source = "terraform-google-modules/vm/google//modules/mig"
178-
version = "~> 12.1"
228+
version = "~> 14.0"
179229

180230
project_id = var.project_id
181231
region = var.region

community/modules/compute/htcondor-execute-point/variables.tf

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,49 @@ variable "subnetwork_self_link" {
135135
default = null
136136
}
137137

138+
variable "network_interfaces" {
139+
description = <<-EOT
140+
A list of network interfaces to attach to HTCondor execute point instances.
141+
Each network interface should have the following fields:
142+
- network (required): The self link of the network
143+
- subnetwork (optional): The self link of the subnetwork
144+
- nic_type (optional): "GVNIC" or "VIRTIO_NET"
145+
- stack_type (optional): "IPV4_ONLY" or "IPV4_IPV6"
146+
- network_ip (optional): Specific IP address to assign
147+
- queue_count (optional): Queue count for multiqueue NIC
148+
- access_config (optional): List of NAT config objects
149+
- ipv6_access_config (optional): List of IPv6 access config objects
150+
- alias_ip_range (optional): List of alias IP ranges
151+
152+
If the list is empty, the module will fall back to using var.network_self_link
153+
and var.subnetwork_self_link for backward compatibility.
154+
155+
NB: If you update the current setup with network interfaces, you may need to delete the current mig to apply the new network interface configuration
156+
EOT
157+
158+
type = list(object({
159+
network = string
160+
subnetwork = optional(string)
161+
nic_type = optional(string)
162+
stack_type = optional(string)
163+
network_ip = optional(string, "")
164+
queue_count = optional(number)
165+
access_config = optional(list(object({
166+
nat_ip = optional(string)
167+
network_tier = optional(string)
168+
})), [])
169+
ipv6_access_config = optional(list(object({
170+
network_tier = optional(string)
171+
})), [])
172+
alias_ip_range = optional(list(object({
173+
ip_cidr_range = string
174+
subnetwork_range_name = string
175+
})), [])
176+
}))
177+
178+
default = []
179+
}
180+
138181
variable "target_size" {
139182
description = "Initial size of the HTCondor execute point pool; set to null (default) to avoid Terraform management of size."
140183
type = number

community/modules/scheduler/htcondor-access-point/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ limitations under the License.
122122
123123
| Name | Source | Version |
124124
|------|--------|---------|
125-
| <a name="module_access_point_instance_template"></a> [access\_point\_instance\_template](#module\_access\_point\_instance\_template) | terraform-google-modules/vm/google//modules/instance_template | ~> 12.1 |
126-
| <a name="module_htcondor_ap"></a> [htcondor\_ap](#module\_htcondor\_ap) | terraform-google-modules/vm/google//modules/mig | ~> 12.1 |
125+
| <a name="module_access_point_instance_template"></a> [access\_point\_instance\_template](#module\_access\_point\_instance\_template) | terraform-google-modules/vm/google//modules/instance_template | ~> 14.0 |
126+
| <a name="module_htcondor_ap"></a> [htcondor\_ap](#module\_htcondor\_ap) | terraform-google-modules/vm/google//modules/mig | ~> 14.0 |
127127
| <a name="module_startup_script"></a> [startup\_script](#module\_startup\_script) | ../../../../modules/scripts/startup-script | n/a |
128128
129129
## Resources

community/modules/scheduler/htcondor-access-point/main.tf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,10 +242,11 @@ resource "google_compute_address" "ap" {
242242

243243
module "access_point_instance_template" {
244244
source = "terraform-google-modules/vm/google//modules/instance_template"
245-
version = "~> 12.1"
245+
version = "~> 14.0"
246246

247247
name_prefix = local.name_prefix
248248
project_id = var.project_id
249+
region = var.region
249250
network = var.network_self_link
250251
subnetwork = var.subnetwork_self_link
251252
service_account = {
@@ -279,7 +280,7 @@ module "access_point_instance_template" {
279280

280281
module "htcondor_ap" {
281282
source = "terraform-google-modules/vm/google//modules/mig"
282-
version = "~> 12.1"
283+
version = "~> 14.0"
283284

284285
project_id = var.project_id
285286
region = var.region

community/modules/scheduler/htcondor-central-manager/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ limitations under the License.
106106

107107
| Name | Source | Version |
108108
|------|--------|---------|
109-
| <a name="module_central_manager_instance_template"></a> [central\_manager\_instance\_template](#module\_central\_manager\_instance\_template) | terraform-google-modules/vm/google//modules/instance_template | ~> 12.1 |
110-
| <a name="module_htcondor_cm"></a> [htcondor\_cm](#module\_htcondor\_cm) | terraform-google-modules/vm/google//modules/mig | ~> 12.1 |
109+
| <a name="module_central_manager_instance_template"></a> [central\_manager\_instance\_template](#module\_central\_manager\_instance\_template) | terraform-google-modules/vm/google//modules/instance_template | ~> 14.0 |
110+
| <a name="module_htcondor_cm"></a> [htcondor\_cm](#module\_htcondor\_cm) | terraform-google-modules/vm/google//modules/mig | ~> 14.0 |
111111
| <a name="module_startup_script"></a> [startup\_script](#module\_startup\_script) | ../../../../modules/scripts/startup-script | n/a |
112112

113113
## Resources

community/modules/scheduler/htcondor-central-manager/main.tf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,11 @@ resource "google_compute_address" "cm" {
149149

150150
module "central_manager_instance_template" {
151151
source = "terraform-google-modules/vm/google//modules/instance_template"
152-
version = "~> 12.1"
152+
version = "~> 14.0"
153153

154154
name_prefix = local.name_prefix
155155
project_id = var.project_id
156+
region = var.region
156157
network = var.network_self_link
157158
subnetwork = var.subnetwork_self_link
158159
service_account = {
@@ -177,7 +178,7 @@ module "central_manager_instance_template" {
177178

178179
module "htcondor_cm" {
179180
source = "terraform-google-modules/vm/google//modules/mig"
180-
version = "~> 12.1"
181+
version = "~> 14.0"
181182

182183
project_id = var.project_id
183184
region = var.region

modules/scripts/startup-script/files/install_ansible.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ main() {
180180

181181
# Create pip virtual environment for Cluster Toolkit
182182
${python_path} -m venv "${venv_path}" --copies
183-
venv_python_path=${venv_path}/bin/python3
183+
venv_python_path="${venv_path}/bin/$(basename "${python_path}")"
184184

185185
# Upgrade pip if necessary
186186
pip_version=$(${venv_python_path} -m pip --version | sed -nr 's/^pip ([0-9]+\.[0-9]+).*$/\1/p')

0 commit comments

Comments
 (0)