Skip to content

Commit

Permalink
bugfix: add platform to container image list; skip download duplicate…
Browse files Browse the repository at this point in the history
… container image;add some debug logs (#2254)

Signed-off-by: kakzhou719 <[email protected]>
  • Loading branch information
kakaZhou719 committed Jul 12, 2023
1 parent dabf8ce commit 968dcdb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
10 changes: 9 additions & 1 deletion cmd/sealer/cmd/image/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,15 @@ func applyRegistryToImage(engine imageengine.Interface, imageID string, platform
if err != nil {
return "", nil, errors.Wrap(err, "failed to parse container image list")
}
containerImageList = append(containerImageList, parsedContainerImageList...)
for _, image := range parsedContainerImageList {
logrus.Debugf("get container image(%s) with platform(%s) from build context",
image.Image, platform.ToString())
containerImageList = append(containerImageList, &v12.ContainerImage{
Image: image.Image,
AppName: image.AppName,
Platform: &platform,
})
}

// ignored image list
if buildFlags.IgnoredImageList != "" && osi.IsFileExist(buildFlags.IgnoredImageList) {
Expand Down
10 changes: 9 additions & 1 deletion pkg/image/save/save.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,22 @@ func (is *DefaultImageSaver) SaveImages(images []string, dir string, platform v1
}
}()

existFlag := make(map[string]struct{})
//handle image name
for _, image := range images {
named, err := ParseNormalizedNamed(image, "")
if err != nil {
return fmt.Errorf("failed to parse image name:: %v", err)
}

//check if image exist
//check if image is duplicate
if _, exist := existFlag[named.FullName()]; exist {
continue
} else {
existFlag[named.FullName()] = struct{}{}
}

//check if image exist in disk
if err := is.isImageExist(named, dir, platform); err == nil {
continue
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/imagedistributor/scp_distributor.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ func (s *scpDistributor) DistributeRegistry(deployHosts []net.IP, dataDir string
}

if existed {
logrus.Debugf("cache %s hits on: %s, skip to do distribution", info.ImageID, tmpDeployHost.String())
return nil
}
}
Expand Down Expand Up @@ -121,6 +122,7 @@ func (s *scpDistributor) Distribute(hosts []net.IP, dest string) error {
}

if existed {
logrus.Debugf("cache %s hits on: %s, skip to do distribution", info.ImageID, host.String())
return nil
}
}
Expand Down

0 comments on commit 968dcdb

Please sign in to comment.