Skip to content

Commit

Permalink
Merge pull request #1348 from openshift-cherrypick-robot/cherry-pick-…
Browse files Browse the repository at this point in the history
…1285-to-release-4.3

[release-4.3] Bug 1784981: pkg/daemon: randomize pivot container name
  • Loading branch information
openshift-merge-robot authored Dec 19, 2019
2 parents 80c8aed + 07208de commit 23a6e6f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions pkg/daemon/pivot/types/imageinspection.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package types

const (
// PivotName is literally the name of the new pivot
PivotName = "ostree-container-pivot"
// PivotNamePrefix is literally the name prefix of the new pivot
PivotNamePrefix = "ostree-container-pivot-"
)
17 changes: 9 additions & 8 deletions pkg/daemon/rpm-ostree.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import (
"time"

"github.com/golang/glog"
"github.com/pkg/errors"

"github.com/opencontainers/go-digest"
"github.com/openshift/machine-config-operator/pkg/daemon/constants"
pivottypes "github.com/openshift/machine-config-operator/pkg/daemon/pivot/types"
pivotutils "github.com/openshift/machine-config-operator/pkg/daemon/pivot/utils"
"github.com/pkg/errors"
"k8s.io/apimachinery/pkg/util/uuid"
)

const (
Expand Down Expand Up @@ -214,15 +214,19 @@ func (r *RpmOstreeClient) PullAndRebase(container string, keep bool) (imgid stri
imgid = container
}

// Clean up a previous container
podmanRemove(pivottypes.PivotName)
containerName := pivottypes.PivotNamePrefix + string(uuid.NewUUID())

// `podman mount` wants a container, so let's make create a dummy one, but not run it
var cidBuf []byte
cidBuf, err = runGetOut("podman", "create", "--net=none", "--name", pivottypes.PivotName, imgid)
cidBuf, err = runGetOut("podman", "create", "--net=none", "--annotation=org.openshift.machineconfigoperator.pivot=true", "--name", containerName, imgid)
if err != nil {
return
}
defer func() {
// Kill our dummy container
podmanRemove(containerName)
}()

cid := strings.TrimSpace(string(cidBuf))
// Use the container ID to find its mount point
var mntBuf []byte
Expand Down Expand Up @@ -282,9 +286,6 @@ func (r *RpmOstreeClient) PullAndRebase(container string, keep bool) (imgid stri
return
}

// Kill our dummy container
podmanRemove(pivottypes.PivotName)

// By default, delete the image.
if !keep {
// Related: https://github.com/containers/libpod/issues/2234
Expand Down

0 comments on commit 23a6e6f

Please sign in to comment.