Skip to content

Commit ef12588

Browse files
whummerclaude
andcommitted
Fix empty DLQ replay; add chaos status banner to UI
- replay_dlq.py: handle empty stdout from receive-message (empty DLQ) - index.html: poll /_localstack/chaos/faults every 5s, show warning banner with active fault details when chaos mode is enabled Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 758f939 commit ef12588

2 files changed

Lines changed: 41 additions & 1 deletion

File tree

01-serverless-app/website/index.html

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,20 @@
145145

146146
#api-bar { font-size: 0.78rem; color: #aaa; margin-bottom: 1rem; }
147147
#api-bar code { background: #f0f0f0; padding: 0.1rem 0.4rem; border-radius: 4px; }
148+
149+
#chaos-banner {
150+
display: none;
151+
background: #fff3cd;
152+
border: 1px solid #ffc107;
153+
border-radius: 8px;
154+
padding: 0.75rem 1rem;
155+
margin-bottom: 1.5rem;
156+
font-size: 0.875rem;
157+
color: #856404;
158+
}
159+
#chaos-banner.active { display: block; }
160+
#chaos-banner strong { font-weight: 700; }
161+
#chaos-faults { font-family: monospace; font-size: 0.8rem; margin-top: 0.4rem; white-space: pre-wrap; }
148162
</style>
149163
</head>
150164
<body>
@@ -157,6 +171,11 @@ <h1>Order Processing Pipeline</h1>
157171
<main>
158172
<p id="api-bar">API endpoint: <code id="api-url"></code></p>
159173

174+
<div id="chaos-banner">
175+
<strong>⚠ Chaos mode active</strong> — fault injections are enabled, orders may fail or get stuck.
176+
<div id="chaos-faults"></div>
177+
</div>
178+
160179
<div class="card">
161180
<h2>New Order</h2>
162181
<form id="order-form">
@@ -340,6 +359,22 @@ <h2>Orders</h2>
340359
return String(s).replace(/[&<>"']/g, c => ({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"}[c]));
341360
}
342361

362+
async function checkChaos() {
363+
try {
364+
const res = await fetch(`${window.location.origin}/_localstack/chaos/faults`);
365+
const faults = await res.json();
366+
const banner = document.getElementById("chaos-banner");
367+
if (Array.isArray(faults) && faults.length > 0) {
368+
banner.classList.add("active");
369+
document.getElementById("chaos-faults").textContent = JSON.stringify(faults, null, 2);
370+
} else {
371+
banner.classList.remove("active");
372+
}
373+
} catch (e) { /* LocalStack not reachable, ignore */ }
374+
}
375+
376+
checkChaos();
377+
setInterval(checkChaos, 5000);
343378
loadOrders();
344379
</script>
345380
</body>

04-chaos-engineering/scripts/replay_dlq.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@
1515
aws_secret_access_key="test",
1616
)
1717

18-
data = json.load(sys.stdin)
18+
raw = sys.stdin.read().strip()
19+
if not raw:
20+
print("DLQ is empty.")
21+
sys.exit(0)
22+
23+
data = json.loads(raw)
1924
messages = data.get("Messages", [])
2025

2126
if not messages:

0 commit comments

Comments
 (0)