-
-
Notifications
You must be signed in to change notification settings - Fork 131
fix: add orphaned status for containers with invalid stats #4441
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
fix: add orphaned status for containers with invalid stats #4441
Conversation
- Add 'orphaned' container state to handle containers with null/undefined cpu_stats.online_cpus - Display orphaned containers with gray badge in UI - Prevent 'Cannot read properties of undefined (reading online_cpus)' error - Add translations for 'orphaned' status in all supported languages - Containers with invalid stats are now marked as orphaned instead of causing errors
|
Here's the code health analysis summary for commits Analysis Summary
|
| return { | ||
| id: container.Id, | ||
| name: container.Names[0]?.split("/")[1] ?? "Unknown", | ||
| state: "orphaned" as ContainerState, | ||
| iconUrl: | ||
| dbIcons.find((icon) => { | ||
| const extractedImage = extractImage(container); | ||
| if (!extractedImage) return false; | ||
| return icon.name.toLowerCase().includes(extractedImage.toLowerCase()); | ||
| })?.url ?? null, | ||
| cpuUsage: 0, | ||
| memoryUsage: 0, | ||
| image: container.Image, | ||
| ports: container.Ports, | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really want to show "failed containers" as "orphaned"?
When does this catch usually get triggered?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, it's not a valid docker container status.
Removed the "orphaned" status and tested these containers to have "exited" status.
Simplified the approach, added safety checks to CPU and memory calculations so it won't fail if cpu_usage, numberOfCpus or memory_stats.usage is null.
exited containers don't have ports either so added a check for no ports in
apps/nextjs/src/app/[locale]/manage/tools/docker/docker-table.tsx too
…s and added simpler fallbacks
| .catch(() => ({ | ||
| cpu_stats: { online_cpus: 0, cpu_usage: { total_usage: 0 }, system_cpu_usage: 0 }, | ||
| memory_stats: { usage: 0 }, | ||
| } as ContainerStats)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use satisfies here if possible?
|
i was also running into this bug after updating my images and rebooting, docker intergration stopped working, searched hours, debugged the docker api, then found out it was an orphaned container. |
Setting homarr up for the first time, I got a
Cannot read properties of undefined (reading online_cpus)error when accessing manage -> tools -> docker.In my case it was an issue of orphaned running containers where online_cpus were null.
I achieved this feat by removing services from a docker-compose stack while the containers were still running and later restarting the compose stack.
Having exited containers exist should not stop a user from using the Docker tool.
Homarr
Thank you for your contribution. Please ensure that your pull request meets the following pull request:
pnpm build, autofix withpnpm format:fix)devbranchx,y,ior any abbrevation)