-
Notifications
You must be signed in to change notification settings - Fork 90
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
Eliminate redundant getContainers/inspectContainer calls #1350
Conversation
src/ContainerIntegration.jsx
Outdated
); | ||
const items = []; | ||
Object.entries(ports).forEach(([containerPort, hostBindings]) => { | ||
hostBindings.forEach(binding => { |
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.
I managed to get error:
Uncaught TypeError: hostBindings is null
renderContainerPublishedPorts ContainerIntegration.jsx:20
renderContainerPublishedPorts ContainerIntegration.jsx:19
ContainerIntegration ContainerIntegration.jsx:97
React 11
These are my ports:
"Ports": {
"3400/tcp": null,
"8080/tcp": [
{
"HostIp": "",
"HostPort": "3404"
}
]
},
I am actually not sure how I created this 🤷♂️
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.
Eww -- Not sure either, but let's not crash the UI on it. Fixed.
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.
Nice cleanup! I managed to get oops - maybe just some broken container on my side
Both the initial container scan and each update called getContainers() once and inspectContainer() twice (!!). But this is very redundant: The objects returned by getContainers() and inspectContainer() have a very similar structure. The latter does not have `Pid` and `PodName`, but we don't use these properties anyway. The others map in a straightforward way: * `Names[]` → single `Name` * `Ports` list → `NetworkSettings.Ports` map * `Mounts` (simple target dir list) → list of objects with lots of info; direct translation is `.Destination` * `Started/Exited...At` → `State.*` * `State` → `State.Status` * `Command` → `Config.Cmd` * `Labels` → `Config.Labels` * `ImageID` → `Image` * `Image` → `ImageName` So change the state keeping to call getContainers() only once at initialization, and from then on only a single inspectContainer() for each state update. Adjust the code for the above property structure changes.
The function already handles falsy values, and other places also call it unguarded. This fixes some Coverage complaints.
These cannot be triggered at will from the UI, as it already prevents actions which won't work. This reduces the coverage report noise.
image.Env ought to always exist. Fixes a coverage complaint.
I also took the opportunity to clean up the coverage report. As I touch so much code here, I got a ton of uncovered code complaints. Update: Hmm -- that link is gone now, apparently each force-push completely deletes and replaces the previous version. Good for reducing the noise in a PR of course, but bad for proving that the proposed changes are necessary.. |
These only apply to old podman versions (where we don't run coverage), are "play it safe" fallbacks which Should Not Happen™, or are transient "Loading..." states which cannot reliably be caught in tests.
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.
Danke!
Both the initial container scan and each update called getContainers() once and inspectContainer() twice (!!). But this is very redundant: The objects returned by getContainers() and inspectContainer() have a very similar structure. The latter does not have
Pid
andPodName
, but we don't use these properties anyway. The others map in a straightforward way:Names[]
→ singleName
Ports
list →NetworkSettings.Ports
mapMounts
(simple target dir list) → list of objects with lots of info; direct translation is.Destination
Started/Exited...At
→State.*
State
→State.Status
Command
→Config.Cmd
Labels
→Config.Labels
ImageID
→Image
Image
→ImageName
So change the state keeping to call getContainers() only once at initialization, and from then on only a single inspectContainer() for each state update. Adjust the code for the above property structure changes.
Another big outcome from #1324, and stress-tested there.