Skip to content

ECI-1625: (fix) add depends_on to prevent race condition in default security list#119

Merged
yuhuyoyo merged 1 commit into
masterfrom
yu.hu/eci-1625-fix-race-condition
May 5, 2026
Merged

ECI-1625: (fix) add depends_on to prevent race condition in default security list#119
yuhuyoyo merged 1 commit into
masterfrom
yu.hu/eci-1625-fix-race-condition

Conversation

@yuhuyoyo
Copy link
Copy Markdown
Contributor

@yuhuyoyo yuhuyoyo commented May 5, 2026

What

Add depends_on = [module.vcn] to oci_core_default_security_list.dd_default in both datadog-integration and datadog-terraform-onboarding regional-stacks modules.

Why

PR #99 (CLOUDS-7599) introduced a race condition where two Terraform resources simultaneously manage the same VCN default security list via manage_default_resource_id:

  • Resource 1: module.vcn[0] (upstream oracle-terraform-modules/vcn/oci) internally creates oci_core_default_security_list.lockdown, which writes empty rules (no egress, no ingress) and has lifecycle { ignore_changes = [...] }.
  • Resource 2: oci_core_default_security_list.dd_default — writes the correct minimal rules: egress-all (required for OCIR image pulls) + two ICMP-only ingress rules.

Both target the same security list ID. The OCI audit log shows two UpdateSecurityList calls ~158ms apart during apply. If lockdown wins the race, the list is left with empty egress — functions cannot reach OCIR → 502 FunctionInvokeImageNotAvailable. Because lockdown has ignore_changes, Terraform won't self-correct on subsequent applies.

depends_on = [module.vcn] enforces ordering: the entire VCN module (including its hidden lockdown resource) completes before dd_default writes the correct rules. Since lockdown has ignore_changes, it won't overwrite dd_default afterward.

References

Two Terraform resources (module.vcn's lockdown resource and
oci_core_default_security_list.dd_default) both manage the same VCN
default security list. Without explicit ordering, they can apply
concurrently: if lockdown wins, the list is left with empty egress rules
and functions cannot reach OCIR, causing FunctionInvokeImageNotAvailable.

Adding depends_on = [module.vcn] ensures the VCN module (and its
lockdown resource) completes before dd_default writes the correct egress
rules. Since lockdown has ignore_changes, it will not overwrite
dd_default on subsequent applies.

Fixes: ECI-1625

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@yuhuyoyo yuhuyoyo force-pushed the yu.hu/eci-1625-fix-race-condition branch from 9231e53 to 65c3683 Compare May 5, 2026 14:50
@yuhuyoyo yuhuyoyo requested a review from sva91 May 5, 2026 14:51
@yuhuyoyo yuhuyoyo changed the title fix: add depends_on to prevent race condition in default security list (ECI-1625) ECI-1625: (fix) add depends_on to prevent race condition in default security list May 5, 2026
@yuhuyoyo yuhuyoyo marked this pull request as ready for review May 5, 2026 14:52
Copy link
Copy Markdown
Contributor

@sva91 sva91 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@yuhuyoyo yuhuyoyo merged commit 5322fb8 into master May 5, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants