コード例 #1
0
ファイル: rkt.go プロジェクト: qingyuancloud/qingyuan
// New creates the rkt container runtime which implements the container runtime interface.
// It will test if the rkt binary is in the $PATH, and whether we can get the
// version of it. If so, creates the rkt container runtime, otherwise returns an error.
func New(config *Config,
	generator qingcontainer.RunContainerOptionsGenerator,
	recorder record.EventRecorder,
	containerRefManager *qingcontainer.RefManager,
	readinessManager *qingcontainer.ReadinessManager,
	volumeGetter volumeGetter) (qingcontainer.Runtime, error) {

	systemdVersion, err := getSystemdVersion()
	if err != nil {
		return nil, err
	}
	result, err := systemdVersion.Compare(systemdMinimumVersion)
	if err != nil {
		return nil, err
	}
	if result < 0 {
		return nil, fmt.Errorf("rkt: systemd version is too old, requires at least %v", systemdMinimumVersion)
	}

	systemd, err := dbus.New()
	if err != nil {
		return nil, fmt.Errorf("cannot connect to dbus: %v", err)
	}

	// Test if rkt binary is in $PATH.
	rktBinAbsPath, err := exec.LookPath(rktBinName)
	if err != nil {
		return nil, fmt.Errorf("cannot find rkt binary: %v", err)
	}

	rkt := &runtime{
		systemd:             systemd,
		rktBinAbsPath:       rktBinAbsPath,
		config:              config,
		dockerKeyring:       credentialprovider.NewDockerKeyring(),
		containerRefManager: containerRefManager,
		generator:           generator,
		recorder:            recorder,
		readinessManager:    readinessManager,
		volumeGetter:        volumeGetter,
	}
	rkt.prober = prober.New(rkt, readinessManager, containerRefManager, recorder)

	// Test the rkt version.
	version, err := rkt.Version()
	if err != nil {
		return nil, err
	}
	result, err = version.Compare(rktMinimumVersion)
	if err != nil {
		return nil, err
	}
	if result < 0 {
		return nil, fmt.Errorf("rkt: Version is too old, requires at least %v", rktMinimumVersion)
	}
	return rkt, nil
}
コード例 #2
0
func NewFakeDockerManager(
	client DockerInterface,
	recorder record.EventRecorder,
	readinessManager *qingcontainer.ReadinessManager,
	containerRefManager *qingcontainer.RefManager,
	podInfraContainerImage string,
	qps float32,
	burst int,
	containerLogsDir string,
	osInterface qingcontainer.OSInterface,
	networkPlugin network.NetworkPlugin,
	generator qingcontainer.RunContainerOptionsGenerator,
	httpClient qingletTypes.HttpGetter,
	runtimeHooks qingcontainer.RuntimeHooks) *DockerManager {

	dm := NewDockerManager(client, recorder, readinessManager, containerRefManager, podInfraContainerImage, qps,
		burst, containerLogsDir, osInterface, networkPlugin, generator, httpClient, runtimeHooks, &NativeExecHandler{})
	dm.puller = &FakeDockerPuller{}
	dm.prober = prober.New(nil, readinessManager, containerRefManager, recorder)
	return dm
}