Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

## Upgrade from v5.0.0 to v5.1.0

- cron pod is now always deleted gracefully ([#72](https://github.com/shopsys/deployment/pull/72))
- health check for webserver now uses PHP-FPM `ping` endpoint instead of nginx `stub_status` ([#71](https://github.com/shopsys/deployment/pull/71))
- update the `/health` location block in `project-nginx.conf` in your project's `app/orchestration/kubernetes/configmap/nginx.yaml` file to pass the request to PHP-FPM:
```diff
Expand Down
17 changes: 5 additions & 12 deletions deploy/parts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,10 @@ else
fi
fi

DEPLOYED_CRON_POD=$(kubectl get pods --namespace=${PROJECT_NAME} --field-selector=status.phase=Running -l app=cron -o=jsonpath='{.items[?(@.status.containerStatuses[0].state.running)].metadata.name}') || true

if [[ -n ${DEPLOYED_CRON_POD} ]]; then
echo -n "Lock crons to prevent run next iteration "
runCommand "ERROR" "kubectl exec -t --namespace=${PROJECT_NAME} ${DEPLOYED_CRON_POD} -- bash -c \"./phing -S cron-lock > /dev/null 2>&1 & disown\""

echo -n "Waiting until all cron instances are done "
runCommand "ERROR" "kubectl exec --namespace=${PROJECT_NAME} ${DEPLOYED_CRON_POD} -- ./phing -S cron-watch"
if kubectl get deployment/cron --namespace="${PROJECT_NAME}" >/dev/null 2>&1; then
echo -n "Waiting until all cron instances are done and stop cron"
runCommand "ERROR" "kubectl scale deployment/cron --namespace=${PROJECT_NAME} --replicas=0"
runCommand "ERROR" "kubectl rollout status deployment/cron --namespace=${PROJECT_NAME} --timeout=60m"
fi

echo "Migrate Application (database migrations, elasticsearch migrations, ...):"
Expand Down Expand Up @@ -130,7 +126,7 @@ if [ ${MIGRATION_COMPLETE_EXIT_CODE} -eq 1 ]; then
echo -e "[${RED}ERROR${NO_COLOR}]"

echo -n "Restore previous cron container "
runCommand "SKIP" "kubectl delete pod --namespace=${PROJECT_NAME} ${DEPLOYED_CRON_POD}"
runCommand "SKIP" "kubectl scale deployment/cron --namespace=${PROJECT_NAME} --replicas=1"
Comment thread
henzigo marked this conversation as resolved.

RUNNING_WEBSERVER_PHP_FPM_POD=$(kubectl get pods --namespace=${PROJECT_NAME} --field-selector=status.phase=Running -l app=webserver-php-fpm -o=jsonpath='{.items[0].metadata.name}')

Expand All @@ -151,9 +147,6 @@ else
kubectl logs job/migrate-application --namespace=${PROJECT_NAME}
echo -e "section_end:`date +%s`:migrate_application_logs_section\r\e[0K"
echo ""

echo -n "Deploy new cron container "
runCommand "ERROR" "kustomize build --load-restrictor LoadRestrictionsNone \"${CONFIGURATION_TARGET_PATH}/kustomize/cron\" | kubectl apply -f -"
fi

echo "Deploy new Webserver and PHP-FPM container:"
Expand Down
33 changes: 23 additions & 10 deletions kubernetes/deployments/cron.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ spec:
progressDeadlineSeconds: 1500
replicas: 1
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
type: RollingUpdate
type: Recreate
selector:
matchLabels:
app: cron
Expand All @@ -25,6 +22,7 @@ spec:
labels:
app: cron
spec:
terminationGracePeriodSeconds: 3000
tolerations:
- key: "workload"
operator: "Equal"
Expand All @@ -38,8 +36,7 @@ spec:
matchExpressions:
- key: workload
operator: In
values:
- background
values: ["background"]
volumes:
- name: domains-urls
configMap:
Expand All @@ -61,14 +58,30 @@ spec:
runAsUser: 0
imagePullPolicy: IfNotPresent
workingDir: /var/www/html
command: ["/bin/sh","-c"]
args: ["cd /var/www/html && ./phing warmup > /dev/null && rm -rf /tmp/log-pipe && mkfifo /tmp/log-pipe && chmod 666 /tmp/log-pipe && crontab -u root /var/spool/cron/template && { crond || cron; } && stdbuf -o0 tail -n +1 -f /tmp/log-pipe"]
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
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.
stdbuf -o0 tail -n +1 -f /tmp/log-pipe &

exec crond -f || exec cron -f
Comment on lines +61 to +75
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
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.
lifecycle:
preStop:
exec:
command:
- sleep
- '5'
- /bin/sh
- -lc
- |
( ./bin/console deploy:cron:lock > /tmp/cron-lock.log 2>&1 || true ) &
./bin/console deploy:cron:watch || true
volumeMounts:
- name: domains-urls
mountPath: /var/www/html/{{DOMAINS_URLS_FILEPATH}}
Expand Down
10 changes: 0 additions & 10 deletions kubernetes/kustomize/cron/kustomization.yaml

This file was deleted.

3 changes: 3 additions & 0 deletions kubernetes/kustomize/webserver/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ resources:
- ../../deployments/webserver-php-fpm.yaml
- ../../services/webserver-php-fpm.yaml
- ../../deployments/storefront.yaml
- ../../deployments/cron.yaml
- ../../services/storefront.yaml
- ../../namespace.yaml
- ../../configmap/nginx.yaml
- ../../configmap/production-php-fpm.yaml
- ../../configmap/production-php-opcache.yaml
- ../../configmap/cron-env.yaml
- ../../configmap/cron-list.yaml
- ../../ingress/ingress-rabbitmq.yaml
namespace: "{{PROJECT_NAME}}"
configMapGenerator:
Expand Down
182 changes: 0 additions & 182 deletions tests/scenarios/basic-production/expected/cron.yaml

This file was deleted.

Loading