Closed dofmind closed 4 months ago
Hi @dofmind,
Good question. According to systemctl man page:
List units that systemd currently has in memory. This includes units that are either referenced directly or through a dependency, units that are pinned by applications programmatically, or units that were active in the past and have failed. By default only units which are active, have pending jobs, or have failed are shown; this can be changed with option --all.
If I understand this correctly, the Loaded: loaded
state isn't enough for a unit to be listed by systemctl list-units
(with and without the --all
flag). For a unit to be listed there it needs to
active
or failed
state[Install]
section and is referenced by another unit that is part of the default dependency tree (so using multi-user.target
should do the trick)So if you add to /etc/containers/systemd/sample-app-b.container
:
...
[Install]
WantedBy=multi-user.target
Then it should get listed by bluechictl | systemctl list-units --all
:
$ systemctl daemon-reload
# shouldn't show anything since sample-app-b.service is inactive
$ systemctl list-units | grep sample
# --all needed
$ systemctl list-units --all | grep sample
sample-app-a.service loaded active running The sample application container
sample-app-b.service loaded inactive dead The sample application container
NOTE:
Since sample-app-b.container
generates sample-app-b.service
it is not possible to enable it:
$ systemctl enable sample-app-b.service
Failed to enable unit: Unit /run/systemd/generator/sample-app-b.service is transient or generated.
But creating such an artificial dependency just so it get the unit listed by list-units
is a bit pointless. The command systemctl list-unit-files
(see list-unit-files man page) is probably better suited to get an overview of available units (and services).
We currently don't have a ListUnitFiles
API in BlueChi, though. I think it would make sense to add it. What do you think? @mkemel @mwperina
Ah, my question has been resolved. Thank you for your reply. If BlueChi has a ListUnitFiles
API, it will be useful when the state-manager checks whether a unit is serviceable on the node.
The command
systemctl list-unit-files
(see list-unit-files man page) is probably better suited to get an overview of available units (and services). We currently don't have aListUnitFiles
API in BlueChi, though. I think it would make sense to add it. What do you think? @mkemel @mwperina
Yeah, let's change this ticket to RFE to add ListUnitFiles functionality
I created a new RFE issue (https://github.com/eclipse-bluechi/bluechi/issues/889) for a better overview. Please have a look at it @dofmind and comment if we should add/change something.
Closing this issue.
The ListUnits method does not get the unit of service generated by quadlet when the service is inactive, even if the service is loaded.
The sample-app-a and the sample-app-b are generated by quadlet using below files
After running only sample-app-a,
bluechictl list-units
command doesn't get information of sample-app-b.The sample-app-b is inactive but it is loaded.
systemdctl list-units --all
also has same result.Does anyone know why I can't get the unit of service generated by the quadlet?