// makeRuntimePod constructs the container runtime pod. It will: // 1, Construct the pod by the information stored in the unit file. // 2, Construct the pod status from pod info. func (r *runtime) makeRuntimePod(unitName string, podInfos map[string]*podInfo) (*kubecontainer.Pod, error) { f, err := os.Open(path.Join(systemdServiceDir, unitName)) if err != nil { return nil, err } defer f.Close() var pod kubecontainer.Pod opts, err := unit.Deserialize(f) if err != nil { return nil, err } var rktID string for _, opt := range opts { if opt.Section != unitKubernetesSection { continue } switch opt.Name { case unitPodName: err = json.Unmarshal([]byte(opt.Value), &pod) if err != nil { return nil, err } case unitRktID: rktID = opt.Value default: return nil, fmt.Errorf("rkt: Unexpected key: %q", opt.Name) } } if len(rktID) == 0 { return nil, fmt.Errorf("rkt: cannot find rkt ID of pod %v, unit file is broken", pod) } info, found := podInfos[rktID] if !found { return nil, fmt.Errorf("rkt: cannot find info for pod %q, rkt uuid: %q", pod.Name, rktID) } pod.Status = info.toPodStatus(&pod) return &pod, nil }