Skip to content

Commit

Permalink
Add validation for deprecated input variables
Browse files Browse the repository at this point in the history
  • Loading branch information
rohitramu committed May 27, 2023
1 parent e7b1eee commit cb4c67e
Show file tree
Hide file tree
Showing 4 changed files with 142 additions and 7 deletions.
4 changes: 2 additions & 2 deletions modules/network/vpc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ No resources.

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_additional_subnetworks"></a> [additional\_subnetworks](#input\_additional\_subnetworks) | DEPRECATED: please see https://goo.gle/hpc-toolkit-vpc-deprecation for migration instructions | `list(map(string))` | `[]` | no |
| <a name="input_additional_subnetworks"></a> [additional\_subnetworks](#input\_additional\_subnetworks) | DEPRECATED: please see https://goo.gle/hpc-toolkit-vpc-deprecation for migration instructions | `list(map(string))` | `null` | no |
| <a name="input_default_primary_subnetwork_size"></a> [default\_primary\_subnetwork\_size](#input\_default\_primary\_subnetwork\_size) | The size, in CIDR bits, of the default primary subnetwork unless explicitly defined in var.subnetworks | `number` | `15` | no |
| <a name="input_delete_default_internet_gateway_routes"></a> [delete\_default\_internet\_gateway\_routes](#input\_delete\_default\_internet\_gateway\_routes) | If set, ensure that all routes within the network specified whose names begin with 'default-route' and with a next hop of 'default-internet-gateway' are deleted | `bool` | `false` | no |
| <a name="input_deployment_name"></a> [deployment\_name](#input\_deployment\_name) | The name of the current deployment | `string` | n/a | yes |
Expand All @@ -200,7 +200,7 @@ No resources.
| <a name="input_primary_subnetwork"></a> [primary\_subnetwork](#input\_primary\_subnetwork) | DEPRECATED: please see https://goo.gle/hpc-toolkit-vpc-deprecation for migration instructions | `map(string)` | `null` | no |
| <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_region"></a> [region](#input\_region) | The default region for Cloud resources | `string` | n/a | yes |
| <a name="input_secondary_ranges"></a> [secondary\_ranges](#input\_secondary\_ranges) | Secondary ranges that will be used in some of the subnets | `map(list(object({ range_name = string, ip_cidr_range = string })))` | `{}` | no |
| <a name="input_secondary_ranges"></a> [secondary\_ranges](#input\_secondary\_ranges) | Secondary ranges that will be used in some of the subnets. Please see https://goo.gle/hpc-toolkit-vpc-deprecation for migration instructions. | `map(list(object({ range_name = string, ip_cidr_range = string })))` | `{}` | no |
| <a name="input_shared_vpc_host"></a> [shared\_vpc\_host](#input\_shared\_vpc\_host) | Makes this project a Shared VPC host if 'true' (default 'false') | `bool` | `false` | no |
| <a name="input_subnetwork_name"></a> [subnetwork\_name](#input\_subnetwork\_name) | The name of the network to be created (if unsupplied, will default to "{deployment\_name}-primary-subnet") | `string` | `null` | no |
| <a name="input_subnetwork_size"></a> [subnetwork\_size](#input\_subnetwork\_size) | DEPRECATED: please see https://goo.gle/hpc-toolkit-vpc-deprecation for migration instructions | `number` | `null` | no |
Expand Down
22 changes: 17 additions & 5 deletions modules/network/vpc/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ variable "subnetwork_size" {
description = "DEPRECATED: please see https://goo.gle/hpc-toolkit-vpc-deprecation for migration instructions"
type = number
default = null
validation {
condition = var.subnetwork_size == null
error_message = "subnetwork_size is deprecated. Please see https://goo.gle/hpc-toolkit-vpc-deprecation for migration instructions."
}
}

variable "default_primary_subnetwork_size" {
Expand Down Expand Up @@ -129,33 +133,41 @@ variable "primary_subnetwork" {
condition = var.primary_subnetwork == null || can(var.primary_subnetwork["new_bits"])
error_message = "Primary subnetwork must define \"new_bits\"."
}
validation {
condition = var.primary_subnetwork == null
error_message = "primary_subnetwork is deprecated. Please see https://goo.gle/hpc-toolkit-vpc-deprecation for migration instructions."
}
}

variable "additional_subnetworks" {
description = "DEPRECATED: please see https://goo.gle/hpc-toolkit-vpc-deprecation for migration instructions"
type = list(map(string))
default = []
default = null
validation {
condition = alltrue([
condition = var.additional_subnetworks == null || alltrue([
for s in var.additional_subnetworks : can(s["subnet_name"])
])
error_message = "All additional subnetworks must define \"subnet_name\"."
}
validation {
condition = alltrue([
condition = var.additional_subnetworks == null || alltrue([
for s in var.additional_subnetworks : can(s["subnet_region"])
])
error_message = "All additional subnetworks must define \"subnet_region\"."
}
validation {
condition = alltrue([for s in var.additional_subnetworks : can(s["new_bits"])])
condition = var.additional_subnetworks == null || alltrue([for s in var.additional_subnetworks : can(s["new_bits"])])
error_message = "All additional subnetworks must define \"new_bits\"."
}
validation {
condition = var.additional_subnetworks == null
error_message = "additional_subnetworks is deprecated."
}
}

variable "secondary_ranges" {
type = map(list(object({ range_name = string, ip_cidr_range = string })))
description = "Secondary ranges that will be used in some of the subnets"
description = "Secondary ranges that will be used in some of the subnets. Please see https://goo.gle/hpc-toolkit-vpc-deprecation for migration instructions."
default = {}
}

Expand Down
12 changes: 12 additions & 0 deletions modules/scheduler/batch-login-node/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,30 @@ variable "job_template_contents" {
description = "Deprecated (use `job_data`): The contents of the Google Cloud Batch job template. Typically supplied by a batch-job-template module."
type = string
default = null
validation {
condition = var.job_template_contents == null
error_message = "job_template_contents is deprecated. Please use `job_data` instead."
}
}

variable "job_filename" {
description = "Deprecated (use `job_data`): The filename of the generated job template file. Typically supplied by a batch-job-template module."
type = string
default = null
validation {
condition = var.job_filename == null
error_message = "job_filename is deprecated. Please use `job_data` instead."
}
}

variable "job_id" {
description = "Deprecated (use `job_data`): The ID for the Google Cloud Batch job. Typically supplied by a batch-job-template module for use in the output instructions."
type = string
default = null
validation {
condition = var.job_id == null
error_message = "job_id is deprecated. Please use `job_data` instead."
}
}

variable "gcloud_version" {
Expand Down
111 changes: 111 additions & 0 deletions tests.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
**************** vetting go code **********************
**************** running ghpc unit tests **************
go vet ./cmd/... ./pkg/...
go test -cover ./cmd/... ./pkg/... 2>&1 | perl tools/enforce_coverage.pl
ok hpc-toolkit/cmd (cached) coverage: 45.5% of statements
ok hpc-toolkit/pkg/config (cached) coverage: 86.8% of statements
ok hpc-toolkit/pkg/deploymentio (cached) coverage: 90.5% of statements
ok hpc-toolkit/pkg/inspect (cached) coverage: 87.5% of statements
? hpc-toolkit/pkg/validators [no test files]
ok hpc-toolkit/pkg/modulereader (cached) coverage: 87.0% of statements
ok hpc-toolkit/pkg/modulewriter (cached) coverage: 80.9% of statements
ok hpc-toolkit/pkg/shell (cached) coverage: 17.2% of statements
ok hpc-toolkit/pkg/sourcereader (cached) coverage: 85.3% of statements
**************** building ghpc ************************
*********** running "Golden copy" tests ***********
tools/validate_configs/golden_copies/validate.sh
Testing igc_pkr
Testing igc_tf
Testing text_escape
*********** running basic integration tests ***********
tools/validate_configs/validate_configs.sh
Running tests in 48 processes
testing examples/hpc-enterprise-slurm.yaml in /tmp/tmp.HK9WiS3Yse
testing examples/serverless-batch-mpi.yaml in /tmp/tmp.RtK0iQV9wB
testing examples/pfs-lustre.yaml in /tmp/tmp.1EI4zTEmIS
testing examples/hpc-slurm.yaml in /tmp/tmp.0EjXSgzbsp
testing examples/ml-slurm.yaml in /tmp/tmp.F6AtGMcdFr
testing community/examples/hpc-slurm-legacy-sharedvpc.yaml in /tmp/tmp.SsYU168qIl
testing community/examples/client-google-cloud-storage.yaml in /tmp/tmp.3hDUlE93U5
testing community/examples/hpc-slurm-legacy.yaml in /tmp/tmp.3s5YRY8QIj
testing community/examples/htc-slurm.yaml in /tmp/tmp.ztxnGGOJSt
testing examples/image-builder.yaml in /tmp/tmp.bkkBSPevVo
testing examples/serverless-batch.yaml in /tmp/tmp.fiLLZ6THb0
testing community/examples/intel/hpc-intel-select-slurm.yaml in /tmp/tmp.S1DML9tN2s
testing community/examples/ml-gke.yaml in /tmp/tmp.hZKhGo7kSl
testing community/examples/intel/hpc-slurm-daos.yaml in /tmp/tmp.K2vFaSBt5r
testing community/examples/intel/pfs-daos.yaml in /tmp/tmp.GJr7jrd4Z9
testing community/examples/hpc-slurm-local-ssd.yaml in /tmp/tmp.J9WhJw7HUb
testing community/examples/tutorial-starccm.yaml in /tmp/tmp.CwSdoL9Ndg
testing community/examples/htc-htcondor.yaml in /tmp/tmp.aIDmGdtSG9
testing tools/validate_configs/test_configs/debian-ss.yaml in /tmp/tmp.gzhfVDbUgR
testing community/examples/hpc-slurm-gromacs.yaml in /tmp/tmp.zdFQFgcrzS
testing tools/validate_configs/test_configs/hpc-cluster-simple.yaml in /tmp/tmp.FGbAuUBqnt
testing tools/validate_configs/test_configs/apt-collision.yaml in /tmp/tmp.lTIFFVPsP5
testing community/examples/omnia-cluster.yaml in /tmp/tmp.8pwYX2BCVi
testing tools/validate_configs/test_configs/multiple-batch-jobs.yaml in /tmp/tmp.ASbw2hVNXN
testing tools/validate_configs/test_configs/test_outputs.yaml in /tmp/tmp.amDVFm8sM8
testing tools/validate_configs/test_configs/gpu.yaml in /tmp/tmp.7Bgsu0X4Rm
testing tools/validate_configs/test_configs/spack-buildcache.yaml in /tmp/tmp.Lm9rvk0AkR
testing community/examples/slurm-chromedesktop.yaml in /tmp/tmp.Q07Ln4cH8M
testing tools/validate_configs/test_configs/slurm-gcp-v5-startup-scripts.yaml in /tmp/tmp.ejYYR5i14E
testing community/examples/tutorial-fluent.yaml in /tmp/tmp.K4l1cgVuDc
testing tools/validate_configs/test_configs/instance-with-startup.yaml in /tmp/tmp.mMWfyHuh1N
testing tools/validate_configs/test_configs/spack-environments.yaml in /tmp/tmp.o3ddhFKJ6o
testing tools/validate_configs/test_configs/hpc-centos-ss.yaml in /tmp/tmp.ob8Si3eLHQ
testing tools/validate_configs/test_configs/ubuntu-ss.yaml in /tmp/tmp.1OtZu8r2un
testing tools/validate_configs/test_configs/nfs-servers.yaml in /tmp/tmp.RmzPdRNrMl
testing tools/validate_configs/test_configs/pre-existing-fs.yaml in /tmp/tmp.lhkXLA819R
testing tools/validate_configs/test_configs/label_test.yaml in /tmp/tmp.F4Qdr9gei8
testing tools/validate_configs/test_configs/pbs-unwrapped.yaml in /tmp/tmp.XYAiW1OaPD
testing community/examples/hpc-slurm-ubuntu2004.yaml in /tmp/tmp.jOoCfrPMxN
testing tools/validate_configs/test_configs/cloud-batch-cft-instance-template.yaml in /tmp/tmp.qW9YlLxDxH
testing community/examples/hpc-gke.yaml in /tmp/tmp.Kxwk2imD18
testing tools/validate_configs/test_configs/startup-options.yaml in /tmp/tmp.kKnRsoNfKN
testing tools/validate_configs/test_configs/exascaler-new-vpc.yaml in /tmp/tmp.MO4zWqxsHX
testing community/examples/hpc-slurm-ramble-gromacs.yaml in /tmp/tmp.hasbRpm1VQ
testing tools/validate_configs/test_configs/threads_per_core.yaml in /tmp/tmp.4Y5vIQOAmm
testing community/examples/AMD/hpc-amd-slurm.yaml in /tmp/tmp.0CpsC4GTeB
testing community/examples/quantum-circuit-simulator.yaml in /tmp/tmp.BrZh9KOAOG
testing tools/validate_configs/test_configs/remote-desktop.yaml in /tmp/tmp.3qEndfZWkq
testing tools/validate_configs/test_configs/hpc-cluster-simple-nfs-sql.yaml in /tmp/tmp.sTn3Iwdb6k
testing tools/validate_configs/test_configs/hpc-cluster-project.yaml in /tmp/tmp.eN8KCsCCNb
testing tools/validate_configs/test_configs/overwrite_labels.yaml in /tmp/tmp.k89oNJmsmd
testing tools/validate_configs/test_configs/timeout_test.yaml in /tmp/tmp.YlZL47M5H4
testing tools/validate_configs/test_configs/node-groups.yaml in /tmp/tmp.nGvlBumi0j
testing tools/validate_configs/test_configs/centos8-ss.yaml in /tmp/tmp.V2VDx0Jd7t
testing tools/validate_configs/test_configs/complex-data.yaml in /tmp/tmp.kuPdGwQtk5
testing tools/validate_configs/test_configs/use-resources.yaml in /tmp/tmp.tXF837X4l8
testing tools/validate_configs/test_configs/hpc-cluster-service-acct.yaml in /tmp/tmp.AONRPJVoY6
*** ERROR: terraform validate failed for tools/validate_configs/test_configs/label_test.yaml, logs in /tmp/tmp.F4Qdr9gei8/label_test-f4qdr9gei8/infrastructure
*** ERROR: terraform validate failed for community/examples/tutorial-starccm.yaml, logs in /tmp/tmp.CwSdoL9Ndg/tutorial-starccm-cwsdol9ndg/primary
*** ERROR: terraform validate failed for tools/validate_configs/test_configs/apt-collision.yaml, logs in /tmp/tmp.lTIFFVPsP5/apt-collision-ltiffvpsp5/primary
*** ERROR: terraform validate failed for tools/validate_configs/test_configs/exascaler-new-vpc.yaml, logs in /tmp/tmp.MO4zWqxsHX/exascaler-new-vpc-mo4zwqxshx/primary
*** ERROR: terraform validate failed for community/examples/hpc-gke.yaml, logs in /tmp/tmp.Kxwk2imD18/hpc-gke-kxwk2imd18/primary
*** ERROR: terraform init failed for tools/validate_configs/test_configs/remote-desktop.yaml, logs in /tmp/tmp.3qEndfZWkq/remote-desktop-3qendfzwkq/primary
*** ERROR: terraform init failed for tools/validate_configs/test_configs/slurm-gcp-v5-startup-scripts.yaml, logs in /tmp/tmp.ejYYR5i14E/slurm-gcp-v5-startup-scripts-ejyyr5i14e/primary
*** ERROR: terraform init failed for examples/hpc-slurm.yaml, logs in /tmp/tmp.0EjXSgzbsp/hpc-slurm-0ejxsgzbsp/primary
*** ERROR: terraform init failed for community/examples/htc-slurm.yaml, logs in /tmp/tmp.ztxnGGOJSt/htc-slurm-ztxnggojst/primary
*** ERROR: terraform init failed for community/examples/hpc-slurm-ubuntu2004.yaml, logs in /tmp/tmp.jOoCfrPMxN/hpc-slurm-ubuntu2004-joocfrpmxn/primary
*** ERROR: terraform init failed for community/examples/hpc-slurm-ramble-gromacs.yaml, logs in /tmp/tmp.hasbRpm1VQ/hpc-slurm-ramble-gromacs-hasbrpm1vq/primary
*** ERROR: terraform init failed for tools/validate_configs/test_configs/hpc-cluster-project.yaml, logs in /tmp/tmp.eN8KCsCCNb/hpc-cluster-project-en8kcsccnb/onboarding
*** ERROR: terraform validate failed for community/examples/quantum-circuit-simulator.yaml, logs in /tmp/tmp.BrZh9KOAOG/quantum-circuit-simulator-brzh9koaog/primary
*** ERROR: terraform init failed for tools/validate_configs/test_configs/centos8-ss.yaml, logs in /tmp/tmp.V2VDx0Jd7t/centos8-ss-v2vdx0jd7t/primary
*** ERROR: terraform validate failed for community/examples/client-google-cloud-storage.yaml, logs in /tmp/tmp.3hDUlE93U5/client-google-cloud-storage-3hdule93u5/primary
*** ERROR: terraform init failed for tools/validate_configs/test_configs/gpu.yaml, logs in /tmp/tmp.7Bgsu0X4Rm/gpu-7bgsu0x4rm/high-count-manual
*** ERROR: terraform init failed for examples/hpc-enterprise-slurm.yaml, logs in /tmp/tmp.HK9WiS3Yse/hpc-enterprise-slurm-hk9wis3yse/primary
*** ERROR: terraform init failed for community/examples/htc-htcondor.yaml, logs in /tmp/tmp.aIDmGdtSG9/htc-htcondor-aidmgdtsg9/htcondor
*** ERROR: terraform init failed for community/examples/ml-gke.yaml, logs in /tmp/tmp.hZKhGo7kSl/ml-gke-hzkhgo7ksl/primary
*** ERROR: terraform init failed for community/examples/slurm-chromedesktop.yaml, logs in /tmp/tmp.Q07Ln4cH8M/slurm-chromedesktop-q07ln4ch8m/primary
*** ERROR: terraform init failed for tools/validate_configs/test_configs/overwrite_labels.yaml, logs in /tmp/tmp.k89oNJmsmd/overwrite_labels-k89onjmsmd/infrastructure
*** ERROR: terraform init failed for community/examples/intel/hpc-intel-select-slurm.yaml, logs in /tmp/tmp.S1DML9tN2s/hpc-intel-select-slurm-s1dml9tn2s/primary
*** ERROR: terraform init failed for examples/image-builder.yaml, logs in /tmp/tmp.bkkBSPevVo/image-builder-bkkbspevvo/primary
*** ERROR: terraform init failed for tools/validate_configs/test_configs/test_outputs.yaml, logs in /tmp/tmp.amDVFm8sM8/test_outputs-amdvfm8sm8/primary
*** ERROR: terraform init failed for community/examples/AMD/hpc-amd-slurm.yaml, logs in /tmp/tmp.0CpsC4GTeB/hpc-amd-slurm-0cpsc4gteb/primary
*** ERROR: terraform init failed for tools/validate_configs/test_configs/hpc-cluster-simple-nfs-sql.yaml, logs in /tmp/tmp.sTn3Iwdb6k/hpc-cluster-simple-nfs-sql-stn3iwdb6k/primary
*** ERROR: terraform init failed for tools/validate_configs/test_configs/timeout_test.yaml, logs in /tmp/tmp.YlZL47M5H4/timeout_test-ylzl47m5h4/primary
*** ERROR: terraform init failed for tools/validate_configs/test_configs/complex-data.yaml, logs in /tmp/tmp.kuPdGwQtk5/complex-data-kupdgwqtk5/infrastructure
*** ERROR: terraform init failed for tools/validate_configs/test_configs/use-resources.yaml, logs in /tmp/tmp.tXF837X4l8/use-resources-txf837x4l8/primary
*** ERROR: terraform init failed for tools/validate_configs/test_configs/node-groups.yaml, logs in /tmp/tmp.nGvlBumi0j/node-groups-ngvlbumi0j/primary
*** ERROR: terraform init failed for tools/validate_configs/test_configs/hpc-cluster-service-acct.yaml, logs in /tmp/tmp.AONRPJVoY6/hpc-cluster-service-acct-aonrpjvoy6/primary
*** ERROR: a test failed. Exiting with status 1.

0 comments on commit cb4c67e

Please sign in to comment.