Skip to content

Add semaphore to limit concurrent API calls during Kubernetes observer startup#11

Open
tomerqodo wants to merge 2 commits intocodex_full_base_add_semaphore_to_limit_concurrent_api_calls_during_kubernetes_observer_startup_pr11from
codex_full_head_add_semaphore_to_limit_concurrent_api_calls_during_kubernetes_observer_startup_pr11
Open

Add semaphore to limit concurrent API calls during Kubernetes observer startup#11
tomerqodo wants to merge 2 commits intocodex_full_base_add_semaphore_to_limit_concurrent_api_calls_during_kubernetes_observer_startup_pr11from
codex_full_head_add_semaphore_to_limit_concurrent_api_calls_during_kubernetes_observer_startup_pr11

Conversation

@tomerqodo
Copy link
Copy Markdown

Benchmark PR from agentic-review-benchmarks#11

desertaxle and others added 2 commits January 25, 2026 12:10
…r startup

closes PrefectHQ#19937

When the observer starts, it receives events for all existing pods/jobs
and checks for duplicates via API calls. This can overwhelm the server
when there are many pods. This change adds a configurable semaphore
(default: 5 concurrent calls) to rate-limit these startup checks.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5297067fd8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 153 to +156
response = await orchestration_client.request(
"POST",
"/events/filter",
json=dict(filter=event_filter.model_dump(exclude_unset=True, mode="json")),
json=dict(
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep the semaphore held during the API request

The startup semaphore is acquired only while building event_filter, but the actual orchestration_client.request happens after the async with block has exited (see the request at lines 153-156). This means concurrent startup events still send API calls without any throttling, so the intended protection against API overload when many existing pods/jobs are present does not actually take effect. Consider keeping the request inside the semaphore scope.

Useful? React with 👍 / 👎.

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