From 50570f6133bca68109990fa8751deaafad01f446 Mon Sep 17 00:00:00 2001 From: Vincent Batts Date: Mon, 16 Oct 2017 15:17:57 -0400 Subject: [PATCH] buildroot: output flags for crio This adds an environment variable file for crio.service to source. And a step for the buildroot provisioner to write flags, initially just insecure-registry. Signed-off-by: Vincent Batts --- .../package/crio-bin/crio.service | 2 + pkg/provision/buildroot.go | 39 +++++++++++++++++-- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/deploy/iso/minikube-iso/package/crio-bin/crio.service b/deploy/iso/minikube-iso/package/crio-bin/crio.service index 4b3dd2a1d0d3..67dedf58f0c6 100644 --- a/deploy/iso/minikube-iso/package/crio-bin/crio.service +++ b/deploy/iso/minikube-iso/package/crio-bin/crio.service @@ -7,11 +7,13 @@ Requires=minikube-automount.service [Service] Type=notify EnvironmentFile=-/etc/sysconfig/crio +EnvironmentFile=-/etc/sysconfig/crio.minikube EnvironmentFile=/var/run/minikube/env Environment=GOTRACEBACK=crash ExecStartPre=/bin/mkdir -p ${PERSISTENT_DIR}/var/lib/containers ExecStart=/usr/bin/crio \ $CRIO_OPTIONS \ + $CRIO_MINIKUBE_OPTIONS \ --root ${PERSISTENT_DIR}/var/lib/containers ExecReload=/bin/kill -s HUP $MAINPID TasksMax=8192 diff --git a/pkg/provision/buildroot.go b/pkg/provision/buildroot.go index cc473e29ce0c..7b4c0e033b01 100755 --- a/pkg/provision/buildroot.go +++ b/pkg/provision/buildroot.go @@ -123,7 +123,9 @@ WantedBy=multi-user.target EngineOptions: p.EngineOptions, } - t.Execute(&engineCfg, engineConfigContext) + if err := t.Execute(&engineCfg, engineConfigContext); err != nil { + return nil, err + } return &provision.DockerOptions{ EngineOptions: engineCfg.String(), @@ -149,20 +151,24 @@ func (p *BuildrootProvisioner) Provision(swarmOptions swarm.Options, authOptions log.Debugf("set auth options %+v", p.AuthOptions) log.Debugf("setting up certificates") - configureAuth := func() error { if err := configureAuth(p); err != nil { return &util.RetriableError{Err: err} } return nil } - err := util.RetryAfter(5, configureAuth, time.Second*10) if err != nil { log.Debugf("Error configuring auth during provisioning %v", err) return err } + log.Debugf("setting minikube options for container-runtime") + if err := setMinikubeOptions(p); err != nil { + log.Debugf("Error setting container-runtime options during provisioning %v", err) + return err + } + return nil } @@ -179,6 +185,33 @@ func setRemoteAuthOptions(p provision.Provisioner) auth.Options { return authOptions } +func setMinikubeOptions(p *BuildrootProvisioner) error { + // pass through --insecure-registry + var ( + crioOptsTmpl = ` +CRIO_MINIKUBE_OPTIONS='{{ range .EngineOptions.InsecureRegistry }}--insecure-registry {{.}} {{ end }}' +` + crioOptsPath = "/etc/sysconfig/crio.minikube" + ) + t, err := template.New("crioOpts").Parse(crioOptsTmpl) + if err != nil { + return err + } + var crioOptsBuf bytes.Buffer + if err := t.Execute(&crioOptsBuf, p); err != nil { + return err + } + if _, err = p.SSHCommand(fmt.Sprintf("sudo mkdir -p %s && printf %%s \"%s\" | sudo tee %s", path.Dir(crioOptsPath), crioOptsBuf.String(), crioOptsPath)); err != nil { + return err + } + + if err := p.Service("crio", serviceaction.Restart); err != nil { + return err + } + + return nil +} + func configureAuth(p *BuildrootProvisioner) error { driver := p.GetDriver() machineName := driver.GetMachineName()