Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow deploy controller & config bucket in different project #3675

Merged
merged 1 commit into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ limitations under the License.
| [google_storage_bucket_iam_binding.legacy_readers](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/storage_bucket_iam_binding) | resource |
| [google_storage_bucket_iam_binding.viewers](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/storage_bucket_iam_binding) | resource |
| [google_compute_image.slurm](https://registry.terraform.io/providers/hashicorp/google/latest/docs/data-sources/compute_image) | data source |
| [google_project.this](https://registry.terraform.io/providers/hashicorp/google/latest/docs/data-sources/project) | data source |
| [google_project.controller_project](https://registry.terraform.io/providers/hashicorp/google/latest/docs/data-sources/project) | data source |

## Inputs

Expand All @@ -289,6 +289,7 @@ limitations under the License.
| <a name="input_cloudsql"></a> [cloudsql](#input\_cloudsql) | Use this database instead of the one on the controller.<br/> server\_ip : Address of the database server.<br/> user : The user to access the database as.<br/> password : The password, given the user, to access the given database. (sensitive)<br/> db\_name : The database to access.<br/> user\_managed\_replication : The list of location and (optional) kms\_key\_name for secret | <pre>object({<br/> server_ip = string<br/> user = string<br/> password = string # sensitive<br/> db_name = string<br/> user_managed_replication = optional(list(object({<br/> location = string<br/> kms_key_name = optional(string)<br/> })), [])<br/> })</pre> | `null` | no |
| <a name="input_compute_startup_script"></a> [compute\_startup\_script](#input\_compute\_startup\_script) | Startup script used by the compute VMs. | `string` | `"# no-op"` | no |
| <a name="input_compute_startup_scripts_timeout"></a> [compute\_startup\_scripts\_timeout](#input\_compute\_startup\_scripts\_timeout) | The timeout (seconds) applied to each script in compute\_startup\_scripts. If<br/>any script exceeds this timeout, then the instance setup process is considered<br/>failed and handled accordingly.<br/><br/>NOTE: When set to 0, the timeout is considered infinite and thus disabled. | `number` | `300` | no |
| <a name="input_controller_project_id"></a> [controller\_project\_id](#input\_controller\_project\_id) | Optionally. Provision controller and config bucket in the different project | `string` | `null` | no |
| <a name="input_controller_startup_script"></a> [controller\_startup\_script](#input\_controller\_startup\_script) | Startup script used by the controller VM. | `string` | `"# no-op"` | no |
| <a name="input_controller_startup_scripts_timeout"></a> [controller\_startup\_scripts\_timeout](#input\_controller\_startup\_scripts\_timeout) | The timeout (seconds) applied to each script in controller\_startup\_scripts. If<br/>any script exceeds this timeout, then the instance setup process is considered<br/>failed and handled accordingly.<br/><br/>NOTE: When set to 0, the timeout is considered infinite and thus disabled. | `number` | `300` | no |
| <a name="input_create_bucket"></a> [create\_bucket](#input\_create\_bucket) | Create GCS bucket instead of using an existing one. | `bool` | `true` | no |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ locals {
}
]

synth_def_sa_email = "${data.google_project.this.number}[email protected]"
synth_def_sa_email = "${data.google_project.controller_project.number}[email protected]"

service_account = {
email = coalesce(var.service_account_email, local.synth_def_sa_email)
Expand All @@ -46,13 +46,19 @@ locals {
var.metadata,
local.universe_domain
)

controller_project_id = coalesce(var.controller_project_id, var.project_id)
}

data "google_project" "controller_project" {
project_id = var.controller_project_id
}

# INSTANCE TEMPLATE
module "slurm_controller_template" {
source = "../../internal/slurm-gcp/instance_template"

project_id = var.project_id
project_id = local.controller_project_id
region = var.region
slurm_instance_role = "controller"
slurm_cluster_name = local.slurm_cluster_name
Expand Down Expand Up @@ -97,7 +103,7 @@ module "slurm_controller_template" {
# INSTANCE
resource "google_compute_instance_from_template" "controller" {
name = "${local.slurm_cluster_name}-controller"
project = var.project_id
project = local.controller_project_id
zone = var.zone
source_instance_template = module.slurm_controller_template.self_link

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ locals {
universe_domain = { "universe_domain" = var.universe_domain }
}

data "google_project" "this" {
project_id = var.project_id
}

# See
# * slurm_files.tf
# * controller.tf
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1354,7 +1354,7 @@ def control_host(self):

@cached_property
def control_host_addr(self):
return host_lookup(self.cfg.slurm_control_host)
return self.control_addr or host_lookup(self.cfg.slurm_control_host)

@property
def control_host_port(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# BUCKET

locals {
synt_suffix = substr(md5("${var.project_id}${var.deployment_name}"), 0, 5)
synt_suffix = substr(md5("${local.controller_project_id}${var.deployment_name}"), 0, 5)
synth_bucket_name = "${local.slurm_cluster_name}${local.synt_suffix}"

bucket_name = var.create_bucket ? module.bucket[0].name : var.bucket_name
Expand All @@ -31,7 +31,7 @@ module "bucket" {
location = var.region
names = [local.synth_bucket_name]
prefix = "slurm"
project_id = var.project_id
project_id = local.controller_project_id

force_destroy = {
(local.synth_bucket_name) = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,3 +338,10 @@ variable "subnetwork_self_link" {
type = string
description = "Subnet to deploy to."
}


variable "controller_project_id" {
type = string
description = "Optionally. Provision controller and config bucket in the different project"
default = null
}
Loading