Пример #1
0
// startInitContainers launches the initial containers that are specified in the
// configuration.
func (r *runner) startInitContainers() error {
	for _, img := range r.config.InitContainers {
		func() {
			f, err := aciremote.RetrieveImage(img, true)
			if err != nil {
				r.log.Errorf("Failed to retrieve image %q: %v", img, err)
				return
			}
			defer f.Close()

			manifest, err := findManifest(f)
			if err != nil {
				r.log.Errorf("Failed to find manifest in image %q: %v", img, err)
				return
			}

			if _, err := f.Seek(0, 0); err != nil {
				r.log.Errorf("Failed to set up %q: %v", img, err)
				return
			}

			if _, err := r.manager.Create("", manifest, f); err != nil {
				r.log.Warnf("Failed to launch container %s: %v", manifest.Name.String(), err)
				return
			}
			r.log.Infof("Launched container %s", manifest.Name.String())
		}()
	}
	return nil
}
Пример #2
0
// startUdev handles launching the udev service.
func (r *runner) startUdev() error {
	if r.config.Services.Udev.Enabled == nil || !*r.config.Services.Udev.Enabled {
		r.log.Trace("Skipping udev")
		return nil
	}

	f, err := aciremote.RetrieveImage(r.config.Services.Udev.ACI, true)
	if err != nil {
		r.log.Errorf("Failed to retrieve udev image: %v", err)
		return nil
	}
	defer f.Close()

	manifest, err := findManifest(f)
	if err != nil {
		r.log.Errorf("Failed to find manifest in udev image: %v", err)
		return nil
	}

	if _, err := f.Seek(0, 0); err != nil {
		r.log.Errorf("Failed to set up udev image: %v", err)
		return nil
	}

	container, err := r.manager.Create("udev", manifest, f)
	if err != nil {
		r.log.Warnf("Failed to launch udev: %v", err)
		return nil
	}
	r.log.Debug("Started udev")

	container.Wait()
	r.log.Trace("Udev is finished")
	if err := container.Stop(); err != nil {
		r.log.Errorf("Failed to stop udev cleanly: %v", err)
		return nil
	}

	return nil
}
Пример #3
0
// startConsole handles launching the udev service.
func (r *runner) startConsole() error {
	if r.config.Services.Console.Enabled == nil || !*r.config.Services.Console.Enabled {
		r.log.Trace("Skipping console")
		return nil
	}

	f, err := aciremote.RetrieveImage(r.config.Services.Console.ACI, true)
	if err != nil {
		r.log.Errorf("Failed to retrieve console image: %v", err)
		return nil
	}
	defer f.Close()

	manifest, err := findManifest(f)
	if err != nil {
		r.log.Errorf("Failed to find manifest in console image: %v", err)
		return nil
	}

	if _, err := f.Seek(0, 0); err != nil {
		r.log.Errorf("Failed to set up console image: %v", err)
		return nil
	}

	// send in the configuration information
	if r.config.Services.Console.Password != nil {
		manifest.App.Environment.Set(
			"CONSOLE_PASSWORD", *r.config.Services.Console.Password)
	}
	manifest.App.Environment.Set(
		"CONSOLE_KEYS", strings.Join(r.config.Services.Console.SSHKeys, "\n"))

	if _, err := r.manager.Create("console", manifest, f); err != nil {
		return fmt.Errorf("Failed to start console: %v", err)
	}
	r.log.Debug("Started console")
	return nil
}
Пример #4
0
// startConsole handles launching the udev service.
func (r *runner) startNTP() error {
	if r.config.Services.NTP.Enabled == nil || !*r.config.Services.NTP.Enabled {
		r.log.Trace("Skipping NTP")
		return nil
	}

	r.log.Info("Updating system clock via NTP...")

	f, err := aciremote.RetrieveImage(r.config.Services.NTP.ACI, true)
	if err != nil {
		r.log.Errorf("Failed to retrieve NTP image: %v", err)
		return nil
	}
	defer f.Close()

	manifest, err := findManifest(f)
	if err != nil {
		r.log.Errorf("Failed to find manifest in console image: %v", err)
		return nil
	}

	if _, err := f.Seek(0, 0); err != nil {
		r.log.Errorf("Failed to set up console image: %v", err)
		return nil
	}

	// add the ntp servers on as environment variables
	manifest.App.Environment.Set(
		"NTP_SERVERS", strings.Join(r.config.Services.NTP.Servers, " "))

	if _, err := r.manager.Create("ntp", manifest, f); err != nil {
		r.log.Warnf("Failed to start NTP: %v", err)
		return nil
	}
	r.log.Debug("Started NTP")
	return nil
}