Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

docs(scaling): give the StatefulSet example the shutdown grace period

Yudhi Armyndharis43c9c3f18793
diff --git a/docs/13-horizontal-scaling.md b/docs/13-horizontal-scaling.md
index 34ea538b3..da37a861f 100644
--- a/docs/13-horizontal-scaling.md
+++ b/docs/13-horizontal-scaling.md
@@ -423,6 +423,9 @@ spec:
labels:
app: openwa
spec:
+ # The teardown can take up to 63 s on a clustered replica (src/common/services/shutdown-budget.ts), so
+ # Kubernetes' default grace of 30 s would SIGKILL a slow stop half way. Match the shipped chart.
+ terminationGracePeriodSeconds: 75
# OS-level containment is defence in depth for the plugin sandbox (see docs/30-plugin-sandboxing.md):
# it limits the privileges the API process holds, not what a plugin inside that process can reach.
# Without it the API process, and every plugin loaded into it, keeps whatever the container runtime
diff --git a/src/common/services/shutdown-budget.spec.ts b/src/common/services/shutdown-budget.spec.ts
index c338686fc..168d21f6c 100644
--- a/src/common/services/shutdown-budget.spec.ts
+++ b/src/common/services/shutdown-budget.spec.ts
@@ -121,7 +121,10 @@ describe('shutdown time budget', () => {
containerSecurityContext: { capabilities: { add: string[] } };
};
expect(values.containerSecurityContext.capabilities.add).toContain('KILL');
- expect(readFileSync(join(root, 'docs/13-horizontal-scaling.md'), 'utf8')).toMatch(/add: \[[^\]]*'KILL'[^\]]*\]/);
+ const scaling = readFileSync(join(root, 'docs/13-horizontal-scaling.md'), 'utf8');
+ expect(scaling).toMatch(/add: \[[^\]]*'KILL'[^\]]*\]/);
+ // Kubernetes' default grace of 30 s is shorter than the teardown can take, so the example sets the deadline.
+ expect(scaling).toContain(`terminationGracePeriodSeconds: ${SHUTDOWN_KILL_DEADLINE_MS / 1000}`);
});
it('destroys open sockets at the HTTP close, which the table counts as 0 s', () => {