Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(infra): leave running out of the status while Docker is down

Yudhi Armyndharis7d17cfa3cc8b
diff --git a/dashboard/src/services/api.ts b/dashboard/src/services/api.ts
index e1b0480b8..8f5bcf7b9 100644
--- a/dashboard/src/services/api.ts
+++ b/dashboard/src/services/api.ts
@@ -624,7 +624,7 @@ export interface InfraStatus {
// `builtIn` = OpenWA's own bundled container is actually running and backing this service (live),
// not just the saved intent; falls back to the saved flag (the environment's first) when Docker is
// unavailable. (#488) `running` = a bundled container OpenWA created is up, whether or not the service uses it
- // (false for one Docker Compose created); optional only because an older gateway does not send it.
+ // (false for one Docker Compose created); absent while Docker is unreachable, and from an older gateway.
database: { connected: boolean; type: string; host: string; builtIn: boolean; running?: boolean };
redis: { enabled: boolean; connected: boolean; host: string; port: number; builtIn: boolean; running?: boolean };
queue: {
diff --git a/docs/06-api-specification.md b/docs/06-api-specification.md
index 7973c00d2..b47457f1f 100644
--- a/docs/06-api-specification.md
+++ b/docs/06-api-specification.md
@@ -5540,7 +5540,7 @@ Aggregate infrastructure status (database, Redis, queue, storage, engine).
The `queue.webhooks` counters are live BullMQ job counts (`pending` = waiting + active + delayed; plus `completed`/`failed`), degrading to zeros when the queue is disabled or Redis is unreachable. `redis.connected` is a live probe. `database.host` is the configured `DATABASE_HOST` (default `localhost`) and is reported on SQLite too, so read `type`, not `host`, to tell the database apart.
-`builtIn` (on `database`/`redis`/`storage`) reports whether OpenWA's own bundled container is actually running _and_ backing this service, detected live from the labelled container; when Docker is unreachable it falls back to the saved `*_BUILTIN` flag (one pinned by the environment first, else the one in `data/.env.generated`), and a host name alone counts for nothing there, since an external server may be called `postgres`. `running` (on the same three) reports whether a bundled container OpenWA itself created is up, whether or not the service uses it: one Docker Compose created (it carries Compose's project label) and any container while Docker is unreachable read `false`. In S3 mode `storage` additionally carries `bucket` and `endpoint` (each when one is configured; a bundled MinIO that is stopped still reports `http://minio:9000` here, with `builtIn` false) and `s3Available` (re-probed, throttled, while false; once true it stays true until a restart, so a later outage does not clear it); in local mode neither key is present. `engine.webVersion`/`engine.webVersionSource` (`pinned` / `auto` / `native`) appear only on `whatsapp-web.js`; `webVersion` is `null` until the auto-resolve first succeeds. `engine.browserArgs` is the effective launch argument list: `PUPPETEER_ARGS` (or the four defaults shown) with `--lang=en-US` appended unless a `--lang` flag is already present.
+`builtIn` (on `database`/`redis`/`storage`) reports whether OpenWA's own bundled container is actually running _and_ backing this service, detected live from the labelled container; when Docker is unreachable it falls back to the saved `*_BUILTIN` flag (one pinned by the environment first, else the one in `data/.env.generated`), and a host name alone counts for nothing there, since an external server may be called `postgres`. `running` (on the same three) reports whether a bundled container OpenWA itself created is up, whether or not the service uses it: one Docker Compose created (it carries Compose's project label) reads `false`, and the key is absent while Docker is unreachable, since nothing can be seen or stopped then. In S3 mode `storage` additionally carries `bucket` and `endpoint` (each when one is configured; a bundled MinIO that is stopped still reports `http://minio:9000` here, with `builtIn` false) and `s3Available` (re-probed, throttled, while false; once true it stays true until a restart, so a later outage does not clear it); in local mode neither key is present. `engine.webVersion`/`engine.webVersionSource` (`pinned` / `auto` / `native`) appear only on `whatsapp-web.js`; `webVersion` is `null` until the auto-resolve first succeeds. `engine.browserArgs` is the effective launch argument list: `PUPPETEER_ARGS` (or the four defaults shown) with `--lang=en-US` appended unless a `--lang` flag is already present.
`envPinned` lists which of `DATABASE_TYPE`, `DATABASE_HOST`, `REDIS_ENABLED`, `REDIS_HOST`, `STORAGE_TYPE`, `S3_ENDPOINT`, `STORAGE_LOCAL_PATH`, `ENGINE_TYPE`, `PUPPETEER_HEADLESS`, `SESSION_DATA_PATH` and `PUPPETEER_ARGS` the host environment or the project `.env` sets. Those layers win over `data/.env.generated`, so a value saved for one of these keys through `PUT /api/infra/config` cannot take effect until that layer is changed. A pinned host also decides whether the bundled container backs its service, whatever `builtIn` is saved.
diff --git a/openapi.json b/openapi.json
index 1e07e6acc..3eb866b4f 100644
--- a/openapi.json
+++ b/openapi.json
@@ -21892,7 +21892,7 @@
},
"running": {
"type": "boolean",
- "description": "Whether a bundled PostgreSQL container OpenWA created is running, whether or not this service uses it. False for one Docker Compose created and when Docker is unreachable.",
+ "description": "Whether a bundled PostgreSQL container OpenWA created is running, whether or not this service uses it. False for one Docker Compose created; absent when Docker is unreachable, where nothing can be seen or stopped.",
"example": false
}
},
@@ -21900,8 +21900,7 @@
"connected",
"type",
"host",
- "builtIn",
- "running"
+ "builtIn"
]
},
"InfraRedisStatusDto": {
@@ -21932,7 +21931,7 @@
},
"running": {
"type": "boolean",
- "description": "Whether a bundled Redis container OpenWA created is running, whether or not this service uses it. False for one Docker Compose created and when Docker is unreachable.",
+ "description": "Whether a bundled Redis container OpenWA created is running, whether or not this service uses it. False for one Docker Compose created; absent when Docker is unreachable, where nothing can be seen or stopped.",
"example": false
}
},
@@ -21941,8 +21940,7 @@
"connected",
"host",
"port",
- "builtIn",
- "running"
+ "builtIn"
]
},
"InfraQueueDepthDto": {
@@ -22025,7 +22023,7 @@
},
"running": {
"type": "boolean",
- "description": "Whether a bundled MinIO container OpenWA created is running, whether or not this service uses it. False for one Docker Compose created and when Docker is unreachable.",
+ "description": "Whether a bundled MinIO container OpenWA created is running, whether or not this service uses it. False for one Docker Compose created; absent when Docker is unreachable, where nothing can be seen or stopped.",
"example": false
},
"s3Available": {
@@ -22035,8 +22033,7 @@
},
"required": [
"type",
- "builtIn",
- "running"
+ "builtIn"
]
},
"InfraEngineStatusDto": {
diff --git a/src/modules/infra/dto/infra-response.dto.ts b/src/modules/infra/dto/infra-response.dto.ts
index 830fb4fac..2d4793479 100644
--- a/src/modules/infra/dto/infra-response.dto.ts
+++ b/src/modules/infra/dto/infra-response.dto.ts
@@ -30,13 +30,13 @@ export class InfraDatabaseStatusDto {
})
builtIn!: boolean;
- @ApiProperty({
+ @ApiPropertyOptional({
description:
'Whether a bundled PostgreSQL container OpenWA created is running, whether or not this service uses it. False ' +
- 'for one Docker Compose created and when Docker is unreachable.',
+ 'for one Docker Compose created; absent when Docker is unreachable, where nothing can be seen or stopped.',
example: false,
})
- running!: boolean;
+ running?: boolean;
}
export class InfraRedisStatusDto {
@@ -55,13 +55,13 @@ export class InfraRedisStatusDto {
@ApiProperty({ description: "Whether OpenWA's bundled Redis container is backing this.", example: true })
builtIn!: boolean;
- @ApiProperty({
+ @ApiPropertyOptional({
description:
'Whether a bundled Redis container OpenWA created is running, whether or not this service uses it. False ' +
- 'for one Docker Compose created and when Docker is unreachable.',
+ 'for one Docker Compose created; absent when Docker is unreachable, where nothing can be seen or stopped.',
example: false,
})
- running!: boolean;
+ running?: boolean;
}
export class InfraQueueDepthDto {
@@ -109,13 +109,13 @@ export class InfraStorageStatusDto {
@ApiProperty({ description: "Whether OpenWA's bundled MinIO container is backing this.", example: false })
builtIn!: boolean;
- @ApiProperty({
+ @ApiPropertyOptional({
description:
'Whether a bundled MinIO container OpenWA created is running, whether or not this service uses it. False ' +
- 'for one Docker Compose created and when Docker is unreachable.',
+ 'for one Docker Compose created; absent when Docker is unreachable, where nothing can be seen or stopped.',
example: false,
})
- running!: boolean;
+ running?: boolean;
@ApiPropertyOptional({ description: 'Whether the S3 endpoint answered a probe. Present only for `s3`.' })
s3Available?: boolean;
diff --git a/src/modules/infra/infra-status.controller.spec.ts b/src/modules/infra/infra-status.controller.spec.ts
index f5a0d2cbb..b0e3090ae 100644
--- a/src/modules/infra/infra-status.controller.spec.ts
+++ b/src/modules/infra/infra-status.controller.spec.ts
@@ -451,9 +451,14 @@ describe('InfraStatusController.getStatus running bundled containers', () => {
expect([status.database.running, status.redis.running, status.storage.running]).toEqual([false, false, false]);
});
- it('reports nothing running when Docker is unreachable', async () => {
+ // Nothing can be seen or stopped then, so a reader cannot take the absence of a container for a fact.
+ it('leaves running out when Docker is unreachable', async () => {
const status = await build(null).getStatus();
- expect([status.database.running, status.redis.running, status.storage.running]).toEqual([false, false, false]);
+ expect(['running' in status.database, 'running' in status.redis, 'running' in status.storage]).toEqual([
+ false,
+ false,
+ false,
+ ]);
});
});
diff --git a/src/modules/infra/infra-status.controller.ts b/src/modules/infra/infra-status.controller.ts
index b30de6204..e84c58bb1 100644
--- a/src/modules/infra/infra-status.controller.ts
+++ b/src/modules/infra/infra-status.controller.ts
@@ -33,9 +33,9 @@ interface InfraStatus {
// service (detected live from the labeled container), not merely the saved intent. Falls back to the
// saved flag, the environment's first, when Docker is unavailable. (#488)
// `running` is whether a bundled container OpenWA created is up, whether or not the service uses it; false for
- // one Docker Compose created and when Docker is unavailable.
- database: { connected: boolean; type: string; host: string; builtIn: boolean; running: boolean };
- redis: { enabled: boolean; connected: boolean; host: string; port: number; builtIn: boolean; running: boolean };
+ // one Docker Compose created, and absent when Docker is unavailable, since nothing can be seen or stopped then.
+ database: { connected: boolean; type: string; host: string; builtIn: boolean; running?: boolean };
+ redis: { enabled: boolean; connected: boolean; host: string; port: number; builtIn: boolean; running?: boolean };
queue: {
enabled: boolean;
webhooks: { pending: number; completed: number; failed: number };
@@ -46,7 +46,7 @@ interface InfraStatus {
bucket?: string;
endpoint?: string;
builtIn: boolean;
- running: boolean;
+ running?: boolean;
s3Available?: boolean;
};
engine: {
@@ -232,7 +232,7 @@ export class InfraStatusController {
type: dbType,
host: dbHost,
builtIn: dbBuiltIn,
- running: running?.database === 'openwa',
+ ...(running ? { running: running.database === 'openwa' } : {}),
},
redis: {
enabled: redisEnabled,
@@ -240,7 +240,7 @@ export class InfraStatusController {
host: redisHost,
port: redisPort,
builtIn: redisBuiltIn,
- running: running?.cache === 'openwa',
+ ...(running ? { running: running.cache === 'openwa' } : {}),
},
queue: {
enabled: queueEnabled,
@@ -253,7 +253,7 @@ export class InfraStatusController {
// The endpoint this process dials: a bundled MinIO that is stopped still names it, an external store does not.
...(storageType === 's3' && s3Endpoint ? { endpoint: s3Endpoint } : {}),
builtIn: storageBuiltIn,
- running: running?.storage === 'openwa',
+ ...(running ? { running: running.storage === 'openwa' } : {}),
...(storageType === 's3' ? { s3Available } : {}),
},
engine: {