// RunPodSandbox creates and starts a pod-level sandbox.
RunPodSandbox creates and starts a pod-level sandbox.
// RunPodSandbox creates and starts a pod - level sandbox .
func (u *UnikernelRuntime) RunPodSandbox(config *kubeapi.PodSandboxConfig) (string, error) {
	var err error
	podID := uuid.NewUUID()
	podName := makeSandboxName(podID, config.GetMetadata())
	if err = u.sandboxNameIndex.Reserve(podName, podID); err != nil {
		return "", fmt.Errorf("failed to reserve sandbox name %q: %v", podName, err)
	}
	defer func() {
		if err != nil {
			u.sandboxNameIndex.ReleaseByName(podName)
		}
	}()
	if err = u.sandboxIDIndex.Add(podID); err != nil {
		return "", fmt.Errorf("failed to reserve sandbox ID %q: %v", podID, err)
	}
	defer func() {
		if err != nil {
			u.sandboxIDIndex.Delete(podID)
		}
	}()
	vmMeta := &metadata.VMMetadata{
		CPUNum: u.defaultCPU,
		Memory: u.defaultMem,
	}
	meta := metadata.SandboxMetadata{
		ID:       podID,
		Name:     podName,
		Config:   config,
		VMConfig: vmMeta,
		LogDir:   config.LogDirectory,
	}
	meta.CreatedAt = time.Now().UnixNano()
	meta.State = kubeapi.PodSandboxState_SANDBOX_READY
	if err = u.sandboxStore.Create(meta); err != nil {
		return "", fmt.Errorf("failed to add sandbox metadata %+v into store: %v", meta, err)
	}
	return podID, nil
}
func ( u * UnikernelRuntime ) RunPodSandbox ( config * kubeapi . PodSandboxConfig ) ( string , error ) { var err error podID := uuid . NewUUID ( ) podName := makeSandboxName ( podID , config . GetMetadata ( ) ) if err = u . sandboxNameIndex . Reserve ( podName , podID ) ; err != nil { return " " , fmt . Errorf ( " " , podName , err ) } defer func ( ) { if err != nil { u . sandboxNameIndex . ReleaseByName ( podName ) } } ( ) if err = u . sandboxIDIndex . Add ( podID ) ; err != nil { return " " , fmt . Errorf ( " " , podID , err ) } defer func ( ) { if err != nil { u . sandboxIDIndex . Delete ( podID ) } } ( ) vmMeta := & metadata . VMMetadata { CPUNum : u . defaultCPU , Memory : u . defaultMem , } meta := metadata . SandboxMetadata { ID : podID , Name : podName , Config : config , VMConfig : vmMeta , LogDir : config . LogDirectory , } meta . CreatedAt = time . Now ( ) . UnixNano ( ) meta . State = kubeapi . PodSandboxState_SANDBOX_READY if err = u . sandboxStore . Create ( meta ) ; err != nil { return " " , fmt . Errorf ( " " , meta , err ) } return podID , nil }
RunPodSandbox creates and starts a pod-level sandbox.
RunPodSandbox creates and starts a pod - level sandbox .
// Genrate sandbox ID and name // Reserve sandbox name // Reserve sandbox ID // TODO(Crazykev): Get cpu/mem from cgroup // Create sandbox metadata. // TODO(Crazykev): Create ns and cni config // Add sandbox into sandbox metadata store.