Skip to content

Commit

Permalink
daemon: Adapt to OS being pre-pivoted
Browse files Browse the repository at this point in the history
Now that RHCOS is pre-pivoted (see
openshift/os#307), we need to tweak the logic
here on how we handle `osImageURL`. Notably, we allow `://dummy` from
the installer to always match the current image, regardless of whether
we're pivoted or not. In fact, that should've been the logic from the
start.

Closes: #150
  • Loading branch information
jlebon committed Oct 31, 2018
1 parent 214b930 commit eb9bfaa
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
6 changes: 6 additions & 0 deletions pkg/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,12 @@ func (dn *Daemon) isDesiredMachineState() (bool, string, error) {

// checkOS validates the OS image URL and returns true if they match.
func (dn *Daemon) checkOS(osImageURL string) (bool, error) {
// XXX: The installer doesn't pivot yet so for now, just make "://dummy"
// match anything. See also: https://github.com/openshift/installer/issues/281
if osImageURL == "://dummy" {
glog.Warningf(`Working around "://dummy" OS image URL until installer ➰ pivots`)
return true, nil
}
return dn.bootedOSImageURL == osImageURL, nil
}

Expand Down
12 changes: 1 addition & 11 deletions pkg/daemon/rpm-ostree.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import (
"encoding/json"
"fmt"
"strings"

"github.com/golang/glog"
)

// RpmOstreeState houses zero or more RpmOstreeDeployments
Expand Down Expand Up @@ -73,21 +71,13 @@ func (r *RpmOstreeClient) GetBootedOSImageURL(rootMount string) (string, string,
}

// the canonical image URL is stored in the custom origin field by the pivot tool
osImageURL := ""
osImageURL := "<not pivoted>"
if len(bootedDeployment.CustomOrigin) > 0 {
if strings.HasPrefix(bootedDeployment.CustomOrigin[0], "pivot://") {
osImageURL = bootedDeployment.CustomOrigin[0][len("pivot://"):]
}
}

// XXX: the installer doesn't pivot yet so for now, just make "" equivalent
// to "://dummy" so that we don't immediately try to pivot to this dummy
// URL. See also: https://github.com/openshift/installer/issues/281
if osImageURL == "" {
osImageURL = "://dummy"
glog.Warningf(`Working around "://dummy" OS image URL until installer ➰ pivots`)
}

return osImageURL, bootedDeployment.Version, nil
}

Expand Down
6 changes: 6 additions & 0 deletions pkg/daemon/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,12 @@ func getFileOwnership(file ignv2_2types.File) (int, int, error) {

// updateOS updates the system OS to the one specified in newConfig
func (dn *Daemon) updateOS(oldConfig, newConfig *mcfgv1.MachineConfig) error {
// see similar logic in checkOS()
if newConfig.Spec.OSImageURL == "://dummy" {
glog.Warningf(`Working around "://dummy" OS image URL until installer ➰ pivots`)
return nil
}

if newConfig.Spec.OSImageURL == dn.bootedOSImageURL {
return nil
}
Expand Down

0 comments on commit eb9bfaa

Please sign in to comment.