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

MCO-395: daemon: Completely remove imageInspect code #3821

Closed
Closed
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
15 changes: 1 addition & 14 deletions pkg/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -2291,8 +2291,7 @@ func (dn *Daemon) validateOnDiskStateWithImage(currentConfig *mcfgv1.MachineConf
// checkOS determines whether the booted system matches the target
// osImageURL and if not whether we need to take action. This function
// returns `true` if no action is required, which is the case if we're
// not running RHCOS or FCOS, or if the target osImageURL is "" (unspecified),
// or if the digests match.
// not running RHCOS or FCOS, or if the target osImageURL is "" (unspecified).
// Otherwise if `false` is returned, then we need to perform an update.
func (dn *Daemon) checkOS(osImageURL string) bool {
// Nothing to do if we're not on RHCOS or FCOS
Expand All @@ -2301,18 +2300,6 @@ func (dn *Daemon) checkOS(osImageURL string) bool {
return true
}

// TODO(jkyros): the header for this functions says "if the digests match"
// so I'm wondering if at one point this used to work this way....
inspection, _, err := imageInspect(osImageURL)
if err != nil {
klog.Warningf("Unable to check manifest for matching hash: %s", err)
} else if ostreeCommit, ok := inspection.Labels["ostree.commit"]; ok {
if ostreeCommit == dn.bootedOSCommit {
klog.Infof("We are technically in the right image even if the URL doesn't match (%s == %s)", ostreeCommit, osImageURL)
return true
}
}

return dn.bootedOSImageURL == osImageURL
}

Expand Down
97 changes: 0 additions & 97 deletions pkg/daemon/image-inspect.go

This file was deleted.

50 changes: 0 additions & 50 deletions pkg/daemon/rpm-ostree.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@ import (
"os/exec"
"path/filepath"
"strings"
"time"

rpmostreeclient "github.com/coreos/rpmostree-client-go/pkg/client"
"github.com/opencontainers/go-digest"
pivotutils "github.com/openshift/machine-config-operator/pkg/daemon/pivot/utils"
"gopkg.in/yaml.v2"
"k8s.io/klog/v2"
)
Expand All @@ -28,21 +25,6 @@ const (
imageRegistryAuthFile = "/etc/mco/internal-registry-pull-secret.json"
)

// imageInspection is a public implementation of
// https://github.com/containers/skopeo/blob/82186b916faa9c8c70cfa922229bafe5ae024dec/cmd/skopeo/inspect.go#L20-L31
type imageInspection struct {
Name string `json:",omitempty"`
Tag string `json:",omitempty"`
Digest digest.Digest
RepoDigests []string
Created *time.Time
DockerVersion string
Labels map[string]string
Architecture string
Os string
Layers []string
}

// RpmOstreeClient provides all RpmOstree related methods in one structure.
// This structure implements DeploymentClient
//
Expand Down Expand Up @@ -162,38 +144,6 @@ func (r *RpmOstreeClient) GetBootedOSImageURL() (string, string, string, error)
return osImageURL, bootedDeployment.Version, baseChecksum, nil
}

func podmanInspect(imgURL string) (imgdata *imageInspection, err error) {
// Pull the container image if not already available
var authArgs []string
if _, err := os.Stat(ostreeAuthFile); err == nil {
authArgs = append(authArgs, "--authfile", ostreeAuthFile)
}
args := []string{"pull", "-q"}
args = append(args, authArgs...)
args = append(args, imgURL)
_, err = pivotutils.RunExt(numRetriesNetCommands, "podman", args...)
if err != nil {
return
}

inspectArgs := []string{"inspect", "--type=image"}
inspectArgs = append(inspectArgs, fmt.Sprintf("%s", imgURL))
var output []byte
output, err = runGetOut("podman", inspectArgs...)
if err != nil {
return
}
var imagedataArray []imageInspection
err = json.Unmarshal(output, &imagedataArray)
if err != nil {
err = fmt.Errorf("unmarshaling podman inspect: %w", err)
return
}
imgdata = &imagedataArray[0]
return

}

// RpmOstreeIsNewEnoughForLayering returns true if the version of rpm-ostree on the
// host system is new enough for layering.
// VersionData represents the static information about rpm-ostree.
Expand Down
3 changes: 3 additions & 0 deletions pkg/daemon/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ const (
extensionsRepo = "/etc/yum.repos.d/coreos-extensions.repo"
osExtensionsContentBaseDir = "/run/mco-extensions/"

// cmdRetriesCount is an arbitrary number of times we will retry
cmdRetriesCount = 2

// These are the actions for a node to take after applying config changes. (e.g. a new machineconfig is applied)
// "None" means no special action needs to be taken
// This happens for example when ssh keys or the pull secret (/var/lib/kubelet/config.json) is changed
Expand Down