Skip to content

fix: disable Gunicorn's control socket - #370

Merged
uniqueg merged 4 commits into
devfrom
fix/gunicorn-control-socket
Oct 22, 2026
Merged

uniqueg merged 4 commits into
devfrom
fix/gunicorn-control-socket

Conversation

@uniqueg

@uniqueg uniqueg commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

Summary

Gunicorn 25.1 and later start a control server for gunicornc and create its socket in $XDG_RUNTIME_DIR or $HOME/.gunicorn. On the read-only root file system of the foca-common chart, it logs Control server error: Read-only file system: '/home/foca/.gunicorn' at startup (found in the kind install test, #365).

  • examples/petstore/Dockerfile: start Gunicorn with --no-control-socket (the app does not use the control interface; the image pins Gunicorn 26.2.0).
  • docs/deployment.md: the production Dockerfile example does the same, with a "Things to keep in mind" bullet (needs Gunicorn 25.1 or later; older versions reject the flag).
  • docs/helm-chart.md: the Gunicorn bullet says to disable the control socket in the image or via extraArgs.
  • .github/workflows/charts.yml: the kind install job now fails if the app's pods log errors (Gunicorn's [ERROR] or FOCA's ERROR ] format), as a regression check for this and similar errors that don't fail the install.

The chart does not add --no-control-socket itself: it can't know the image's Gunicorn version, and Gunicorn before 25.1 exits on the unknown flag. Apps can already pass it via <valuesKey>.gunicorn.extraArgs.

Light lane: only changes the example image's command (configuration), docs and a CI check (no secrets, permissions or release workflows); no reviewer subagents, no 15-minute Sourcery wait.

Verification

  • Reproduced with Gunicorn 26.2.0 and an unwritable HOME (HOME=/proc): without the flag, [ERROR] Control server error: ... '/proc/.gunicorn'; with --no-control-socket, no error.
  • --no-control-socket exists in Gunicorn 25.1.0, 25.2.0, 25.3.0, 26.0.0, 26.2.0, not in 24.1.1 or 25.0.0 (gunicorn --help).
  • actionlint (with shellcheck) on charts.yml: clean; git diff --check: clean.
  • mkdocs build --strict: passes.
  • CI: all checks pass, incl. the kind install with the new log check (Gunicorn 26.2.0 starts without the control server error).

Open questions

None.

Closes #369

🤖 Generated with Claude Code

Summary by Sourcery

Disable Gunicorn's unused control socket in deployment guidance and strengthen chart CI checks for startup errors.

Bug Fixes:

  • Prevent Gunicorn startup errors in read-only chart environments by disabling its unused control socket in the petstore and production deployment examples.

Enhancements:

  • Document Gunicorn control-socket requirements and configuration options for Docker and Helm deployments.

CI:

  • Add a chart installation regression check that fails when application pods emit Gunicorn or FOCA-formatted error logs.

Gunicorn 25.1 and later create a control socket for gunicornc in
$XDG_RUNTIME_DIR or $HOME/.gunicorn and log "Control server error" at
startup if that is not writable, as on the read-only root file system
of the Helm chart. Start the petstore example's Gunicorn with
--no-control-socket, as the app does not use it, do the same in the
production Dockerfile example and document it for the chart. The kind
install test now fails if the app logs errors.

Closes #369

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@sourcery-ai

sourcery-ai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

The PR prevents Gunicorn 25.1+ from creating an unusable control socket in the read-only chart environment by updating the example image and deployment guidance, while strengthening the kind install workflow to fail on startup errors visible only in application logs.

Sequence diagram for Gunicorn startup without a control socket

sequenceDiagram
    participant Pod
    participant Gunicorn
    participant App
    Pod->>Gunicorn: start --no-control-socket
    Gunicorn->>App: create_app()
    Gunicorn-->>Pod: serve HTTP requests
Loading

Flow diagram for Kubernetes application log regression checking

flowchart TD
    A[Install petstore chart] --> B[Collect app pod logs]
    B --> C{grep Gunicorn or FOCA error format}
    C -->|error found| D[Fail workflow]
    C -->|no error found| E[Continue CI]
Loading

File-Level Changes

Change Details Files
Disable Gunicorn’s control socket in the example production commands to avoid startup errors on read-only filesystems.
  • Add --no-control-socket to the petstore image command.
  • Add the flag to the documented production Dockerfile and explain its Gunicorn version requirement and runtime implications.
examples/petstore/Dockerfile
docs/deployment.md
Document how Helm chart users should configure Gunicorn when the root filesystem is read-only.
  • Recommend configuring the flag in the image or through gunicorn.extraArgs.
  • Explain that the chart cannot add the flag automatically because older Gunicorn versions reject it.
docs/helm-chart.md
Add a kind-install regression check that detects application errors which Kubernetes installation status does not report.
  • Collect and print app pod logs after chart installation.
  • Fail the workflow when Gunicorn [ERROR] or FOCA ERROR log patterns are found.
.github/workflows/charts.yml

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@codecov

codecov Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (908b4d0) to head (3fea5b0).

Additional details and impacted files
@@            Coverage Diff            @@
##               dev      #370   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           25        25           
  Lines         2006      2006           
=========================================
  Hits          2006      2006           
Flag Coverage Δ
test_unit 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

FOCA logs errors as "ERROR   ]", not as Gunicorn's "[ERROR]".

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@uniqueg
uniqueg marked this pull request as ready for review October 22, 2026 00:34

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="docs/deployment.md" line_range="60" />
<code_context>
 USER 1000
 COPY ./ /app
-CMD ["gunicorn", "--bind", "0.0.0.0:8080", "--workers", "4", "wsgi:create_app()"]
+CMD ["gunicorn", "--bind", "0.0.0.0:8080", "--workers", "4", "--no-control-socket", "wsgi:create_app()"]
 ```

</code_context>
<issue_to_address>
**Shell example still emits socket error**

When the generic command is used to run Gunicorn in the chart’s read-only container, the generic Gunicorn command above the Dockerfile example still omits `--no-control-socket`, so users who use it in the chart’s read-only container get a control-server startup error in the app logs.

Add `--no-control-socket` to the generic command example, with the Gunicorn 25.1 version requirement noted.
</issue_to_address>

Sourcery assessment

Approval pending. 1 finding to address first.

Blocking findings: docs/deployment.md:60


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread docs/deployment.md Resolved
uniqueg and others added 2 commits October 22, 2026 02:44
The command-line example matches the Dockerfile example now.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sourcery assessment

Approved.

@uniqueg
uniqueg merged commit 09cc190 into dev Oct 22, 2026
15 checks passed
@uniqueg
uniqueg deleted the fix/gunicorn-control-socket branch October 22, 2026 00:48
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