Support sequential regional stack applies - #181
Support sequential regional stack applies#181gh-worker-dd-mergequeue-cf854d[bot] merged 6 commits into
Conversation
Allow Quick Start deployments to avoid OCI concurrent Resource Manager job limits while preserving parallel applies by default. Co-Authored-By: Claude <noreply@anthropic.com>
|
Version bumped: Override if needed:
|
There was a problem hiding this comment.
The shared script sends invalid defined-tag data to every regional child stack. The Quick Start schema also cannot set the new sequential option.
🤖 Datadog Autotest · Commit 9d8d653 · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest
| --arg home_region "$HOME_REGION" \ | ||
| --arg region_key "$REGION_KEY" \ | ||
| --arg subnet_ocid "$SUBNET_OCID" \ | ||
| --arg defined_tags "$DEFINED_TAGS" \ |
There was a problem hiding this comment.
Remove the extra defined-tags encoding
Every regional child-stack apply can fail when OCI resources receive a string instead of a tag map.
Assertion details
- Input: Any regional stack apply, including the default empty defined-tags value.
- Expected:
The child stack must receive defined_tags as one JSON-encoded map string. - Actual:
The caller passes a JSON-encoded string. jq encodes it again. The child stack then decodes it to a string instead of a map.
| --arg defined_tags "$DEFINED_TAGS" \ | |
| --argjson defined_tags "$DEFINED_TAGS" \ |
Was this helpful? React 👍 or 👎
🤖 Datadog Autotest · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest
There was a problem hiding this comment.
we might want to test the json encoding for this since I remember the behavior was weird when I first added it
There was a problem hiding this comment.
Tested — the encoding is correct now. Verified with a live apply using defined_tags="datadog.env:test": the plan showed "datadog.env" = "test" on resources and the apply succeeded. The earlier weirdness was the double jsonencode(jsonencode(...)) which was fixed in 18017fa; the current single-encode + jq --arg path is right.
| STACK_ID=$(oci resource-manager stack create --compartment-id "$COMPARTMENT_ID" --display-name "$STACK_NAME" \ | ||
| --config-source ./modules/regional-stacks/dd_regional_stack.zip --variables "$VARIABLES_JSON" \ | ||
| --terraform-version 1.5.x \ | ||
| $DEFINED_TAGS_FLAG \ |
There was a problem hiding this comment.
Pass defined tags as separate shell arguments
Quick Start deployments with defined tags can fail when the script creates, updates, or applies a regional stack.
Assertion details
- Input: A Quick Start deployment with one or more defined tags.
- Expected:
Pass --defined-tags and its JSON value as separate shell arguments. Apply this handling to stack create, stack update, and apply-job creation. - Actual:
The caller builds the flag and JSON as one shell value. Shell expansion removes or retains quote characters as data, so OCI receives invalid JSON.
Was this helpful? React 👍 or 👎
🤖 Datadog Autotest · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest
| default = "" | ||
| } | ||
|
|
||
| variable "apply_regional_stacks_sequentially" { |
There was a problem hiding this comment.
Expose the sequential option in Quick Start
Users with low concurrent-job limits cannot enable the sequential mode through the intended Quick Start flow.
Assertion details
- Input: A user starts or reapplies the integration through OCI Quick Start and needs sequential regional jobs.
- Expected:
Declare the option in datadog-integration/schema.yaml and add it to a suitable variable group. - Actual:
The Terraform variable exists, but schema.yaml does not declare it or show it in a variable group. Quick Start therefore keeps the false default.
Was this helpful? React 👍 or 👎
🤖 Datadog Autotest · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest
There was a problem hiding this comment.
A failed non-final regional apply does not stop the sequential loop. A later successful region can make Terraform report success and register an incomplete integration.
🤖 Datadog Autotest · Commit 18017fa · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest
| FAILURE=$(echo "$REGIONS_JSON" | jq -r --arg region "$REGION" '.[$region].failure') | ||
| REGION_KEY=$(echo "$REGIONS_JSON" | jq -r --arg region "$REGION" '.[$region].region_key') | ||
| SUBNET_OCID=$(echo "$REGIONS_JSON" | jq -r --arg region "$REGION" '.[$region].subnet_ocid') | ||
| bash ./create_apply_regional_stack.sh "$REGION" "$FAILURE" "$REGION_KEY" "$SUBNET_OCID" '${module.compartment.id}' '${terraform_data.stack_digest.id}' '${var.tenancy_ocid}' '${var.datadog_site}' '${module.kms[0].api_key_secret_id}' '${local.home_region_name}' '${jsonencode(local.defined_tags)}' '${var.enable_regional_vaults}' '${jsonencode(local.compartment_defined_tags)}' |
There was a problem hiding this comment.
Stop after a failed sequential regional apply
Terraform can register the integration as successful while regional infrastructure is missing.
Assertion details
- Input: Set apply_regional_stacks_sequentially to true. Let a non-final regional apply fail. Let a later region succeed or exit as unsupported.
- Expected:
The provisioner must stop and return a nonzero status when any regional apply fails. - Actual:
The loop continues after the script returns a nonzero status. A later region can return zero and become the status of the complete provisioner command.
| bash ./create_apply_regional_stack.sh "$REGION" "$FAILURE" "$REGION_KEY" "$SUBNET_OCID" '${module.compartment.id}' '${terraform_data.stack_digest.id}' '${var.tenancy_ocid}' '${var.datadog_site}' '${module.kms[0].api_key_secret_id}' '${local.home_region_name}' '${jsonencode(local.defined_tags)}' '${var.enable_regional_vaults}' '${jsonencode(local.compartment_defined_tags)}' | |
| bash ./create_apply_regional_stack.sh "$REGION" "$FAILURE" "$REGION_KEY" "$SUBNET_OCID" '${module.compartment.id}' '${terraform_data.stack_digest.id}' '${var.tenancy_ocid}' '${var.datadog_site}' '${module.kms[0].api_key_secret_id}' '${local.home_region_name}' '${jsonencode(local.defined_tags)}' '${var.enable_regional_vaults}' '${jsonencode(local.compartment_defined_tags)}' || exit $? |
Was this helpful? React 👍 or 👎
🤖 Datadog Autotest · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest
There was a problem hiding this comment.
Fixed in 1492a2e — the loop now exits with a nonzero status on the first failed regional apply.
|
|
||
| variable "apply_regional_stacks_sequentially" { | ||
| type = bool | ||
| description = "Apply regional Resource Manager stacks sequentially to support tenancies with a low concurrent job limit. This setting only affects the Quick Start deployment; it has no effect when using the Terraform onboarding module directly." |
There was a problem hiding this comment.
Nit: Add that this should not be used unless the customer has stack quotas preventing parallel computation
There was a problem hiding this comment.
Done in 1492a2e — updated the schema.yaml description to: "Do not enable this unless the tenancy has a stack quota that prevents parallel Resource Manager jobs."
EamonBrady1
left a comment
There was a problem hiding this comment.
Approving to unblock the customer, but I think we definitely need to make it exit on a failed region since they are silently swallowed now, and I think we should also verify the defined_tags parsing with the new argument, since I know the behavior is weird with trying to pass it as a string versus a json list
|
Thanks Eamon. Both addressed in
Also tightened the schema.yaml description per your nit: "Do not enable this unless the tenancy has a stack quota that prevents parallel Resource Manager jobs." |
The concurrency limit applies to Resource Manager child jobs, so omit the option from direct Terraform onboarding where it would have no effect. Co-Authored-By: Claude <noreply@anthropic.com>
Make the Resource Manager concurrency workaround selectable from the Quick Start advanced options. Co-Authored-By: Claude <noreply@anthropic.com>
Pass child tags with a single JSON encoding and preserve OCI defined-tag JSON as one quoted CLI argument across regional stack operations. Co-Authored-By: Claude <noreply@anthropic.com>
The sequential regional-stack loop continued after a failed region's apply, letting a later succeeding region mask the failure and report overall success with an incomplete integration. Exit the loop with a nonzero status on the first failure so the parent apply fails loudly. Also clarify the schema.yaml description per review feedback: the sequential option should only be used when a tenancy stack quota prevents parallel Resource Manager jobs. Co-Authored-By: Claude <noreply@anthropic.com>
1492a2e to
57e2e8d
Compare
Summary
apply_regional_stacks_sequentiallyto Quick Start so deployments can opt out of concurrent OCI Resource Manager child jobsdatadog-integration; direct Terraform onboarding does not create Resource Manager child jobs and is unaffected by this limitTest plan
datadog-integration/schema.yamlas YAMLterraform fmt -check -recursive datadog-integration datadog-terraform-onboardingterraform -chdir=datadog-integration validateterraform -chdir=datadog-terraform-onboarding validatebash -n datadog-integration/create_apply_regional_stack.shdatad0g.com, andapply_regional_stacks_sequentially=truedd-vcnresources, or Datadog function applications remain across all subscribed regionsNotes
🤖 Generated with Claude Code