Skip to content

cache warmup is now run as an init container#73

Open
henzigo wants to merge 1 commit intojg/cron-graceful-shutdownfrom
jg/warmup
Open

cache warmup is now run as an init container#73
henzigo wants to merge 1 commit intojg/cron-graceful-shutdownfrom
jg/warmup

Conversation

@henzigo
Copy link
Copy Markdown
Member

@henzigo henzigo commented Apr 15, 2026

No description provided.

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

Moves the application cache warmup step from a postStart lifecycle hook into a dedicated Kubernetes init container to ensure warmup completes before the main containers start.

Changes:

  • Updated webserver-php-fpm deployment template to add a warmup initContainer and remove the postStart hook.
  • Extended deployment generation script to inject environment variables into the new warmup initContainer.
  • Updated scenario expected manifests and documented the upgrade note.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/scenarios/production-with-cloudflare/expected/webserver.yaml Updates expected rendered manifest to reflect warmup as an initContainer.
tests/scenarios/escaping-env/expected/webserver.yaml Updates expected rendered manifest to reflect warmup as an initContainer.
tests/scenarios/development-single-domain/expected/webserver.yaml Updates expected rendered manifest to reflect warmup as an initContainer.
tests/scenarios/basic-production/expected/webserver.yaml Updates expected rendered manifest to reflect warmup as an initContainer.
kubernetes/deployments/webserver-php-fpm.yaml Adds warmup initContainer and removes postStart warmup hook from php-fpm.
deploy/parts/environment-variables.sh Injects env vars into the warmup initContainer in generated manifests.
UPGRADE.md Documents the behavioral change for upgrading users.

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

Comment on lines +86 to +94
- name: warmup
image: "{{TAG}}"
command: ["/var/www/html/phing", "-S", "warmup"]
volumeMounts:
- name: source-codes
mountPath: /var/www/html
- name: domains-urls
mountPath: /var/www/html/{{DOMAINS_URLS_FILEPATH}}
subPath: "{{DOMAINS_URLS_FILENAME}}"
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 warmup initContainer runs phing but doesn’t set workingDir. Elsewhere in this repo, containers that run phing explicitly set workingDir: /var/www/html (e.g., cron.yaml) or cd /var/www/html before invoking it, which suggests phing depends on the CWD to find the build file. Consider setting workingDir: /var/www/html for this initContainer (or wrapping the command with a cd) to avoid initContainer failures and pods stuck in Init state.

Copilot uses AI. Check for mistakes.
Comment on lines +45 to +46
\"name\": \"${key}\",
\"value\": \"${ENVIRONMENT_VARIABLES[$key]}\"
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.

This yq edit interpolates ${key} / ${ENVIRONMENT_VARIABLES[$key]} directly into the expression instead of using strenv(...) like the other env injections above. This can break when values contain quotes/newlines/backslashes and also risks yq-expression injection via unescaped content. Prefer reusing YQ_KEY/YQ_VALUE with strenv() (consistent with the other blocks) so values are safely escaped.

Suggested change
\"name\": \"${key}\",
\"value\": \"${ENVIRONMENT_VARIABLES[$key]}\"
\"name\": strenv(YQ_KEY),
\"value\": strenv(YQ_VALUE)

Copilot uses AI. Check for mistakes.
Comment on lines +44 to +46
.spec.template.spec.initContainers[1].env[${ITERATOR}] = {
\"name\": \"${key}\",
\"value\": \"${ENVIRONMENT_VARIABLES[$key]}\"
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 script writes warmup env vars to .spec.template.spec.initContainers[1], which is brittle if initContainers are reordered or additional initContainers are added later (env vars could end up on the wrong container). Consider selecting the initContainer by name (e.g., matching name == "warmup") rather than relying on a fixed index.

Suggested change
.spec.template.spec.initContainers[1].env[${ITERATOR}] = {
\"name\": \"${key}\",
\"value\": \"${ENVIRONMENT_VARIABLES[$key]}\"
(.spec.template.spec.initContainers[] | select(.name == \"warmup\")).env[${ITERATOR}] = {
\"name\": strenv(YQ_KEY),
\"value\": strenv(YQ_VALUE)

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