Skip to content

remove the need to sleep in remote config#6811

Draft
rochdev wants to merge 2 commits intomainfrom
rochdev/remove-remote-config-sleep
Draft

remove the need to sleep in remote config#6811
rochdev wants to merge 2 commits intomainfrom
rochdev/remove-remote-config-sleep

Conversation

@rochdev
Copy link
Copy Markdown
Member

@rochdev rochdev commented Apr 24, 2026

Motivation

Using sleep is always bad and is flaky by design.

Changes

From Claude:

Before: After the library acknowledged the config, time.sleep(2) was used as a blunt delay to give subprocesses (e.g., gunicorn workers) time to also apply it.

After: Before sending the config, we snapshot all runtime_ids already seen in /v0.7/config requests — one per process/worker polling RC. The remote_config_applied closure now only returns True once every known runtime_id has sent a request acknowledging the new config version. This is deterministic: on a single-process app it returns immediately after the first ACK (same as before minus the sleep), and on a multi-worker app it waits for every worker to confirm without sleeping at all.

The variable-shadowing bug in the original (for state in config_states overwrote the nonlocal state) was also fixed — loop variables are now cs and config_state.

Workflow

  1. ⚠️ Create your PR as draft ⚠️
  2. Work on you PR until the CI passes
  3. Mark it as ready for review
    • Test logic is modified? -> Get a review from RFC owner.
    • Framework is modified, or non obvious usage of it -> get a review from R&P team

🚀 Once your PR is reviewed and the CI green, you can merge it!

🛟 #apm-shared-testing 🛟

Reviewer checklist

  • Anything but tests/ or manifests/ is modified ? I have the approval from R&P team
  • A docker base image is modified?
    • the relevant build-XXX-image label is present
  • A scenario is added, removed or renamed?

@github-actions
Copy link
Copy Markdown
Contributor

CODEOWNERS have been resolved as:

utils/_remote_config.py                                                 @DataDog/system-tests-core

@datadog-prod-us1-3
Copy link
Copy Markdown
Contributor

datadog-prod-us1-3 Bot commented Apr 24, 2026

Tests

Fix all issues with BitsAI or with Cursor

⚠️ Warnings

🧪 995 Tests failed

tests.appsec.rasp.test_lfi.Test_Lfi_RC_CustomAction.test_lfi_get[apache-mod-7.0] from system_tests_suite   View in Datadog   (Fix with Cursor)
AssertionError: assert <RemoteConfigApplyState.UNKNOWN: 0> == <RemoteConfigApplyState.ACKNOWLEDGED: 2>
 +  where <RemoteConfigApplyState.UNKNOWN: 0> = <utils._remote_config.RemoteConfigStateResults object at 0x7f19c579b560>.state
 +    where <utils._remote_config.RemoteConfigStateResults object at 0x7f19c579b560> = <tests.appsec.rasp.test_lfi.Test_Lfi_RC_CustomAction object at 0x7f19f4a55a00>.config_state_1
 +  and   <RemoteConfigApplyState.ACKNOWLEDGED: 2> = <enum 'RemoteConfigApplyState'>.ACKNOWLEDGED
 +    where <enum 'RemoteConfigApplyState'> = rc.ApplyState

self = <tests.appsec.rasp.test_lfi.Test_Lfi_RC_CustomAction object at 0x7f19f4a55a00>

    def test_lfi_get(self):
>       assert self.config_state_1.state == rc.ApplyState.ACKNOWLEDGED
...
tests.appsec.rasp.test_lfi.Test_Lfi_RC_CustomAction.test_lfi_get[apache-mod-7.0] from system_tests_suite   View in Datadog   (Fix with Cursor)
AssertionError: assert <RemoteConfigApplyState.UNKNOWN: 0> == <RemoteConfigApplyState.ACKNOWLEDGED: 2>
 +  where <RemoteConfigApplyState.UNKNOWN: 0> = <utils._remote_config.RemoteConfigStateResults object at 0x7f40c47aafc0>.state
 +    where <utils._remote_config.RemoteConfigStateResults object at 0x7f40c47aafc0> = <tests.appsec.rasp.test_lfi.Test_Lfi_RC_CustomAction object at 0x7f40eaddf560>.config_state_1
 +  and   <RemoteConfigApplyState.ACKNOWLEDGED: 2> = <enum 'RemoteConfigApplyState'>.ACKNOWLEDGED
 +    where <enum 'RemoteConfigApplyState'> = rc.ApplyState

self = <tests.appsec.rasp.test_lfi.Test_Lfi_RC_CustomAction object at 0x7f40eaddf560>

    def test_lfi_get(self):
>       assert self.config_state_1.state == rc.ApplyState.ACKNOWLEDGED
...
tests.appsec.rasp.test_lfi.Test_Lfi_RC_CustomAction.test_lfi_get[apache-mod-7.0-zts] from system_tests_suite   View in Datadog   (Fix with Cursor)
AssertionError: assert <RemoteConfigApplyState.UNKNOWN: 0> == <RemoteConfigApplyState.ACKNOWLEDGED: 2>
 +  where <RemoteConfigApplyState.UNKNOWN: 0> = <utils._remote_config.RemoteConfigStateResults object at 0x7fc6e7fb0320>.state
 +    where <utils._remote_config.RemoteConfigStateResults object at 0x7fc6e7fb0320> = <tests.appsec.rasp.test_lfi.Test_Lfi_RC_CustomAction object at 0x7fc711ff3da0>.config_state_1
 +  and   <RemoteConfigApplyState.ACKNOWLEDGED: 2> = <enum 'RemoteConfigApplyState'>.ACKNOWLEDGED
 +    where <enum 'RemoteConfigApplyState'> = rc.ApplyState

self = <tests.appsec.rasp.test_lfi.Test_Lfi_RC_CustomAction object at 0x7fc711ff3da0>

    def test_lfi_get(self):
>       assert self.config_state_1.state == rc.ApplyState.ACKNOWLEDGED
...
View all

ℹ️ Info

No other issues found (see more)

❄️ No new flaky tests detected

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 9db3e94 | Docs | Datadog PR Page | Give us feedback!

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.

1 participant