Skip to content

Commit

Permalink
Merge pull request #77 from srl-labs/fix/pull-through-when-present-sk…
Browse files Browse the repository at this point in the history
…ipped

fix: dont forget to actually export/re-import image if its present in cri
  • Loading branch information
carlmontanari authored Nov 24, 2023
2 parents 8de835d + 1189c2c commit 5ec5c96
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 28 deletions.
2 changes: 2 additions & 0 deletions http/alive.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ const (
func (m *manager) aliveHandler(w http.ResponseWriter, r *http.Request) {
if !m.returnedReady {
m.logRequest(r)

m.returnedReady = true
}

if m.managerReadyF() {
Expand Down
53 changes: 25 additions & 28 deletions launcher/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,26 @@ func (c *clabernetes) image() {
return
}

abort = c.imageCheckPresent(imageManager)
if abort {
imagePresent, err := imageManager.Present(c.imageName)
if err != nil {
c.logger.Warnf("failed image pull through (check), err: %s", err)

if c.imagePullThroughMode == clabernetesconstants.ImagePullThroughModeAlways {
clabernetesutil.Panic(
"image pull through failed and pull through mode is always, cannot continue",
)
}

c.logger.Warnf("attempting to continue without image pull through...")

return
}

if imagePresent {
c.logger.Infof("image %q is present, begin copy to docker daemon...", c.imageName)

c.copyImageFromCRI(imageManager)

return
}

Expand Down Expand Up @@ -78,7 +96,11 @@ func (c *clabernetes) image() {
}
}

err = imageManager.Export(c.imageName, imageDestination)
c.copyImageFromCRI(imageManager)
}

func (c *clabernetes) copyImageFromCRI(imageManager claberneteslauncherimage.Manager) {
err := imageManager.Export(c.imageName, imageDestination)
if err != nil {
c.logger.Warnf("failed image pull through (export), err: %s", err)

Expand Down Expand Up @@ -277,31 +299,6 @@ func (c *clabernetes) sendImagePullRequest(configuredPullSecrets []string) error
return nil
}

func (c *clabernetes) imageCheckPresent(
imageManager claberneteslauncherimage.Manager,
) bool {
imagePresent, err := imageManager.Present(c.imageName)
if err != nil {
c.logger.Warnf("failed image pull through (check), err: %s", err)

if c.imagePullThroughMode == clabernetesconstants.ImagePullThroughModeAlways {
clabernetesutil.Panic(
"image pull through failed and pull through mode is always, cannot continue",
)
}

return true
}

if imagePresent {
c.logger.Infof("image %q is present, aborting image pull through", c.imageName)

return true
}

return false
}

func (c *clabernetes) waitForImage(
imageManager claberneteslauncherimage.Manager,
) error {
Expand Down

0 comments on commit 5ec5c96

Please sign in to comment.