Skip to content

Commit 5c3f7a1

Browse files
committed
Merge branch 'fix/monitoring-restart-policies' into 'main'
fix: keep monitoring services running after reboot See merge request postgres-ai/postgresai!246
2 parents 5d44816 + 8607efd commit 5c3f7a1

2 files changed

Lines changed: 33 additions & 0 deletions

File tree

cli/test/config-consistency.test.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ type GrafanaDatasourceConfig = {
2424
datasources?: GrafanaDatasource[];
2525
};
2626

27+
type DockerComposeConfig = {
28+
services?: Record<string, { restart?: unknown }>;
29+
};
30+
2731
// These UIDs are referenced by provisioned Grafana dashboards.
2832
// Changing them without updating dashboard JSON silently breaks panels.
2933
const expectedGrafanaDatasourceUids = new Map([
@@ -259,6 +263,32 @@ describe("Config consistency", () => {
259263
expect(envExample).toContain("openssl rand -base64 18");
260264
});
261265

266+
test("long-running Docker Compose services survive host reboot", () => {
267+
const composeConfig = Bun.YAML.parse(
268+
readFileSync(composePath, "utf8")
269+
) as DockerComposeConfig;
270+
const services = composeConfig.services ?? {};
271+
272+
// All services should survive host reboot unless they are one-shot setup jobs.
273+
const oneShotServices = new Set(["config-init", "sources-generator"]);
274+
const serviceEntries = Object.entries(services);
275+
276+
expect(serviceEntries.length).toBeGreaterThan(0);
277+
278+
for (const serviceName of oneShotServices) {
279+
expect(services[serviceName]).toBeDefined();
280+
expect(services[serviceName]?.restart).toBeUndefined();
281+
}
282+
283+
for (const [serviceName, serviceConfig] of serviceEntries) {
284+
if (oneShotServices.has(serviceName)) {
285+
continue;
286+
}
287+
288+
expect(serviceConfig.restart).toBe("unless-stopped");
289+
}
290+
});
291+
262292
test("pgwatch presets only reference configured metrics", () => {
263293
const pgwatchConfig = loadPgwatchConfig();
264294
const metricNames = new Set(Object.keys(pgwatchConfig.metrics));

docker-compose.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ services:
6666
depends_on:
6767
config-init:
6868
condition: service_completed_successfully
69+
restart: unless-stopped
6970

7071
# Hot standby used by xmin-horizon integration coverage when explicitly started.
7172
target-standby:
@@ -99,6 +100,7 @@ services:
99100
- target_standby_data:/var/lib/postgresql/data
100101
depends_on:
101102
- target-db
103+
restart: unless-stopped
102104

103105
# Postgres Sink - Storage for metrics in PostgreSQL format
104106
# Note: pg_hba.conf is configured to allow passwordless connections (trust)
@@ -297,6 +299,7 @@ services:
297299
pgwatch-prometheus:
298300
condition: service_started
299301
command: ["bash", "/postgres_ai_configs/scripts/postgres-reports.sh"]
302+
restart: unless-stopped
300303

301304
# Self-monitoring components (may have reduced functionality on macOS)
302305

0 commit comments

Comments
 (0)