Skip to content

[INFRA-456] - feat(plane-enterprise): expose gunicorn rotation and Celery broker envs; add PLANE_INTERNAL_API_HOST to pi-api - #271

Closed
akshat5302 wants to merge 6 commits into
masterfrom
feat/gunicorn-celery-envs
Closed

[INFRA-456] - feat(plane-enterprise): expose gunicorn rotation and Celery broker envs; add PLANE_INTERNAL_API_HOST to pi-api#271
akshat5302 wants to merge 6 commits into
masterfrom
feat/gunicorn-celery-envs

Conversation

@akshat5302

@akshat5302 akshat5302 commented Jul 23, 2026

Copy link
Copy Markdown
Member

What

Adds 5 new env vars to the plane-enterprise chart across two ConfigMaps:

app-vars ConfigMap (templates/config-secrets/app-env.yaml):

GUNICORN_MAX_REQUESTS: "1000"       # env.gunicorn_max_requests
GUNICORN_MAX_REQUESTS_JITTER: "150" # env.gunicorn_max_requests_jitter
CELERY_TASK_PUBLISH_RETRY: "True"   # env.celery_task_publish_retry
CELERY_BROKER_POOL_LIMIT: "10"      # env.celery_broker_pool_limit

pi-api-vars ConfigMap (templates/config-secrets/pi-api-env.yaml):

PLANE_INTERNAL_API_HOST: "http://<release>-api.<namespace>.svc.<cluster-domain>:8000"

Defaults declared in values.yaml; Rancher form entries added in questions.yml; README table updated.

Chart version bumped 3.0.0 → 3.0.2.

Why

Reported in #261 (leedsjb): a 50% silent CSV export failure rate caused by two compounding issues:

  1. Gunicorn worker rotation--max-requests 1200 is hardcoded in the image entrypoint, rotating each worker every ~1,200–2,200 requests. Each rotation produces a ~10–30 s AMQP reconnect window. During that window, task.delay() either hits a broken connection (returning without raising) or writes to a kernel-accepted-but-broker-closed socket — both paths silently discard the task, leaving the exporters record stuck in "queued" forever.

  2. No publish retry + unbounded broker pool — without CELERY_TASK_PUBLISH_RETRY, Kombu treats a failed publish as final. Without a pool limit, stale connections accumulate and are reused without health-checking.

PLANE_INTERNAL_API_HOST is added so PI can reach the backend API directly over the cluster network without going through the ingress.

Scope / behavior

Var Default Changes default behavior?
GUNICORN_MAX_REQUESTS 1000 Yes — sets a sensible rotation limit. Image previously hardcoded 1200; set to 0 to disable rotation entirely.
GUNICORN_MAX_REQUESTS_JITTER 150 Yes — staggers worker restarts. Set to 0 when rotation is disabled.
CELERY_TASK_PUBLISH_RETRY True Yes — enables publish retry on all deployments.
CELERY_BROKER_POOL_LIMIT 10 Yes — bounds the previously unlimited pool. Set to 0 to disable pooling.
PLANE_INTERNAL_API_HOST in-cluster API URL Not configurable; always renders to http://<release>-api.<ns>.svc.<domain>:8000.

Note on 0 overrides: GUNICORN_MAX_REQUESTS, GUNICORN_MAX_REQUESTS_JITTER, and CELERY_BROKER_POOL_LIMIT all support 0 as a meaningful value (disables rotation / pooling). The template intentionally omits | default N in favor of relying on values.yaml defaults — Helm's default filter treats 0 as falsy and would silently override an explicit --set env.gunicorn_max_requests=0 with the fallback value.

GUNICORN_MAX_REQUESTS and GUNICORN_MAX_REQUESTS_JITTER only take effect if the image entrypoint reads these env vars (the fix in the application image is a prerequisite for the rotation changes to work). CELERY_TASK_PUBLISH_RETRY and CELERY_BROKER_POOL_LIMIT are Celery settings consumed by the Django/Celery app directly.

PLANE_INTERNAL_API_HOST is rendered unconditionally whenever services.pi.enabled=true (the template is already gated by that condition).

Testing

helm lint — clean, 0 failures.

helm template output (defaults):

GUNICORN_MAX_REQUESTS: "1000"
GUNICORN_MAX_REQUESTS_JITTER: "150"
CELERY_TASK_PUBLISH_RETRY: "True"
CELERY_BROKER_POOL_LIMIT: "10"
PLANE_INTERNAL_API_HOST: "http://test-api.default.svc.cluster.local:8000"

helm template with --set env.gunicorn_max_requests=0 --set env.gunicorn_max_requests_jitter=0 --set env.celery_task_publish_retry=false --set env.celery_broker_pool_limit=0:

GUNICORN_MAX_REQUESTS: "0"
GUNICORN_MAX_REQUESTS_JITTER: "0"
CELERY_TASK_PUBLISH_RETRY: "False"
CELERY_BROKER_POOL_LIMIT: "0"

