Move image pull throttling logic to kubelet/images
This allows runtimes in different packages (dockertools, rkt, kuberuntime) to share the same logic. Before this change, only dockertools support this feature. Now all three packages support image pull throttling.
This commit is contained in:
@@ -31,16 +31,16 @@ type imagePuller interface {
|
||||
var _, _ imagePuller = ¶llelImagePuller{}, &serialImagePuller{}
|
||||
|
||||
type parallelImagePuller struct {
|
||||
runtime kubecontainer.Runtime
|
||||
imageService kubecontainer.ImageService
|
||||
}
|
||||
|
||||
func newParallelImagePuller(runtime kubecontainer.Runtime) imagePuller {
|
||||
return ¶llelImagePuller{runtime}
|
||||
func newParallelImagePuller(imageService kubecontainer.ImageService) imagePuller {
|
||||
return ¶llelImagePuller{imageService}
|
||||
}
|
||||
|
||||
func (pip *parallelImagePuller) pullImage(spec kubecontainer.ImageSpec, pullSecrets []api.Secret, errChan chan<- error) {
|
||||
go func() {
|
||||
errChan <- pip.runtime.PullImage(spec, pullSecrets)
|
||||
errChan <- pip.imageService.PullImage(spec, pullSecrets)
|
||||
}()
|
||||
}
|
||||
|
||||
@@ -48,12 +48,12 @@ func (pip *parallelImagePuller) pullImage(spec kubecontainer.ImageSpec, pullSecr
|
||||
const maxImagePullRequests = 10
|
||||
|
||||
type serialImagePuller struct {
|
||||
runtime kubecontainer.Runtime
|
||||
imageService kubecontainer.ImageService
|
||||
pullRequests chan *imagePullRequest
|
||||
}
|
||||
|
||||
func newSerialImagePuller(runtime kubecontainer.Runtime) imagePuller {
|
||||
imagePuller := &serialImagePuller{runtime, make(chan *imagePullRequest, maxImagePullRequests)}
|
||||
func newSerialImagePuller(imageService kubecontainer.ImageService) imagePuller {
|
||||
imagePuller := &serialImagePuller{imageService, make(chan *imagePullRequest, maxImagePullRequests)}
|
||||
go wait.Until(imagePuller.processImagePullRequests, time.Second, wait.NeverStop)
|
||||
return imagePuller
|
||||
}
|
||||
@@ -74,6 +74,6 @@ func (sip *serialImagePuller) pullImage(spec kubecontainer.ImageSpec, pullSecret
|
||||
|
||||
func (sip *serialImagePuller) processImagePullRequests() {
|
||||
for pullRequest := range sip.pullRequests {
|
||||
pullRequest.errChan <- sip.runtime.PullImage(pullRequest.spec, pullRequest.pullSecrets)
|
||||
pullRequest.errChan <- sip.imageService.PullImage(pullRequest.spec, pullRequest.pullSecrets)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user