Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

daemon: Support unpivoted images #1155

Merged
merged 1 commit into from
Oct 7, 2019
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions pkg/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -1154,6 +1154,11 @@ func compareOSImageURL(current, desired string) (bool, error) {
return true, nil
}

// If we're not in pivot:// right now, then it must not match.
if current == "" {
return false, nil
}

if current == desired {
return true, nil
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/daemon/daemon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"time"

igntypes "github.com/coreos/ignition/config/v2_2/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/vincent-petithory/dataurl"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -128,6 +129,9 @@ func TestCompareOSImageURL(t *testing.T) {
if m || err == nil {
t.Fatalf("Expected err")
}
m, err = compareOSImageURL("", refA)
assert.False(t, m)
assert.Nil(t, err)
}

type fixture struct {
Expand Down
28 changes: 18 additions & 10 deletions pkg/daemon/rpm-ostree.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,16 @@ func (r *RpmOstreeClient) GetStatus() (string, error) {
}

// GetBootedOSImageURL returns the image URL as well as the OSTree version (for logging)
// Returns the empty string if the host doesn't have a custom origin that matches pivot://
// (This could be the case for e.g. FCOS, or a future RHCOS which comes not-pivoted by default)
func (r *RpmOstreeClient) GetBootedOSImageURL() (string, string, error) {
bootedDeployment, err := r.getBootedDeployment()
if err != nil {
return "", "", err
}

// the canonical image URL is stored in the custom origin field by the pivot tool
osImageURL := "<not pivoted>"
// the canonical image URL is stored in the custom origin field.
osImageURL := ""
if len(bootedDeployment.CustomOrigin) > 0 {
if strings.HasPrefix(bootedDeployment.CustomOrigin[0], "pivot://") {
osImageURL = bootedDeployment.CustomOrigin[0][len("pivot://"):]
Expand Down Expand Up @@ -150,7 +152,11 @@ func (r *RpmOstreeClient) PullAndRebase(container string, keep bool) (imgid stri
if strings.HasPrefix(defaultDeployment.CustomOrigin[0], "pivot://") {
previousPivot = defaultDeployment.CustomOrigin[0][len("pivot://"):]
glog.Infof("Previous pivot: %s", previousPivot)
} else {
glog.Infof("Previous custom origin: %s", defaultDeployment.CustomOrigin[0])
}
} else {
glog.Info("Current origin is not custom")
}

var authArgs []string
Expand All @@ -168,14 +174,16 @@ func (r *RpmOstreeClient) PullAndRebase(container string, keep bool) (imgid stri
args = append(args, container)
pivotutils.RunExt(false, numRetriesNetCommands, "podman", args...)
} else {
var targetMatched bool
targetMatched, err = compareOSImageURL(previousPivot, container)
if err != nil {
return
}
if targetMatched {
changed = false
return
if previousPivot != "" {
var targetMatched bool
targetMatched, err = compareOSImageURL(previousPivot, container)
if err != nil {
return
cgwalters marked this conversation as resolved.
Show resolved Hide resolved
}
if targetMatched {
changed = false
return
}
}

// Pull the image
Expand Down