Skip to content

Commit

Permalink
systemd: Add support for 'Listening' state
Browse files Browse the repository at this point in the history
Currently the systemd status code is not able to parse the status of
listening socket units (`Active: active (listening)`). This causes
the checkLibvirtServiceRunning preflight check to unexpectedly fail on
systems using socket activation.
This commit should add the missing parsing, and fix this issue

This fixes #1705
  • Loading branch information
cfergeau authored and praveenkumar committed Nov 27, 2020
1 parent dce70e0 commit 199c835
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
15 changes: 11 additions & 4 deletions pkg/crc/preflight/preflight_checks_linux.go
Expand Up @@ -223,12 +223,19 @@ func checkLibvirtServiceRunning() error {
libvirtSystemdUnits := []string{"virtqemud.socket", "libvirtd.socket", "virtqemud.service", "libvirtd.service"}
for _, unit := range libvirtSystemdUnits {
status, err := sd.Status(unit)
if err == nil && status == states.Running {
logging.Debugf("%s is running", unit)
return nil
if err == nil {
switch status {
case states.Running:
logging.Debugf("%s is running", unit)
return nil
case states.Listening:
logging.Debugf("%s is listening", unit)
return nil
default:
logging.Debugf("%s is neither running nor listening", unit)
}
}

logging.Debugf("%s is not running", unit)
}

logging.Warnf("No active (running) libvirtd systemd unit could be found - make sure one of libvirt systemd units is enabled so that it's autostarted at boot time.")
Expand Down
5 changes: 5 additions & 0 deletions pkg/crc/systemd/states/state.go
Expand Up @@ -9,6 +9,7 @@ type State int
const (
Unknown State = iota
Running
Listening
Stopped
NotFound
Error
Expand All @@ -17,6 +18,7 @@ const (
var states = []string{
"unknown",
"active (running)",
"active (listening)",
"inactive (dead)",
"could not be found",
"error",
Expand All @@ -33,6 +35,9 @@ func Compare(input string) State {
if strings.Contains(input, states[Running]) {
return Running
}
if strings.Contains(input, states[Listening]) {
return Listening
}
if strings.Contains(input, states[Stopped]) {
return Stopped
}
Expand Down

0 comments on commit 199c835

Please sign in to comment.