fix: surface native stack inspection failures

This commit is contained in:
Thai Nguyen
2026-08-18 17:52:46 +07:00
parent 2221b8a99c
commit 49055a05b1
2 changed files with 5 additions and 1 deletions
@@ -30,6 +30,10 @@ describe("stack container lookup results", () => {
await expect(
getContainersByAppNameMatch("farmgate-odoo", "stack"),
).resolves.toBeUndefined();
const command = execAsyncMock.mock.calls[0]?.[0];
expect(command).toBeDefined();
expect(command).not.toContain("|| true");
});
it("returns an empty list for a successful native lookup with no tasks", async () => {
+1 -1
View File
@@ -175,7 +175,7 @@ const getStackTaskContainers = async (appName: string, serverId?: string) => {
const divider = "__DOKPLOY_DIVIDER__";
const tasksCommand = `docker stack ps ${appName} --no-trunc --filter "desired-state=running" --format 'TASK : {{.ID}} | Name: {{.Name}} | Node: {{.Node}} | CurrentState: {{.CurrentState}} | Error: {{.Error}}'`;
const inspectCommand = `docker stack ps ${appName} -q --no-trunc --filter "desired-state=running" | xargs -r docker inspect --format '{{if .Status.ContainerStatus}}TASK : {{.ID}} | ContainerId: {{.Status.ContainerStatus.ContainerID}}{{end}}' 2>/dev/null`;
const command = `${tasksCommand} && echo "${divider}" && (${inspectCommand} || true)`;
const command = `${tasksCommand} && echo "${divider}" && ${inspectCommand}`;
let stdout = "";