pkg/daemon: Add IgnitionVersion to Daemon
Populate with output of `ignition --version` command
from locally installed binary.
@@ -52,9 +52,13 @@ import (
type Daemon struct {
// name is the node name.
name string
+
// OperatingSystem the operating system the MCD is running on
OperatingSystem string
+ // IgnitionVersion is the version of the installed Ignition binary on the system
+ IgnitionVersion string
+
// mock is set if we're running as non-root, probably under unit tests
mock bool
@@ -115,6 +119,8 @@ type Daemon struct {
}
const (
+ // pathIgnition is the path where the ignition binary resides
+ pathIgnition = "/usr/lib/dracut/modules.d/30ignition/ignition"
// pathSystemd is the path systemd modifiable units, services, etc.. reside
pathSystemd = "/etc/systemd/system"
// wantsPathSystemd is the path where enabled units should be linked
@@ -190,6 +196,7 @@ func New(
var (
osImageURL string
osVersion string
+ ignVersion string
err error
)
@@ -209,6 +216,13 @@ func New(
return nil, fmt.Errorf("error reading osImageURL from rpm-ostree: %v", err)
}
glog.Infof("Booted osImageURL: %s (%s)", osImageURL, osVersion)
+
+ ignVersionBytes, err := exec.Command(pathIgnition, "--version").Output()
+ if err != nil {
+ return nil, fmt.Errorf("error getting installed Ignition version: %v", err)
+ }
+ ignVersion = strings.SplitAfter(string(ignVersionBytes), " ")[1]
+ glog.Infof("Installed Ignition binary version: %s", ignVersion)
}
bootID := ""
@@ -237,6 +251,7 @@ func New(
return &Daemon{
mock: mock,
booting: true,
+ IgnitionVersion: ignVersion,
OperatingSystem: operatingSystem,
NodeUpdaterClient: nodeUpdaterClient,
bootedOSImageURL: osImageURL,
