fix(actions): reuse ingestor pod for canary checks
All checks were successful
deploy-trade-r001-canary / apply (push) Successful in 50s
All checks were successful
deploy-trade-r001-canary / apply (push) Successful in 50s
This commit is contained in:
@@ -87,37 +87,56 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
KUBECONFIG: /tmp/kubeconfig
|
KUBECONFIG: /tmp/kubeconfig
|
||||||
run: |
|
run: |
|
||||||
kubectl -n trade-r001-canary delete pod canary-netcheck --ignore-not-found=true
|
pod_name="$(kubectl -n trade-r001-canary get pod -l app.kubernetes.io/name=trade-ingestor -o jsonpath='{.items[0].metadata.name}')"
|
||||||
kubectl -n trade-r001-canary run canary-netcheck \
|
kubectl -n trade-r001-canary exec -i "$pod_name" -- node - <<'JS'
|
||||||
--image=python:3.12-alpine \
|
const net = require('net');
|
||||||
--restart=Never \
|
|
||||||
--command -- sleep 600
|
|
||||||
kubectl -n trade-r001-canary wait --for=condition=Ready pod/canary-netcheck --timeout=180s
|
|
||||||
kubectl -n trade-r001-canary exec canary-netcheck -- python - <<'PY'
|
|
||||||
import socket
|
|
||||||
|
|
||||||
targets = [
|
const targets = [
|
||||||
("postgres-host.trade-infra.svc.cluster.local", 5432),
|
['postgres-host.trade-infra.svc.cluster.local', 5432],
|
||||||
("redis-host.trade-infra.svc.cluster.local", 6379),
|
['redis-host.trade-infra.svc.cluster.local', 6379],
|
||||||
]
|
];
|
||||||
|
|
||||||
for host, port in targets:
|
function checkSocket(host, port) {
|
||||||
with socket.create_connection((host, port), timeout=5):
|
return new Promise((resolve, reject) => {
|
||||||
print(f"OK {host}:{port}")
|
const socket = net.createConnection({ host, port, timeout: 5000 });
|
||||||
PY
|
socket.on('connect', () => {
|
||||||
kubectl -n trade-r001-canary exec canary-netcheck -- python - <<'PY'
|
console.log(`OK ${host}:${port}`);
|
||||||
import urllib.request
|
socket.end();
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
socket.on('timeout', () => {
|
||||||
|
socket.destroy(new Error(`Timeout ${host}:${port}`));
|
||||||
|
});
|
||||||
|
socket.on('error', reject);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
targets = [
|
(async () => {
|
||||||
"http://hasura:8080/healthz",
|
for (const [host, port] of targets) {
|
||||||
"http://trade-api:8787/healthz",
|
await checkSocket(host, port);
|
||||||
"http://trade-frontend:8081/healthz",
|
}
|
||||||
]
|
})().catch((err) => {
|
||||||
|
console.error(String(err && err.message ? err.message : err));
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
|
JS
|
||||||
|
kubectl -n trade-r001-canary exec -i "$pod_name" -- node - <<'JS'
|
||||||
|
const targets = [
|
||||||
|
'http://hasura:8080/healthz',
|
||||||
|
'http://trade-api:8787/healthz',
|
||||||
|
'http://trade-frontend:8081/healthz',
|
||||||
|
];
|
||||||
|
|
||||||
for url in targets:
|
(async () => {
|
||||||
with urllib.request.urlopen(url, timeout=10) as response:
|
for (const url of targets) {
|
||||||
if response.status != 200:
|
const response = await fetch(url, { signal: AbortSignal.timeout(10000) });
|
||||||
raise SystemExit(f"Unexpected status for {url}: {response.status}")
|
if (!response.ok) {
|
||||||
print(f"OK {url}")
|
throw new Error(`Unexpected status for ${url}: ${response.status}`);
|
||||||
PY
|
}
|
||||||
kubectl -n trade-r001-canary delete pod canary-netcheck --wait=true
|
console.log(`OK ${url}`);
|
||||||
|
}
|
||||||
|
})().catch((err) => {
|
||||||
|
console.error(String(err && err.message ? err.message : err));
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
|
JS
|
||||||
|
|||||||
Reference in New Issue
Block a user