mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-02 16:29:21 +00:00
Merge pull request #14706 from yifan-gu/rkt_get_status
Auto commit by PR queue bot
This commit is contained in:
commit
1b158fc466
@ -820,16 +820,26 @@ func (r *runtime) KillPod(pod *api.Pod, runningPod kubecontainer.Pod) error {
|
|||||||
// getPodStatus reads the service file and invokes 'rkt status $UUID' to get the
|
// getPodStatus reads the service file and invokes 'rkt status $UUID' to get the
|
||||||
// pod's status.
|
// pod's status.
|
||||||
func (r *runtime) getPodStatus(serviceName string) (*api.PodStatus, error) {
|
func (r *runtime) getPodStatus(serviceName string) (*api.PodStatus, error) {
|
||||||
|
var status api.PodStatus
|
||||||
|
|
||||||
// TODO(yifan): Get rkt uuid from the service file name.
|
// TODO(yifan): Get rkt uuid from the service file name.
|
||||||
pod, rktInfo, err := r.readServiceFile(serviceName)
|
pod, rktInfo, err := r.readServiceFile(serviceName)
|
||||||
if err != nil {
|
if err != nil && !os.IsNotExist(err) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if os.IsNotExist(err) {
|
||||||
|
// Pod does not exit, means it's not been created yet,
|
||||||
|
// return empty status for now.
|
||||||
|
// TODO(yifan): Maybe inspect the image and return waiting status.
|
||||||
|
return &status, nil
|
||||||
|
}
|
||||||
|
|
||||||
podInfo, err := r.getPodInfo(rktInfo.uuid)
|
podInfo, err := r.getPodInfo(rktInfo.uuid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
status := makePodStatus(pod, podInfo, rktInfo)
|
status = makePodStatus(pod, podInfo, rktInfo)
|
||||||
return &status, nil
|
return &status, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -979,10 +989,6 @@ func (r *runtime) IsImagePresent(image kubecontainer.ImageSpec) (bool, error) {
|
|||||||
// SyncPod syncs the running pod to match the specified desired pod.
|
// SyncPod syncs the running pod to match the specified desired pod.
|
||||||
func (r *runtime) SyncPod(pod *api.Pod, runningPod kubecontainer.Pod, podStatus api.PodStatus, pullSecrets []api.Secret, backOff *util.Backoff) error {
|
func (r *runtime) SyncPod(pod *api.Pod, runningPod kubecontainer.Pod, podStatus api.PodStatus, pullSecrets []api.Secret, backOff *util.Backoff) error {
|
||||||
podFullName := kubeletUtil.FormatPodName(pod)
|
podFullName := kubeletUtil.FormatPodName(pod)
|
||||||
if len(runningPod.Containers) == 0 {
|
|
||||||
glog.V(4).Infof("Pod %q is not running, will start it", podFullName)
|
|
||||||
return r.RunPod(pod, pullSecrets)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add references to all containers.
|
// Add references to all containers.
|
||||||
unidentifiedContainers := make(map[types.UID]*kubecontainer.Container)
|
unidentifiedContainers := make(map[types.UID]*kubecontainer.Container)
|
||||||
@ -1036,8 +1042,11 @@ func (r *runtime) SyncPod(pod *api.Pod, runningPod kubecontainer.Pod, podStatus
|
|||||||
}
|
}
|
||||||
|
|
||||||
if restartPod {
|
if restartPod {
|
||||||
if err := r.KillPod(pod, runningPod); err != nil {
|
// Kill the pod only if the pod is actually running.
|
||||||
return err
|
if len(runningPod.Containers) > 0 {
|
||||||
|
if err := r.KillPod(pod, runningPod); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if err := r.RunPod(pod, pullSecrets); err != nil {
|
if err := r.RunPod(pod, pullSecrets); err != nil {
|
||||||
return err
|
return err
|
||||||
|
Loading…
Reference in New Issue
Block a user