Skip to content

Commit

Permalink
Merge pull request #2747 from harshthakkar01/feedback-ps
Browse files Browse the repository at this point in the history
Update parameters for parallelstore module as per feedback
  • Loading branch information
harshthakkar01 authored Jul 11, 2024
2 parents c8bc08c + d656154 commit 3a2d7a3
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 18 deletions.
6 changes: 3 additions & 3 deletions modules/file-system/parallelstore/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,16 @@ No modules.
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_deployment_name"></a> [deployment\_name](#input\_deployment\_name) | Name of the HPC deployment. | `string` | n/a | yes |
| <a name="input_destination_hydration_parallelstore"></a> [destination\_hydration\_parallelstore](#input\_destination\_hydration\_parallelstore) | The name of local path to import data on parallelstore instance from GCS bucket. | `string` | `"/"` | no |
| <a name="input_import_destination_path"></a> [import\_destination\_path](#input\_import\_destination\_path) | The name of local path to import data on parallelstore instance from GCS bucket. | `string` | `null` | no |
| <a name="input_import_gcs_bucket_uri"></a> [import\_gcs\_bucket\_uri](#input\_import\_gcs\_bucket\_uri) | The name of the GCS bucket to import data from to parallelstore. | `string` | `null` | no |
| <a name="input_labels"></a> [labels](#input\_labels) | Labels to add to parallel store instance. | `map(string)` | `{}` | no |
| <a name="input_local_mount"></a> [local\_mount](#input\_local\_mount) | The mount point where the contents of the device may be accessed after mounting. | `string` | `"/parallelstore"` | no |
| <a name="input_mount_options"></a> [mount\_options](#input\_mount\_options) | Options describing various aspects of the parallelstore instance. | `string` | `"disable-wb-cache,thread-count=16,eq-count=8"` | no |
| <a name="input_name"></a> [name](#input\_name) | Name of parallelstore instance. | `string` | `null` | no |
| <a name="input_network_id"></a> [network\_id](#input\_network\_id) | The ID of the GCE VPC network to which the instance is connected given in the format:<br>`projects/<project_id>/global/networks/<network_name>`" | `string` | n/a | yes |
| <a name="input_private_vpc_connection_peering"></a> [private\_vpc\_connection\_peering](#input\_private\_vpc\_connection\_peering) | The name of the VPC Network peering connection. | `string` | n/a | yes |
| <a name="input_private_vpc_connection_peering"></a> [private\_vpc\_connection\_peering](#input\_private\_vpc\_connection\_peering) | The name of the VPC Network peering connection.<br>If using new VPC, please use community/modules/network/private-service-access to create private-service-access and<br>If using existing VPC with private-service-access enabled, set this manually." | `string` | n/a | yes |
| <a name="input_project_id"></a> [project\_id](#input\_project\_id) | Project in which the HPC deployment will be created. | `string` | n/a | yes |
| <a name="input_size_gb"></a> [size\_gb](#input\_size\_gb) | Storage size of the parallelstore instance in GB. | `number` | `12000` | no |
| <a name="input_source_gcs_bucket_uri"></a> [source\_gcs\_bucket\_uri](#input\_source\_gcs\_bucket\_uri) | The name of the GCS bucket to import data from to parallelstore. | `string` | `""` | no |
| <a name="input_zone"></a> [zone](#input\_zone) | Location for parallelstore instance. | `string` | n/a | yes |

## Outputs
Expand Down
15 changes: 8 additions & 7 deletions modules/file-system/parallelstore/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ locals {
}

locals {
fs_type = "daos"
server_ip = ""
remote_mount = ""
id = var.name != null ? var.name : "${var.deployment_name}-${random_id.resource_name_suffix.hex}"
access_points = jsonencode(google_parallelstore_instance.instance.access_points)
fs_type = "daos"
server_ip = ""
remote_mount = ""
id = var.name != null ? var.name : "${var.deployment_name}-${random_id.resource_name_suffix.hex}"
access_points = jsonencode(google_parallelstore_instance.instance.access_points)
destination_path = var.import_destination_path == null ? "/" : var.import_destination_path

client_install_runner = {
"type" = "shell"
Expand Down Expand Up @@ -58,10 +59,10 @@ resource "google_parallelstore_instance" "instance" {
}

resource "null_resource" "hydration" {
count = var.source_gcs_bucket_uri != "" ? 1 : 0
count = var.import_gcs_bucket_uri != null ? 1 : 0

depends_on = [resource.google_parallelstore_instance.instance]
provisioner "local-exec" {
command = "curl -X POST -H \"Content-Type: application/json\" -H \"Authorization: Bearer $(gcloud auth print-access-token)\" -d '{\"source_gcs_bucket\": {\"uri\":\"${var.source_gcs_bucket_uri}\"}, \"destination_parallelstore\": {\"path\":\"${var.destination_hydration_parallelstore}\"}}' https://parallelstore.googleapis.com/v1beta/projects/${var.project_id}/locations/${var.zone}/instances/${local.id}:importData"
command = "curl -X POST -H \"Content-Type: application/json\" -H \"Authorization: Bearer $(gcloud auth print-access-token)\" -d '{\"source_gcs_bucket\": {\"uri\":\"${var.import_gcs_bucket_uri}\"}, \"destination_parallelstore\": {\"path\":\"${local.destination_path}\"}}' https://parallelstore.googleapis.com/v1beta/projects/${var.project_id}/locations/${var.zone}/instances/${local.id}:importData"
}
}
9 changes: 8 additions & 1 deletion modules/file-system/parallelstore/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,16 @@ output "network_storage" {
client_install_runner = local.client_install_runner
mount_runner = local.mount_runner
}

precondition {
condition = var.import_gcs_bucket_uri != null || var.import_destination_path == null
error_message = <<-EOD
Please specify import_gcs_bucket_uri to import data to parallelstore instance.
EOD
}
}

output "instructions" {
description = "Instructions to monitor import-data operation from GCS bucket to parallelstore."
value = var.source_gcs_bucket_uri != "" ? local.operation_instructions : "Data is not imported from GCS bucket."
value = var.import_gcs_bucket_uri != null ? local.operation_instructions : "Data is not imported from GCS bucket."
}
4 changes: 3 additions & 1 deletion modules/file-system/parallelstore/scripts/mount-daos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ chmod 777 "$local_mount"
# Mount container for multi-user.
fuse_config=/etc/fuse.conf
sed -i "s/#.*user_allow_other/user_allow_other/g" $fuse_config
dfuse -m "$local_mount" --pool default-pool --container default-container --multi-user -o "$mount_options"
# To parse mount_options as --disable-wb-cache --eq-count=8.
# shellcheck disable=SC2086
dfuse -m "$local_mount" --pool default-pool --container default-container --multi-user $mount_options

exit 0
14 changes: 9 additions & 5 deletions modules/file-system/parallelstore/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ variable "mount_options" {
}

variable "private_vpc_connection_peering" {
description = "The name of the VPC Network peering connection."
description = <<-EOT
The name of the VPC Network peering connection.
If using new VPC, please use community/modules/network/private-service-access to create private-service-access and
If using existing VPC with private-service-access enabled, set this manually."
EOT
type = string
}

Expand All @@ -76,14 +80,14 @@ variable "network_id" {
}
}

variable "source_gcs_bucket_uri" {
variable "import_gcs_bucket_uri" {
description = "The name of the GCS bucket to import data from to parallelstore."
type = string
default = ""
default = null
}

variable "destination_hydration_parallelstore" {
variable "import_destination_path" {
description = "The name of local path to import data on parallelstore instance from GCS bucket."
type = string
default = "/"
default = null
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ chmod 777 "$local_mount"
# Mount container for multi-user.
fuse_config=/etc/fuse.conf
sed -i "s/#.*user_allow_other/user_allow_other/g" $fuse_config
dfuse -m "$local_mount" --pool default-pool --container default-container --multi-user -o "$mount_options"
# To parse mount_options as --disable-wb-cache --eq-count=8.
# shellcheck disable=SC2086
dfuse -m "$local_mount" --pool default-pool --container default-container --multi-user $mount_options

exit 0

0 comments on commit 3a2d7a3

Please sign in to comment.