Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions pkg/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,19 +201,25 @@ func New(
err error
)

os := OperatingSystem{}
hostos := OperatingSystem{}
if !mock {
os, err = GetHostRunningOS()
hostos, err = GetHostRunningOS()
if err != nil {
HostOS.WithLabelValues("unsupported", "").Set(1)
return nil, errors.Wrapf(err, "checking operating system")
}
}

// Only pull the osImageURL from OSTree when we are on RHCOS or FCOS
if os.IsCoreOSVariant() {
if hostos.IsCoreOSVariant() {
osImageURL, osVersion, err = nodeUpdaterClient.GetBootedOSImageURL()
if err != nil {
// If this fails for some reason, let's dump the unit status
// into our logs to aid future debugging.
cmd := exec.Command("systemctl", "status", "rpm-ostreed")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does printing status will capture enough error logs or should we print here rpm-ostreed journal log from current boot?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Status will capture the last few lines of logs at the point in time this happens, which I think will be enough.

openshift/must-gather#244 will help for the general case.

cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
_ = cmd.Run()
return nil, fmt.Errorf("error reading osImageURL from rpm-ostree: %v", err)
}
glog.Infof("Booted osImageURL: %s (%s)", osImageURL, osVersion)
Expand All @@ -230,7 +236,7 @@ func New(
// RHEL 7.6/Centos 7 logger (util-linux) doesn't have the --journald flag
loggerSupportsJournal := true
if !mock {
if os.IsLikeTraditionalRHEL7() {
if hostos.IsLikeTraditionalRHEL7() {
loggerOutput, err := exec.Command("logger", "--help").CombinedOutput()
if err != nil {
return nil, errors.Wrapf(err, "running logger --help")
Expand All @@ -240,12 +246,12 @@ func New(
}

// report OS & version (if RHCOS or FCOS) to prometheus
HostOS.WithLabelValues(os.ToPrometheusLabel(), osVersion).Set(1)
HostOS.WithLabelValues(hostos.ToPrometheusLabel(), osVersion).Set(1)

return &Daemon{
mock: mock,
booting: true,
os: os,
os: hostos,
NodeUpdaterClient: nodeUpdaterClient,
bootedOSImageURL: osImageURL,
bootID: bootID,
Expand Down