first working version
parent
c017c98e81
commit
ac66bf2f90
|
@ -130,7 +130,7 @@ func (d *Driver) Create() error {
|
|||
return
|
||||
}
|
||||
t := time.Now()
|
||||
glog.Infof("Starting extracting preloaded images to volume")
|
||||
glog.Infof("Starting extracting preloaded images to volume ....")
|
||||
// Extract preloaded images to container
|
||||
if err := oci.ExtractTarballToVolume(download.TarballPath(d.NodeConfig.KubernetesVersion, d.NodeConfig.ContainerRuntime), params.Name, BaseImage); err != nil {
|
||||
glog.Infof("Unable to extract preloaded tarball to volume: %v", err)
|
||||
|
|
|
@ -22,6 +22,7 @@ import (
|
|||
"fmt"
|
||||
"os/exec"
|
||||
"path"
|
||||
"runtime/debug"
|
||||
"strings"
|
||||
"text/template"
|
||||
"time"
|
||||
|
@ -232,6 +233,7 @@ func (r *Containerd) ImageExists(name string, sha string) bool {
|
|||
|
||||
// LoadImage loads an image into this runtime
|
||||
func (r *Containerd) LoadImage(path string) error {
|
||||
debug.PrintStack()
|
||||
glog.Infof("Loading image: %s", path)
|
||||
c := exec.Command("sudo", "ctr", "-n=k8s.io", "images", "import", path)
|
||||
if _, err := r.Runner.RunCmd(c); err != nil {
|
||||
|
@ -327,7 +329,7 @@ func (r *Containerd) Preload(cfg config.KubernetesConfig) error {
|
|||
}
|
||||
if ContainerdImagesPreloaded(r.Runner, images) {
|
||||
glog.Info("Images already preloaded, skipping extraction")
|
||||
return nil
|
||||
return r.Restart()
|
||||
}
|
||||
|
||||
tarballPath := download.TarballPath(k8sVersion, cRuntime)
|
||||
|
@ -374,12 +376,14 @@ func (r *Containerd) Restart() error {
|
|||
// ContainerdImagesPreloaded returns true if all images have been preloaded
|
||||
func ContainerdImagesPreloaded(runner command.Runner, images []string) bool {
|
||||
fmt.Printf("medyadb inside ContainerdImagesPreloaded : images %s \n", strings.Join(images, ","))
|
||||
// rr, err := runner.RunCmd(exec.Command("sudo", "crictl", "images"))
|
||||
// if err != nil {
|
||||
// return false
|
||||
// }
|
||||
fmt.Println("=================================")
|
||||
rr, err := runner.RunCmd(exec.Command("sudo", "crictl", "images"))
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
// glog.Infof("Got contained preloaded images: %s", rr.Output())
|
||||
glog.Infof("Got contained preloaded images: %s", rr.Output())
|
||||
fmt.Println("=================================")
|
||||
|
||||
// // Make sure images == imgs
|
||||
// for _, i := range images {
|
||||
|
|
|
@ -25,6 +25,7 @@ import (
|
|||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"runtime/debug"
|
||||
|
||||
"cloud.google.com/go/storage"
|
||||
"google.golang.org/api/option"
|
||||
|
@ -78,6 +79,10 @@ func remoteTarballURL(k8sVersion, containerRuntime string) string {
|
|||
|
||||
// PreloadExists returns true if there is a preloaded tarball that can be used
|
||||
func PreloadExists(k8sVersion, containerRuntime string) bool {
|
||||
// TODO: debug why this func is being called two times
|
||||
fmt.Println("************************************************************************")
|
||||
debug.PrintStack()
|
||||
fmt.Println("************************************************************************")
|
||||
glog.Infof("Checking if preload exists for k8s version %s and runtime %s", k8sVersion, containerRuntime)
|
||||
if !viper.GetBool("preload") {
|
||||
return false
|
||||
|
|
|
@ -64,12 +64,20 @@ func CacheImagesForBootstrapper(imageRepository string, version string, clusterB
|
|||
|
||||
// LoadImages loads previously cached images into the container runtime
|
||||
func LoadImages(cc *config.ClusterConfig, runner command.Runner, images []string, cacheDir string) error {
|
||||
// Skip loading images if images already exist
|
||||
if cruntime.DockerImagesPreloaded(runner, images) {
|
||||
glog.Infof("Images are preloaded, skipping loading")
|
||||
return nil
|
||||
if cc.KubernetesConfig.ContainerRuntime == "docker" {
|
||||
// Skip loading images if images already exist
|
||||
if cruntime.DockerImagesPreloaded(runner, images) {
|
||||
glog.Infof("Images are preloaded, skipping loading")
|
||||
return nil
|
||||
}
|
||||
}
|
||||
if cc.KubernetesConfig.ContainerRuntime == "containerd" {
|
||||
// Skip loading images if images already exist
|
||||
if cruntime.ContainerdImagesPreloaded(runner, images) {
|
||||
glog.Infof("Images are preloaded, skipping loading")
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
glog.Infof("LoadImages start: %s", images)
|
||||
start := time.Now()
|
||||
|
||||
|
|
Loading…
Reference in New Issue