oneuptime icon indicating copy to clipboard operation
oneuptime copied to clipboard

Docker Agent for telemetry does not connect to OneUptime server properly

Open weirdbiz opened this issue 1 month ago • 0 comments

Describe the bug Docker Agent for telemetry does not connect to OneUptime server properly after Docker Host item deleted from UI. Local deployment in docker.

I got 2 cases to reproduce:

  • previously created and then removed host with specific DOCKER_HOST_NAME value (for ex.: test01) does not appear in UI even after Docker Agent 'rm -f' and 'run' again.
  • Trying to fix the first case, run 'npm restart', then Docker Agent 'rm -f' and 'run' again - got duplicate items with same name and settings in Docker Host UI. One of them working fine. But after I deleted both from UI and Docker Agent re-install again - got same behavior as in the first case.

To Reproduce Steps to reproduce the behavior:

  1. Get local docker installation of OneUptime on VM https://github.com/OneUptime/oneuptime/tree/master#-self-host-with-docker-compose
  2. Add Host telemetry as described in Hosts. Host name in this example is 'test01'. This step is required to reproduce environment.
  3. Go through Docker Agent installation process as described in https://oneuptime.com/docs/en/telemetry/docker-host. Also install Docker AI Agent.
  4. Click on 'Infrastructure - Docker', new Docker Host item should appear (for ex.: test01).
  5. Delete item 'test01' from Docker Host UI.
  6. Uninstall and install again Docker Agent from same host, as described in https://oneuptime.com/docs/en/telemetry/docker-host. DO NOT install Docker AI Agent. Use same specific DOCKER_HOST_NAME value (for ex.: test01)
  7. Docker Host item 'test01' was not created in UI.
  8. Install Docker AI Agent. Docker Host item 'test01' appears, but does not receive heartbeats and 20 min later goes to Disconnected state.
  9. Delete item 'test01' from Docker Host UI.
  10. Restart OneUptime server by 'npm restart'.
  11. Go through step 6 again (re-install Docker agent without AI Agent)
  12. Docker Host item 'test01' created in UI twice with same name.

Expected behavior Docker Host entity should be created correctly every time only once, even upon reinstallation of agent. Docker Host entity should properly connect to OneUptime server and send heartbeats.

Desktop:

  • OS: MacOS
  • Browser: Chrome
  • Version: 155.0.8059.85

Deployment Type self hosted, single VM (Ubuntu 24.04) Version: 14.0.85 Commit: 55506c5e68aa48d15c1df7e9c16b20f1ada3962b

Additional context PostgreSQL error log, correlated with bug reproduction

[4933] STATEMENT: INSERT INTO "DockerResource" ( "projectId", "dockerHostId", "kind", "name", "containerId", "imageName", "state", "latestCpuPercent", "latestMemoryBytes", "metricsUpdatedAt", "lastSeenAt", "version", "labels", "resourceCreationTimestamp" ) VALUES ($1, $2, $3, $4, $5, $6, $7, $8::numeric, $9::bigint, $10::timestamptz, $11::timestamptz, $12, $13::jsonb, $14::timestamptz), ($15, $16, $17, $18, $19, $20, $21, $22::numeric, $23::bigint, $24::timestamptz, $25::timestamptz, $26, $27::jsonb, $28::timestamptz), ($29, $30, $31, $32, $33, $34, $35, $36::numeric, $37::bigint, $38::timestamptz, $39::timestamptz, $40, $41::jsonb, $42::timestamptz), ($43, $44, $45, $46, $47, $48, $49, $50::numeric, $51::bigint, $52::timestamptz, $53::timestamptz, $54, $55::jsonb, $56::timestamptz), ($57, $58, $59, $60, $61, $62, $63, $64::numeric, $65::bigint, $66::timestamptz, $67::timestamptz, $68, $69::jsonb, $70::timestamptz), ($71, $72, $73, $74, $75, $76, $77, $78::numeric, $79::bigint, $80::timestamptz, $81::timestamptz, $82, $83::jsonb, $84::timestamptz), ($85, $86, $87, $88, $89, $90, $91, $92::numeric, $93::bigint, $94::timestamptz, $95::timestamptz, $96, $97::jsonb, $98::timestamptz), ($99, $100, $101, $102, $103, $104, $105, $106::numeric, $107::bigint, $108::timestamptz, $109::timestamptz, $110, $111::jsonb, $112::timestamptz), ($113, $114, $115, $116, $117, $118, $119, $120::numeric, $121::bigint, $122::timestamptz, $123::timestamptz, $124, $125::jsonb, $126::timestamptz) ON CONFLICT ("projectId", "dockerHostId", "kind", "name") DO UPDATE SET "containerId" = COALESCE(EXCLUDED."containerId", "DockerResource"."containerId"), "imageName" = COALESCE(EXCLUDED."imageName", "DockerResource"."imageName"), "state" = EXCLUDED."state", "latestCpuPercent" = COALESCE(EXCLUDED."latestCpuPercent", "DockerResource"."latestCpuPercent"), "latestMemoryBytes" = COALESCE(EXCLUDED."latestMemoryBytes", "DockerResource"."latestMemoryBytes"), "metricsUpdatedAt" = EXCLUDED."metricsUpdatedAt", "lastSeenAt" = EXCLUDED."lastSeenAt", "labels" = CASE WHEN EXCLUDED."labels" IS NULL THEN "DockerResource"."labels" WHEN lower(left(EXCLUDED."containerId", 12)) <> lower(left("DockerResource"."containerId", 12)) THEN EXCLUDED."labels" WHEN jsonb_typeof("DockerResource"."labels") = 'object' THEN "DockerResource"."labels" || EXCLUDED."labels" ELSE EXCLUDED."labels" END, "resourceCreationTimestamp" = CASE WHEN EXCLUDED."resourceCreationTimestamp" IS NULL THEN "DockerResource"."resourceCreationTimestamp" WHEN "DockerResource"."resourceCreationTimestamp" IS NULL OR lower(left(EXCLUDED."containerId", 12)) <> lower(left("DockerResource"."containerId", 12)) OR EXCLUDED."resourceCreationTimestamp" > "DockerResource"."resourceCreationTimestamp" + interval '1 minute' THEN EXCLUDED."resourceCreationTimestamp" ELSE "DockerResource"."resourceCreationTimestamp" END, "updatedAt" = now() WHERE EXCLUDED."lastSeenAt" >= "DockerResource"."lastSeenAt"

[4966] DETAIL: Key (dockerHostId)=(66f44447-ee93-4a12-99ec-79edd9a2421c) is not present in table "DockerHost".

[5240] ERROR: insert or update on table "DockerResource" violates foreign key constraint "FK_84fba362f2ac3a2550e08d16fb2"

weirdbiz avatar Oct 23 '26 16:10 weirdbiz