Fix Payment Gateway Propagation

Redeploy Gateway Fix

5 minutes

Rebuild and Redeploy After Saving

Note

Saving server.js does not update running pods until you rebuild and restart.
bash
cd ~/workshop/context-propagation
bash scripts/build-images.sh payment-gateway
bash scripts/import-images-k3d.sh payment-gateway
kubectl -n cosmic-shop rollout restart deployment/payment-gateway
kubectl -n cosmic-shop rollout status deployment/payment-gateway --timeout=180s

Validation Checklist

Run these commands after redeploy completes.

1. Confirm health endpoint reports propagation

bash
kubectl -n cosmic-shop exec deploy/payment-gateway -- wget -qO- http://localhost:3004/health

2. Place a test order and inspect traces

bash
curl -s -X POST http://localhost:30080/api/purchases \
  -H "Content-Type: application/json" \
  -d '{"productId":"telescope-orion-8","quantity":1,"customerEmail":"gateway-test@cosmic.shop"}' \
  | python3 -m json.tool

Note

This workshop uses a Node.js proxy so you practice application-layer propagation bugs (common in BFFs and custom gateways). The NGINX ConfigMap approach from Step 06 applies when the break is at the infrastructure proxy layer instead.

Troubleshooting

Click here for Troubleshooting Guidance

Potential Issue 1. Traces still disconnected after fix

  • Confirm you saved services/payment-gateway/server.js and ran make fix-payment-gateway (rebuild + import + restart)
  • Confirm the pod restarted with a recent AGE: kubectl -n cosmic-shop get pods -l app=payment-gateway
  • Verify health shows "propagation": true
  • Generate new traffic - old traces won’t change retroactively

Potential Issue 2. Health still shows "propagation": false

  • Confirm propagation.inject() is inside buildUpstreamHeaders() and runs before return headers
  • Confirm you removed suppressTracing() from the upstream fetch path
  • Re-run the full rebuild chain - a restart alone is not enough if the image was not rebuilt

Potential Issue 3. If gateway setup is using NGINX / ConfigMap proxy

Some teams implement payment routing with an API gateway or NGINX sidecar instead of a Node.js proxy. The failure mode is identical to Step 06: missing proxy_set_header traceparent directives.

If your organization uses that pattern, the fix would be a ConfigMap change to (gateway-config.yaml) rather than JavaScript:

nginx
location /payments/ {
    proxy_set_header Host $host;
    proxy_set_header traceparent $http_traceparent;
    proxy_set_header tracestate $http_tracestate;
    proxy_set_header baggage $http_baggage;
    proxy_pass http://payment_api;
}
Last Modified ·