Restart crio after applying the kic overlay (in background)

pull/7575/head
Thomas Stromberg 2020-04-09 22:41:00 -07:00
parent 6449039181
commit 80d4ae529a
1 changed files with 24 additions and 10 deletions

View File

@ -212,15 +212,18 @@ func (k *Bootstrapper) init(cfg config.ClusterConfig) error {
return errors.Wrap(err, "run")
}
var wg sync.WaitGroup
wg.Add(4)
go func() {
// this is required for containerd and cri-o runtime. till we close https://github.com/kubernetes/minikube/issues/7428
if driver.IsKIC(cfg.Driver) && cfg.KubernetesConfig.ContainerRuntime != "docker" {
if err := k.applyKicOverlay(cfg); err != nil {
return errors.Wrap(err, "apply kic overlay")
glog.Errorf("failed to apply kic overlay: %v", err)
}
}
var wg sync.WaitGroup
wg.Add(3)
wg.Done()
}()
go func() {
if err := k.applyNodeLabels(cfg); err != nil {
@ -242,6 +245,7 @@ func (k *Bootstrapper) init(cfg config.ClusterConfig) error {
}
wg.Done()
}()
wg.Wait()
return nil
}
@ -762,20 +766,30 @@ func startKubeletIfRequired(runner command.Runner, sm sysinit.Manager) error {
// applyKicOverlay applies the CNI plugin needed to make kic work
func (k *Bootstrapper) applyKicOverlay(cfg config.ClusterConfig) error {
// Allow no more than 5 seconds for apply kic overlay
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
cmd := exec.CommandContext(ctx, "sudo",
path.Join(vmpath.GuestPersistentDir, "binaries", cfg.KubernetesConfig.KubernetesVersion, "kubectl"), "create", fmt.Sprintf("--kubeconfig=%s", path.Join(vmpath.GuestPersistentDir, "kubeconfig")),
"-f", "-")
b := bytes.Buffer{}
if err := kicCNIConfig.Execute(&b, struct{ ImageName string }{ImageName: kic.OverlayImage}); err != nil {
return err
}
cmd.Stdin = bytes.NewReader(b.Bytes())
if rr, err := k.c.RunCmd(cmd); err != nil {
return errors.Wrapf(err, "cmd: %s output: %s", rr.Command(), rr.Output())
}
// CRIO needs to eventually know about CNI changes (#7380)
if cfg.KubernetesConfig.ContainerRuntime == "crio" {
sm := sysinit.New(k.c)
err := sm.Restart("crio")
return errors.Wrap(err, "restart crio")
}
return nil
}