Skip to content

cron pod is now always deleted gracefully#72

Open
henzigo wants to merge 2 commits intojg/webserver-probesfrom
jg/cron-graceful-shutdown
Open

cron pod is now always deleted gracefully#72
henzigo wants to merge 2 commits intojg/webserver-probesfrom
jg/cron-graceful-shutdown

Conversation

@henzigo
Copy link
Copy Markdown
Member

@henzigo henzigo commented Apr 15, 2026

No description provided.

@henzigo henzigo changed the title Jg/cron graceful shutdown cron pod is now always deleted gracefully Apr 15, 2026
@henzigo henzigo requested a review from Copilot April 15, 2026 18:01
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the Kubernetes cron Deployment and deploy flow so cron workloads are stopped via Kubernetes mechanisms (scale-down + preStop) to allow in-flight cron executions to finish before the pod is terminated, and consolidates cron resources into the main webserver kustomization output.

Changes:

  • Move cron resources (Deployment + configmaps) into the kustomize/webserver build output and remove the separate kustomize/cron layer and expected cron.yaml fixtures.
  • Update the cron Deployment to use Recreate, add a long termination grace period, and replace the old sleep preStop with a deploy:cron:lock + deploy:cron:watch shutdown sequence.
  • Update deploy script to scale deployment/cron to 0 and wait for rollout prior to running migrations.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/scenarios/production-with-cloudflare/expected/webserver.yaml Expected manifest now includes cron configmaps + cron Deployment in the webserver output.
tests/scenarios/production-with-cloudflare/expected/cron.yaml Removed expected cron-only output (cron now part of webserver output).
tests/scenarios/escaping-env/expected/webserver.yaml Expected manifest now includes cron configmaps + cron Deployment in the webserver output.
tests/scenarios/escaping-env/expected/cron.yaml Removed expected cron-only output (cron now part of webserver output).
tests/scenarios/development-single-domain/expected/webserver.yaml Expected manifest now includes cron configmaps + cron Deployment in the webserver output.
tests/scenarios/development-single-domain/expected/cron.yaml Removed expected cron-only output (cron now part of webserver output).
tests/scenarios/basic-production/expected/webserver.yaml Expected manifest now includes cron configmaps + cron Deployment in the webserver output.
tests/scenarios/basic-production/expected/cron.yaml Removed expected cron-only output (cron now part of webserver output).
kubernetes/kustomize/webserver/kustomization.yaml Adds cron Deployment + cron configmaps to the webserver kustomization resources list.
kubernetes/kustomize/cron/kustomization.yaml Removes the standalone cron kustomization.
kubernetes/deployments/cron.yaml Updates cron rollout/termination behavior and adds preStop lock+watch shutdown logic.
deploy/parts/deploy.sh Switches from in-pod locking/watching to scaling cron down/up around migrations.
UPGRADE.md Documents the behavioral change for v5.1.0 upgrades.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread deploy/parts/deploy.sh
Comment on lines +61 to +75
command: ["/bin/sh","-lc"]
args:
- >
./phing warmup > /dev/null

# FIFO for logs
rm -f /tmp/log-pipe && mkfifo /tmp/log-pipe && chmod 666 /tmp/log-pipe

# crontab
crontab -u root /var/spool/cron/template

# run on backround
stdbuf -o0 tail -n +1 -f /tmp/log-pipe &

exec crond -f || exec cron -f
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

args uses a folded block scalar (>) while also including shell comment lines (e.g. # FIFO for logs). YAML folding joins the # ... line with the next command into a single shell line, causing the following command(s) to be commented out at runtime (e.g. rm -f ..., crontab ..., stdbuf ...). Use a literal block scalar (|) or remove/move the # comment lines so each command remains on its own line when executed.

Copilot uses AI. Check for mistakes.
Comment on lines +63 to +75
- >
./phing warmup > /dev/null

# FIFO for logs
rm -f /tmp/log-pipe && mkfifo /tmp/log-pipe && chmod 666 /tmp/log-pipe

# crontab
crontab -u root /var/spool/cron/template

# run on backround
stdbuf -o0 tail -n +1 -f /tmp/log-pipe &

exec crond -f || exec cron -f
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

The previous single-line args used &&, so failures in ./phing warmup, FIFO setup, or crontab would stop the container and surface the error. With the new multi-line script, failures won’t stop execution unless you explicitly enable fail-fast (e.g., set -e near the top) or reintroduce && chaining for the critical steps.

Copilot uses AI. Check for mistakes.
# crontab
crontab -u root /var/spool/cron/template

# run on backround
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

Typo in the shell comment: “backround” → “background”.

Suggested change
# run on backround
# run in background

Copilot uses AI. Check for mistakes.
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