1
0
mirror of https://github.com/rancher/os.git synced 2025-07-31 22:47:16 +00:00

enhance preload timing issue

This commit is contained in:
Jason-ZW 2018-04-02 04:56:47 +00:00
parent c73954fab0
commit 80c99642b2
4 changed files with 16 additions and 4 deletions

View File

@ -14,6 +14,8 @@ import (
"github.com/codegangsta/cli"
dockerClient "github.com/docker/engine-api/client"
"github.com/docker/engine-api/types"
"github.com/rancher/os/config"
"github.com/rancher/os/docker"
"github.com/rancher/os/log"
)
@ -90,10 +92,17 @@ func PreloadImages(clientFactory func() (dockerClient.APIClient, error), imagesD
clientInitialized = true
}
log.Infof("Loading image %s", filename)
if _, err = client.ImageLoad(context.Background(), imageReader, false); err != nil {
var imageLoadResponse types.ImageLoadResponse
if imageLoadResponse, err = client.ImageLoad(context.Background(), imageReader, false); err != nil {
return err
}
cfg := config.LoadConfig()
if cfg.Rancher.PreloadWait {
if _, err := ioutil.ReadAll(imageLoadResponse.Body); err != nil {
return err
}
}
log.Infof("Finished to load image %s", filename)
log.Infof("Creating done stamp file for image %s", filename)

View File

@ -55,7 +55,8 @@ var schema = `{
"sysctl": {"type": "object"},
"restart_services": {"type": "array"},
"hypervisor_service": {"type": "boolean"},
"shutdown_timeout": {"type": "integer"}
"shutdown_timeout": {"type": "integer"},
"preload_wait": {"type": "boolean"}
}
},

View File

@ -137,6 +137,7 @@ type RancherConfig struct {
RestartServices []string `yaml:"restart_services,omitempty"`
HypervisorService bool `yaml:"hypervisor_service,omitempty"`
ShutdownTimeout int `yaml:"shutdown_timeout,omitempty"`
PreloadWait bool `yaml:"preload_wait,omitempty"`
}
type UpgradeConfig struct {

View File

@ -53,7 +53,8 @@
"sysctl": {"type": "object"},
"restart_services": {"type": "array"},
"hypervisor_service": {"type": "boolean"},
"shutdown_timeout": {"type": "integer"}
"shutdown_timeout": {"type": "integer"},
"preload_wait": {"type": "boolean"}
}
},