Replies: 8 comments 8 replies
-
IMHO, Agama is closer to a server-client architecture than a set of processes using IPC. Ideally, Agama would consist on a single backend service (with multithreating) that is running in the machine in which we want to install a system. That service encapsulates the state and logic of the installation process. Then threre are clients. Clients (graphical or not) are "only" a kind of UI for interacting with our service. And there is no reason to have the client running in the very same machine than the service. For example, there could be a native Windows client which communicates with the Agama service running in another machine. This is also the case of SUMA, an external process that requires to call to the Agama service. Moreover, I think we are abusing of D-Bus because we make use of it for both IPC and for defining an API to get and modify the installation process. IPC should be its unique usage. So, in my opinion, moving from our D-Bus API to a rich HTTP API makes a lot of sense. Probably, we will still need some D-Bus API (only for IPC) meanwhile we have more than one backend service, but this is ok. And for me the key point is the athentication and translation mechanisms that Cockpit brings and how difficult they would be to replace. |
Beta Was this translation helpful? Give feedback.
-
Using CockpitWe use Cockpit in Agama rather as a helper library. Actually we are hiding it as much as possible, users normally cannot see it in Agama except some special situations (the login screen, the integrated terminal). I guess many users do not know that Cockpit is actually running there... 😃 But it provides some quite nice functions which would be difficult to implement properly as we do not have much expertise in those areas. The Cockpit APIAs mentioned at the top, there are few ways how we interact with the system using Cockpit:
The Web ServerThe Cockpit web server is quite simple, it is basically a simple server serving static files (JS, CSS, fonts, images, ...). The advanced feature is that it provides a web socket for communication with the server. We take advantage of this in our webpack development server where we serve the built files (JS, CSS,...) locally and the websocket traffic is redirected to a real Agama server (possibly running on a different machine) using proxy. LocalizationAs mentioned, the localization support on the server side is rather simple, I have reimplemented that in the webpack development server. On the client side the translation functions are also simple. ArchitectureCockpit spawns a Cokpit bridge process for each running Cockpit session. That process runs as the logged in user. That means the users have the same system permission as when logging via SSH. And if you create a file it will have your ownership and permissions. That's good from the security POV. And it easily allows to have multiple user sessions without affecting each other. (In WebYaST we did it differently, for each request we checked whether the logged-in user is allowed to perform the requested action via PolicyKit. The action was only performed if the user had the appropriate permissions otherwise it was denied. But it was still done as the root user...) But Agama requires root permissions, it cannot work as non-root (at least the backend DBus service). And multiple user sessions do not make sense as well as we run a single DBus backend in the end. Cockpit also supports remote servers, you can log into a different server than your browser is connected to. For Agama we could be fine even with some simpler architecture with less features. Authentication and SecurityCockpit handles authentication transparently for us, we do not need to take care about that at all. That's good because we do not have much experience in this area and it is critical as we need to run the server (at least the DBus services) as the root user. So having a security issue would be a big problem for us... 😱 It is not just about verifying the root password, but also about the ensuring that the user session is safe and secure (e.g. using CSRF tokens etc...). I think this is the most critical and complex problem. Python DependencyI guess it is not a big problem for now as we already have Python included in the Live ISO:
So unless we drop these dependencies the new Python dependency is not a big problem. IntegrationsProbably the biggest problem of the Cockpit architecture is that it does not allow easy integration with other tools. The Cockpit architecture does not allow implementing REST API or something similar. But the question is what does the integration actually mean in this case. In a web application you can easily embed Agama using So unless we get some clear use cases and requirements I think the current situation is quite OK. So What...???IMHO the current situation is OK, Cockpit provides some important functionalities which would be difficult for us to reimplement (esp. from the security POV). Adapting to new released versions is a generic problem, we would have similar problems when using any framework. We know that from YaST pretty well... 😝 (We also had to adapt WebYaST to new Ruby or RoR...) But Maybe...Changing the architecture completely and using a true web server would be too complex for Agama, that would very likely not pay off. But maybe (maybe!) if we want to get rid of Cockpit we could reimplement the HTTP + websocket server part and keep the current client side Cockpit API. Maybe it would not be that difficult... I have checked the Cockpit sources and the code is veeery long and complex. But that's because they do all the low level C stuff by themselves (even parsing HTTP headers, URLs, etc...). Using some web server framework and external libraries could make it much easier (example?). |
Beta Was this translation helpful? Give feedback.
-
In general, I agree with most of your points, but I have some comments.
Well, many of us have a past in that area (ok, some years ago) but, to be honest, we neither have experience with D-Bus 😅
By design, we try to stick to the D-Bus API. We want all the logic to be implemented in the service, not having specific bits depending on the client. Setting the keyboard is an exception I am not happy about 😄 but, given it was not needed in the CLI, we decided to go with the straightforward approach.
Any decent web server (or library) already supports websockets.
Actually, none of these things need to change that much.
[..]
+1. The Agama use case is more constrained.
[..]
Again, it is an already solved problem. Any decent library... well, copy&paste.
At the dawn of ALP, the idea was to not have Python installed in the system. OK, I know that's not the case anymore. So the only (minor) drawback is those additional 30MB of memory usage.
I am not aiming to integrate Agama into another web application. About 3rd party tools, as you mention, we might need to work around the problem: connecting through SSH or adding support directly in the client to do that. But an HTTP call is so standard... :-)
That's exactly what I was discussing this week with some teammates. We can rely on some libraries to build a rather minimal communication layer and drop our dependency on Cockpit as a whole. For instance, we could give axum a try as we already depend on some tokio. And we already have zbus and friends to work with D-Bus data structures. But those are implementation details. If we can do that, in the future, we could extend the API to support more HTTP calls if we want to. |
Beta Was this translation helpful? Give feedback.
-
I want to bring up another topic: our usage of D-Bus. I did not have experience with D-Bus when we started to build Agama, so perhaps my designs are not D-Bus friendly at all and that's why I find it limiting sometimes. In general, I represent many concepts as objects themselves. For instance, we have a connection object for each network connection (
Something I dislike is that if I want to update several properties in one shot, I need to implement my own
There are other small glitches, like not having "optional" values, but they are easy to work around. |
Beta Was this translation helpful? Give feedback.
-
TL;DR we decided to stop relying on Cockpit. Hi all, We discussed this topic in a team meeting and decided to move on and stop relying on Cockpit. Do not get us wrong: Cockpit is a fantastic project, but we feel we use a tiny fraction of its features and do not need the rest. In @lslezak's words, we have been actively hiding Cockpit. Having said that, we are grateful for what Cockpit has provided to us until now. Why are we relying on Cockpit?At this point, we use Cockpit to:
Let's have a closer look at what each point means. D-Bus communicationThat's the main reason we started using Cockpit. It offers a convenient way to access D-Bus services from a browser. However, it lacks an API for external callers (by design). Additionally, the proxies-based approach does not fit our use case so well. Working with the D-Bus API is kind of low-level and we need to duplicate some logic in the browser and the CLI. Authentication/authorizationThat's a hot topic. We do not need something as flexible as Cockpit's authentication. Agama is expected to be used only by the "root" user to perform the installation. However, we need to do some research. Service UI filesIt is trivial to implement this feature using any decent framework. UI translationThe mechanism used by A web-based terminalLet's use xterm.js directly. Additionally, let's take the chance to improve its integration into Agama's UI. Downloading the logsIt is something simple to implement using a decent framework. The (lack of) planWe do not have a clear plan and need to research. However, we know that there are a few questions to answer:
We will let you know as we know the answer to those questions and the path becomes clear. Regards, |
Beta Was this translation helpful? Give feedback.
-
Don't forget, Red Hat is (coincidentally) currently also re-imagining Anaconda (the Fedora, RHEL, CentOS, etc. installer) as a web-based installer too. So Cockpit is being used for the same use case on the Red Hat side too. 😉 (We're doing things a little bit different UI-wise, but I wanted to point out that an installer is actually a supported and usable use case for Cockpit.) |
Beta Was this translation helpful? Give feedback.
-
Hello @imobachgs and others, thanks for the transparency! I just want to respond to a few technical points.
I don't know what that means -- the whole point of the bridge, websocket, and protocol is to make OS APIs accessible to web pages and JS code. Callers outside of that (like desktop apps) would obviously not use that.
This isn't a showstopper for Fedora's Cockpit based installer (Anaconda), but if it is for you, and you are currently using Cockpit for Agama: The current versions still contain the C bridge, so you can configure with That doesn't mean that you should rely on this forever (the C bridge is dead and we don't want to change it any more), but it may help with your transition.
There is no standard mechanism for web pages to do e.g. D-Bus calls or file access. If there was, (https://varlink.org/ was such a previous attempt), we'd be very happy and wouldn't have to maintain all this stuff 😁 Thanks, and good luck with everything! |
Beta Was this translation helpful? Give feedback.
-
Hi @martinpitt!
Welcome!
We are referring to providing, for instance, an HTTP-based API (e.g., REST). Bear in mind that in Agama the CLI is an important part and we are also interested in offering better integration to other external tools. Sure, we could use D-Bus in some of those cases, but we would like to experiment to build a higher-level API.
Well, I would not say the new bridge is a showstopper for us (I am pretty sure we need Python in the installation media anyway) and we fully understand that you want to get rid of the old C bridge. The new one enables some interesting use cases and we are looking forward to them, but not for our installer.
Hehe, yes, I know :-) I meant that we are more akin to use old plain HTTP calls and receiving events over the WebSocket. We are still deciding how far are we going to go with hiding the D-Bus part. As a last note, take into account that Agama works only as an installer so we can drop some features that, for sure, you need for Cockpit. For the 1:1 management case, we have Cockpit ;-)
Thanks for your feedback! Good luck! |
Beta Was this translation helpful? Give feedback.
-
Recently, the Cockpit packages started to use the new Python-based bridge. That's perfectly fine, but it caused some problems in Agama that we need to fix.
When discussing the solution, we brought up two topics we would like to discuss:
Disclaimer: Cockpit is a neat project and this discussion is unrelated to recent events. It was a conversation we had before, but this time we decided to record the conclusions and draw a plan if needed.
How does Agama use Cockpit?
In a nutshell, we use Cockpit as a transport layer to access Agama's D-Bus interface from the browser over a websocket. The communication is ruled by the Cockpit
protocol but thanks to cockpit.js library we do not need to deal with those details. Having said that, we only use the D-Bus part of the API (we hardly execute a command, as that logic is backed in our D-Bus API). It works that way by design: put as little business logic as possible in the UI layer.
However, Cockpit does a few extra things for us:
Some drawbacks
Again, these points are not Cockpit fault; it just happens that Agama's use case is
slightly different.
Let's discuss
What do you think we should do? Should we fix the current implementation and continue moving? Or should we consider a more considerable change? Let's open the discussion!
Beta Was this translation helpful? Give feedback.
All reactions