Skip to content

Commit

Permalink
chore: update concurrent for some logic (#1928)
Browse files Browse the repository at this point in the history
Signed-off-by: yuxing.lyx <[email protected]>

Signed-off-by: yuxing.lyx <[email protected]>
  • Loading branch information
starnop authored Dec 22, 2022
1 parent fbb35bf commit c5c90a2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pkg/image/save/save.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const (
HTTP = "http://"
defaultProxyURL = "https://registry-1.docker.io"
configRootDir = "rootdirectory"
maxPullGoroutineNum = 2
maxPullGoroutineNum = 1

manifestV2 = "application/vnd.docker.distribution.manifest.v2+json"
manifestOCI = "application/vnd.oci.image.manifest.v1+json"
Expand Down
16 changes: 12 additions & 4 deletions pkg/imagedistributor/scp_distributor.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,26 @@ type scpDistributor struct {
}

func (s *scpDistributor) DistributeRegistry(deployHosts []net.IP, dataDir string) error {
eg, _ := errgroup.WithContext(context.Background())
for _, info := range s.imageMountInfo {
if !osi.IsFileExist(filepath.Join(info.MountDir, RegistryDirName)) {
continue
}

for _, deployHost := range deployHosts {
err := s.infraDriver.Copy(deployHost, filepath.Join(info.MountDir, RegistryDirName), dataDir)
if err != nil {
return fmt.Errorf("failed to copy registry data %s: %v", info.MountDir, err)
}
tmpDeployHost := deployHost
eg.Go(func() error {
err := s.infraDriver.Copy(tmpDeployHost, filepath.Join(info.MountDir, RegistryDirName), dataDir)
if err != nil {
return fmt.Errorf("failed to copy registry data %s: %v", info.MountDir, err)
}
return nil
})
}
}
if err := eg.Wait(); err != nil {
return err
}

return nil
}
Expand Down

0 comments on commit c5c90a2

Please sign in to comment.