Related

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added configuration options for Gunicorn worker rotation and jitter.
    • Added Celery task retry and broker connection pool settings.
    • Added an internal API host configuration for improved service connectivity.
    • Documented the new deployment settings and their defaults.
  • Improvements

    • Celery retry settings now use consistent 1/0 values.
    • Updated the enterprise Helm chart version to 3.0.1.

akshat5302 and others added 3 commits July 23, 2026 15:47
…v vars

Add GUNICORN_MAX_REQUESTS, GUNICORN_MAX_REQUESTS_JITTER,
CELERY_TASK_PUBLISH_RETRY, and CELERY_BROKER_POOL_LIMIT to the
app-vars ConfigMap so operators can tune worker rotation and broker
pool behaviour without rebuilding the image.

Defaults set to Kubernetes-friendly values (rotation disabled,
publish retry enabled, pool bounded to 10) to eliminate the
silent task-dispatch failures reported in issue #261.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ERNAL_API_HOST to pi-api

Add to app-vars ConfigMap (configurable via values.yaml):
- GUNICORN_MAX_REQUESTS (default 0 — rotation disabled, recommended for K8s)
- GUNICORN_MAX_REQUESTS_JITTER (default 0)
- CELERY_TASK_PUBLISH_RETRY (default True — prevent silent task drops on AMQP reconnect)
- CELERY_BROKER_POOL_LIMIT (default 10 — bound connection pool to avoid stale accumulation)

Add to pi-api-vars ConfigMap (hardcoded internal cluster URL):
- PLANE_INTERNAL_API_HOST — points directly to the in-cluster API service

Fixes the silent CSV export failures reported in issue #261 where
gunicorn worker rotation caused stale AMQP connections to silently
discard published tasks.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ETRY

Align with existing boolean pattern (ternary without default) so that
setting celery_task_publish_retry: false in values.yaml is respected.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 17ffdd07-47a5-4e32-89d2-b547ed57e3a8

📥 Commits

Reviewing files that changed from the base of the PR and between f7a672e and 6e78498.

📒 Files selected for processing (2)
  • charts/plane-enterprise/README.md
  • charts/plane-enterprise/templates/config-secrets/app-env.yaml
🚧 Files skipped from review as they are similar to previous changes (1)
  • charts/plane-enterprise/README.md

Walkthrough

The enterprise Helm chart adds configurable Gunicorn and Celery environment settings, renders them into application configuration, adds an internal API host, documents the new options, and increments the chart version.

Changes

Enterprise chart configuration

Layer / File(s) Summary
Environment tuning configuration
charts/plane-enterprise/values.yaml, charts/plane-enterprise/questions.yml, charts/plane-enterprise/README.md, charts/plane-enterprise/templates/config-secrets/app-env.yaml
Adds Gunicorn request-rotation and Celery retry/broker-pool settings, with defaults, configuration questions, documentation, and ConfigMap rendering.
Internal API host and chart release metadata
charts/plane-enterprise/Chart.yaml, charts/plane-enterprise/templates/config-secrets/pi-api-env.yaml
Updates the chart version to 3.0.1 and adds the in-cluster PLANE_INTERNAL_API_HOST value to the PI API ConfigMap.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: pratapalakshmi, mguptahub

Poem

A rabbit hops through Helm’s bright tune,
Four new knobs rise beneath the moon.
Gunicorn spins, Celery sings,
An inner API sprouts its wings.
Chart 3.0.1 greets spring.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main chart changes: new Gunicorn, Celery, and PI API environment variables.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/gunicorn-celery-envs

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@makeplane

makeplane Bot commented Jul 23, 2026

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@charts/plane-enterprise/README.md`:
- Around line 503-504: Update the Celery settings entries
env.celery_task_publish_retry and env.celery_broker_pool_limit in the README
configuration documentation to place them in a shared API/worker environment
section or explicitly identify both workloads as consumers. Preserve their
existing defaults and descriptions.

In `@charts/plane-enterprise/templates/config-secrets/app-env.yaml`:
- Line 82: Update the CELERY_BROKER_POOL_LIMIT template expression to preserve
an explicitly configured value of 0 instead of allowing default to replace it
with 10. Use presence-based handling such as hasKey on
.Values.env.celery_broker_pool_limit, while retaining 10 only when the key is
absent.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 30bc2b85-10b9-4fc4-b6b0-7c1bedd3e104

📥 Commits

Reviewing files that changed from the base of the PR and between bfd3047 and dfa566f.

📒 Files selected for processing (6)
  • charts/plane-enterprise/Chart.yaml
  • charts/plane-enterprise/README.md
  • charts/plane-enterprise/questions.yml
  • charts/plane-enterprise/templates/config-secrets/app-env.yaml
  • charts/plane-enterprise/templates/config-secrets/pi-api-env.yaml
  • charts/plane-enterprise/values.yaml

Comment thread charts/plane-enterprise/README.md Outdated
Comment thread charts/plane-enterprise/templates/config-secrets/app-env.yaml Outdated
akshat5302 and others added 2 commits July 24, 2026 13:42
@akshat5302

Copy link
Copy Markdown
Member Author

Superseded by #276 which combines this with #272.

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