Skip to content
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

Automatically start podman.socket #1976

Merged
merged 2 commits into from
Jan 27, 2025

Conversation

martinpitt
Copy link
Member

@martinpitt martinpitt commented Jan 23, 2025

Always start the system and user podman.socket unit on initialization. There really is no reason to explicitly ask the user about it -- we can treat it as "extended cockpit" to just access podman.

There also isn't a reason to enable the socket unit -- starting it on demand is fine from cockpit-podman's perspective.

Now the user will only see the empty state if the service fails, which should be very rare. So turn the Troubleshoot button into a primary one.

We also don't need the "System/User podman is also available" alerts any more -- gaining root privileges auto-starts the system service.


This is a necessary prerequisite for https://issues.redhat.com/browse/COCKPIT-1086 , but useful in its own right -- it removes a big hurdle/annoyance at startup.

Podman: Automatically start podman.socket

If the system or user's podman.socket unit isn't running, cockpit-podman now silently starts it on its own, instead of asking the user about it. There is no need to have the service enabled (i.e. always start it on boot or user login) for cockpit-podman any more.

@martinpitt
Copy link
Member Author

This failure is completely independent, some internal xterm bug:

error: TypeError: Cannot read properties of undefined (reading 'dimensions')

Not sure why it triggers so robustly now, changed timing or 3x affected? It rings a bell, need to check when I'm more awake. https://stackoverflow.com/questions/78116360/xtermjs-cannot-read-properties-of-undefined-reading-dimensions-v5-3-on-next

@@ -80,11 +80,14 @@ class ContainerLogs extends React.Component {
}

resize(width) {
if (!this.term?._core?._renderService?.dimensions)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit akward as this now depends on internals. Which I see, it already did...

jelly
jelly previously approved these changes Jan 27, 2025
Copy link
Member

@jelly jelly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤯 that is quite a nice cleanup as a result of auto starting the podman.socket!

And a great improvement for cockpit-podman 100 😉


I'll leave fixing the small typo up to you

src/app.jsx Show resolved Hide resolved
src/app.jsx Outdated
});

// Listen if podman is still running
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated to code review, but why does this exist? I suppose to check if streaming events works as subscribing to streamEvents does nothing until an event comes along

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, not at all. This is meant to update the state if/when podman.service/.socket gets stopped, i.e. the "close" method. I updated the comment, is it clearer now?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, but then we can in theory re-use podmanMonitor for this? Except it doesn't expose the channel so we can't easily add an eventlistener to close()

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems there are some complications however, this is unrelated to your work.

test/browser/browser.sh Show resolved Hide resolved
We will soon add another piece of initialization at the top, and this
already has too many indentation levels.
Always start the system and user `podman.socket` unit on initialization.
There really is no reason to explicitly ask the user about it -- we can
treat it as "extended cockpit" to just access podman.

There also isn't a reason to enable the socket unit -- starting it
on demand is fine from cockpit-podman's perspective.

Now the user will only see the empty state if the service fails, which
should be very rare. So turn the Troubleshoot button into a primary one.

We also don't need the "System/User podman is also available" alerts any
more -- gaining root privileges auto-starts the system service.
this.updatePods(system);

client.streamEvents(system, message => this.handleEvent(message, system))
.catch(e => console.error("init", system ? "system" : "user", "streamEvents failed:", e.toString()))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This added line is not executed by any test.

client.streamEvents(system, message => this.handleEvent(message, system))
.catch(e => console.error("init", system ? "system" : "user", "streamEvents failed:", e.toString()))
.finally(() => {
this.setState({ [system ? "systemServiceAvailable" : "userServiceAvailable"]: false });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This added line is not executed by any test.

Comment on lines +493 to +494
console.log("init", system ? "system" : "user", "podman service closed");
this.setState({ [system ? "systemServiceAvailable" : "userServiceAvailable"]: false });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These 2 added lines are not executed by any test.

@martinpitt martinpitt merged commit 890ce6e into cockpit-project:main Jan 27, 2025
33 checks passed
@martinpitt martinpitt deleted the auto-start-socket branch January 27, 2025 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants