Skip to content

Commit

Permalink
Merge pull request openshift#2291 from cgwalters/explicit-start-rpmos…
Browse files Browse the repository at this point in the history
…tree

Bug 1888565: daemon: Explicitly start rpm-ostreed
  • Loading branch information
openshift-merge-robot authored Dec 12, 2020
2 parents 9df04c6 + 4f62209 commit d6b5d19
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,10 @@ func New(

// Only pull the osImageURL from OSTree when we are on RHCOS or FCOS
if os.IsCoreOSVariant() {
err := nodeUpdaterClient.Start()
if err != nil {
return nil, err
}
osImageURL, osVersion, err = nodeUpdaterClient.GetBootedOSImageURL()
if err != nil {
return nil, fmt.Errorf("error reading osImageURL from rpm-ostree: %v", err)
Expand Down
13 changes: 13 additions & 0 deletions pkg/daemon/rpm-ostree.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ type imageInspection struct {
// NodeUpdaterClient is an interface describing how to interact with the host
// around content deployment
type NodeUpdaterClient interface {
Start() error
GetStatus() (string, error)
GetBootedOSImageURL() (string, string, error)
Rebase(string, string) (bool, error)
Expand Down Expand Up @@ -99,6 +100,18 @@ func (r *RpmOstreeClient) GetBootedDeployment() (*RpmOstreeDeployment, error) {
return nil, fmt.Errorf("not currently booted in a deployment")
}

// Start ensures the daemon is running; the DBus activation timeout
// is shorter than the systemd timeout. xref
// https://bugzilla.redhat.com/show_bug.cgi?id=1888565#c3
func (r *RpmOstreeClient) Start() error {
_, err := runGetOut("systemctl", "start", "rpm-ostreed")
if err != nil {
return fmt.Errorf("failed to start rpm-ostreed: %v", err)
}

return nil
}

// GetStatus returns multi-line human-readable text describing system status
func (r *RpmOstreeClient) GetStatus() (string, error) {
output, err := runGetOut("rpm-ostree", "status")
Expand Down
5 changes: 5 additions & 0 deletions pkg/daemon/rpm-ostree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ func (r RpmOstreeClientMock) GetBootedOSImageURL() (string, string, error) {
return returnValues.OsImageURL, returnValues.Version, returnValues.Error
}

// Start is a mock
func (r RpmOstreeClientMock) Start() error {
return nil
}

// PullAndRebase is a mock
func (r RpmOstreeClientMock) Rebase(string, string) (bool, error) {
return false, nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ contents: |
After=machine-config-daemon-pull.service
Before=crio.service crio-wipe.service
Before=kubelet.service
Wants=rpm-ostreed.service
[Service]
Type=oneshot
Expand Down

0 comments on commit d6b5d19

Please sign in to comment.