Skip to content

Commit

Permalink
Slight confusion between driver and runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
afbjorklund committed Apr 10, 2021
1 parent 3803f5b commit 13e8544
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions pkg/minikube/machine/cache_images.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func LoadCachedImages(cc *config.ClusterConfig, runner command.Runner, images []
// because it takes much less than that time to just transfer the image.
// This is needed because if running in offline mode, we can spend minutes here
// waiting for i/o timeout.
err := timedNeedsTransfer(imgClient, image, cr, 10*time.Second)
err := timedNeedsTransfer(cc.Driver, imgClient, image, cr, 10*time.Second)
if err == nil {
return nil
}
Expand All @@ -114,7 +114,7 @@ func LoadCachedImages(cc *config.ClusterConfig, runner command.Runner, images []
return nil
}

func timedNeedsTransfer(imgClient *client.Client, imgName string, cr cruntime.Manager, t time.Duration) error {
func timedNeedsTransfer(driver string, imgClient *client.Client, imgName string, cr cruntime.Manager, t time.Duration) error {
timeout := make(chan bool, 1)
go func() {
time.Sleep(t)
Expand All @@ -124,7 +124,7 @@ func timedNeedsTransfer(imgClient *client.Client, imgName string, cr cruntime.Ma
transferFinished := make(chan bool, 1)
var err error
go func() {
err = needsTransfer(imgClient, imgName, cr)
err = needsTransfer(driver, imgClient, imgName, cr)
transferFinished <- true
}()

Expand All @@ -137,9 +137,9 @@ func timedNeedsTransfer(imgClient *client.Client, imgName string, cr cruntime.Ma
}

// needsTransfer returns an error if an image needs to be retransfered
func needsTransfer(imgClient *client.Client, imgName string, cr cruntime.Manager) error {
imgDgst := "" // for instance sha256:7c92a2c6bbcb6b6beff92d0a940779769c2477b807c202954c537e2e0deb9bed
if cr.Name() == "docker" && imgClient != nil { // if possible try to get img digest from Client lib which is 4s faster.
func needsTransfer(driver string, imgClient *client.Client, imgName string, cr cruntime.Manager) error {
imgDgst := "" // for instance sha256:7c92a2c6bbcb6b6beff92d0a940779769c2477b807c202954c537e2e0deb9bed
if driver == "docker" && imgClient != nil { // if possible try to get img digest from Client lib which is 4s faster.
imgDgst = image.DigestByDockerLib(imgClient, imgName)
if imgDgst != "" {
if !cr.ImageExists(imgName, imgDgst) {
Expand All @@ -148,7 +148,7 @@ func needsTransfer(imgClient *client.Client, imgName string, cr cruntime.Manager
return nil
}
}
if cr.Name() == "podman" {
if driver == "podman" {
imgDgst = image.DigestByPodmanExec(imgName)
if imgDgst != "" {
if !cr.ImageExists(imgName, imgDgst) {
Expand All @@ -158,7 +158,7 @@ func needsTransfer(imgClient *client.Client, imgName string, cr cruntime.Manager
}
}
// if not found with method above try go-container lib (which is 4s slower)
imgDgst = image.DigestByGoLib(cr.Name(), imgName)
imgDgst = image.DigestByGoLib(driver, imgName)
if imgDgst == "" {
return fmt.Errorf("got empty img digest %q for %s", imgDgst, imgName)
}
Expand Down

0 comments on commit 13e8544

Please sign in to comment.