worker.py (both the ConfigMap copy and conf/worker.py): - Set an explicit ack_wait=60s on the JetStream pull consumer. It was previously left at the implicit default (~30s), the same ballpark as the outbound HTTP timeout - a slow-but-legitimate external call could cause JetStream to redeliver the message to another worker while the first was still mid-request, double-processing a non-idempotent call (e.g. duplicate order creation). - Track in-flight tasks and drain them (bounded wait) before closing the NATS/HTTP connections on shutdown, instead of cutting them off immediately - avoids dropped/duplicated messages on pod restarts. - Generic exception handler now does nak(delay=5) instead of an undelayed nak(), avoiding a tight redelivery loop on a persistent bug. - Missing 'data' field in a message now explicitly drops with a log line instead of silently forwarding the entire internal envelope. - Removed the hardcoded NATS password fallback baked into the source (every deployment already supplies it via a Secret at runtime, so this was a redundant plaintext copy sitting in a ConfigMap). app.py (both the ConfigMap copy and conf/app.py): - Fixed "NATS by connected" typo -> "NATS not connected". - Same hardcoded-password-fallback removal as worker.py. CORS: - conf/nginx-jupiter.conf and the in-cluster jupiter-cors-proxy nginx config both add their own CORS headers without stripping any the upstream might set, unlike nginx-queue-proxy.conf which does this correctly. Added proxy_hide_header for the ACA-* headers in both - browsers reject a response with duplicate Access-Control-* values. docker-compose.yml: - Added the missing doormile-proxy service (doormile.com -> :8206 -> NodePort 30830). nginx-doormile.conf existed but had no service wiring it into Traefik, unlike every other app.
107 lines
3.1 KiB
YAML
107 lines
3.1 KiB
YAML
apiVersion: v1
|
|
kind: ConfigMap
|
|
metadata:
|
|
name: jupiter-cors-config
|
|
namespace: nearle
|
|
data:
|
|
nginx.conf: |
|
|
events {}
|
|
http {
|
|
upstream jupiter_backend {
|
|
server jupiter:80;
|
|
}
|
|
|
|
server {
|
|
listen 80;
|
|
|
|
location / {
|
|
proxy_pass http://jupiter_backend;
|
|
|
|
# Strip any CORS headers the backend may set itself, so we don't
|
|
# end up sending duplicate Access-Control-* headers (browsers
|
|
# reject a response that has more than one value for these).
|
|
proxy_hide_header 'Access-Control-Allow-Origin';
|
|
proxy_hide_header 'Access-Control-Allow-Methods';
|
|
proxy_hide_header 'Access-Control-Allow-Headers';
|
|
proxy_hide_header 'Access-Control-Max-Age';
|
|
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
|
|
add_header 'Access-Control-Allow-Origin' '*' always;
|
|
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, PATCH, DELETE' always;
|
|
add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization, X-Requested-With, Accept, Origin, X-Auth-Token' always;
|
|
|
|
if ($request_method = 'OPTIONS') {
|
|
add_header 'Access-Control-Allow-Origin' '*';
|
|
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, PATCH, DELETE';
|
|
add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization, X-Requested-With, Accept, Origin, X-Auth-Token';
|
|
add_header 'Access-Control-Max-Age' 1728000;
|
|
add_header 'Content-Type' 'text/plain; charset=utf-8';
|
|
add_header 'Content-Length' 0;
|
|
return 204;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
---
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: jupiter-cors-proxy
|
|
namespace: nearle
|
|
labels:
|
|
app: jupiter-cors-proxy
|
|
spec:
|
|
replicas: 1
|
|
selector:
|
|
matchLabels:
|
|
app: jupiter-cors-proxy
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app: jupiter-cors-proxy
|
|
spec:
|
|
tolerations:
|
|
- key: dedicated
|
|
operator: Equal
|
|
value: apps
|
|
effect: NoSchedule
|
|
containers:
|
|
- name: nginx
|
|
image: nginx:alpine
|
|
ports:
|
|
- containerPort: 80
|
|
volumeMounts:
|
|
- name: nginx-config
|
|
mountPath: /etc/nginx/nginx.conf
|
|
subPath: nginx.conf
|
|
resources:
|
|
requests:
|
|
memory: "32Mi"
|
|
cpu: "10m"
|
|
limits:
|
|
memory: "64Mi"
|
|
cpu: "100m"
|
|
volumes:
|
|
- name: nginx-config
|
|
configMap:
|
|
name: jupiter-cors-config
|
|
---
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: jupiter-cors-proxy
|
|
namespace: nearle
|
|
labels:
|
|
app: jupiter-cors-proxy
|
|
spec:
|
|
selector:
|
|
app: jupiter-cors-proxy
|
|
ports:
|
|
- port: 80
|
|
targetPort: 80
|
|
protocol: TCP
|