Skip to content

Commit

Permalink
Merge pull request #85 from srl-labs/fix/never-pull-via-cri-directly
Browse files Browse the repository at this point in the history
fix: always ask manager to create puller pod if image is not present, fixes issues w/ insecure registries
  • Loading branch information
carlmontanari authored Dec 10, 2023
2 parents c894053 + 7ae4fb4 commit 1418900
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 42 deletions.
19 changes: 4 additions & 15 deletions launcher/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,22 +78,11 @@ func (c *clabernetes) image() {
return
}

if len(configuredPullSecrets) == 0 {
c.logger.Info("no pull secrets configured, pulling image ourselves with no credentials...")

err = imageManager.Pull(c.imageName)
if err != nil {
handleImagePullThroughModeAlwaysPanic(c.imagePullThroughMode)

return
}
} else {
err = c.requestImagePull(imageManager, configuredPullSecrets)
if err != nil {
handleImagePullThroughModeAlwaysPanic(c.imagePullThroughMode)
err = c.requestImagePull(imageManager, configuredPullSecrets)
if err != nil {
handleImagePullThroughModeAlwaysPanic(c.imagePullThroughMode)

return
}
return
}

c.copyImageFromCRI(imageManager)
Expand Down
24 changes: 0 additions & 24 deletions launcher/image/containerd.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,30 +37,6 @@ func (m *containerdManager) Present(imageName string) (bool, error) {
return true, nil
}

func (m *containerdManager) Pull(imageName string) error {
pullCmd := exec.Command(
"nerdctl",
"--address",
"/clabernetes/.node/containerd.sock",
"--namespace",
"k8s.io",
"image",
"pull",
imageName,
"--quiet",
)

pullCmd.Stdout = m.logger
pullCmd.Stderr = m.logger

err := pullCmd.Run()
if err != nil {
return err
}

return nil
}

func (m *containerdManager) Export(imageName, destination string) error {
exportCmd := exec.Command(
"nerdctl",
Expand Down
3 changes: 0 additions & 3 deletions launcher/image/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ func NewImageManager(logger claberneteslogging.Instance, criKind string) (Manage
type Manager interface {
// Present checks if the image is already present in the node.
Present(imageName string) (bool, error)
// Pull pulls the given image -- this is used if/when there are no pull secrets found, since we
// can very easily pull via the cri if we dont have to think about secrets.
Pull(imageName string) error
// Export is the main reason we are using this and not the cri interface directly (cri has no
// service for export!) -- and does what it says: exports an image to disk.
Export(imageName, destination string) error
Expand Down

0 comments on commit 1418900

Please sign in to comment.