New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make pod status to Running if some are Running and some are Completed #62642

Merged
merged 1 commit into from Apr 19, 2018

Conversation

@ceshihao
Contributor

ceshihao commented Apr 16, 2018

What this PR does / why we need it:
Make pod status to Running if some are Running and some are Completed

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #62588

Special notes for your reviewer:
Only Set Pod status to Completed when no other reason, no Running container and only Completed containers.

Set status to Running if some are Running and some are Completed

Release note:

Set pod status to "Running" if there is at least one container still reporting as "Running" status and others are "Completed".
@ceshihao

This comment has been minimized.

Contributor

ceshihao commented Apr 16, 2018

/assign @smarterclayton

@hochuenw

This comment has been minimized.

hochuenw commented Apr 16, 2018

@ceshiha, it seems I can not ping this kind of pod (which some containers are Running and some are Completed) from another pod through service. Can this printer fix also fix that issue?

@ceshihao

This comment has been minimized.

Contributor

ceshihao commented Apr 16, 2018

@hochuenw

No, it is different. I think it is another issue.

@mengqiy

This comment has been minimized.

Contributor

mengqiy commented Apr 17, 2018

/ok-to-test
/cc @juanvallejo

@ceshihao

This comment has been minimized.

Contributor

ceshihao commented Apr 17, 2018

/retest

@dixudx

Better add a test for this change.

@ceshihao

This comment has been minimized.

Contributor

ceshihao commented Apr 17, 2018

/retest

@ceshihao

This comment has been minimized.

Contributor

ceshihao commented Apr 17, 2018

/test pull-kubernetes-e2e-kops-aws

1 similar comment
@ceshihao

This comment has been minimized.

Contributor

ceshihao commented Apr 17, 2018

/test pull-kubernetes-e2e-kops-aws

readyContainers++
}
}
if reason == string(api.PodRunning) && hasCompleted && !hasRunning {

This comment has been minimized.

@juanvallejo

juanvallejo Apr 17, 2018

Member

What if the pod's status is Completed?
This line would make it so that Completed pods would appear with a Succeeded status, rather than Completed.

Why not simplify to this (or something similar)?

...
if !initializing {
    restarts = 0
    hasRunning := false
    for i := ... {
        ...
        // last "else if" in loop 
        } else if container.Ready && container.State.Running != nil {
            hasRunning = true
            readyContainers++
        }
    }

    // revert status back to "Running" if there is at least onr
    // container still reporting the "Running" status
    if reason == "Completed" && hasRunning {
        reason = "Running"
    }
}

This comment has been minimized.

@ceshihao

ceshihao Apr 18, 2018

Contributor

Thank you.

Sounds great.
Change the pod status codes according to your comment.

@juanvallejo

This comment has been minimized.

Member

juanvallejo commented Apr 17, 2018

@soltysh fyi

@ceshihao

This comment has been minimized.

Contributor

ceshihao commented Apr 18, 2018

/test pull-kubernetes-e2e-gce

@mengqiy

This comment has been minimized.

Contributor

mengqiy commented Apr 18, 2018

We probably want a release note, since this is a behavior change to fix a bug.
The code LGTM

@juanvallejo

This comment has been minimized.

Member

juanvallejo commented Apr 18, 2018

lgtm pending a release note

@ceshihao

This comment has been minimized.

Contributor

ceshihao commented Apr 19, 2018

Add a meaningful release note.

@dixudx

This comment has been minimized.

Member

dixudx commented Apr 19, 2018

/retest

@dixudx

This comment has been minimized.

Member

dixudx commented Apr 19, 2018

@ceshihao Would you please squash your commits. No need to have 4 commits on 2 files.

@ceshihao

This comment has been minimized.

Contributor

ceshihao commented Apr 19, 2018

@dixudx
Squash to a single commit.

@dixudx

This comment has been minimized.

Member

dixudx commented Apr 19, 2018

/lgtm

@dixudx

This comment has been minimized.

Member

dixudx commented Apr 19, 2018

ping @kubernetes/sig-cli-maintainers for approval.

@smarterclayton

This comment has been minimized.

Contributor

smarterclayton commented Apr 19, 2018

/approve

@k8s-ci-robot

This comment has been minimized.

Contributor

k8s-ci-robot commented Apr 19, 2018

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ceshihao, dixudx, smarterclayton

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-merge-robot

This comment has been minimized.

Contributor

k8s-merge-robot commented Apr 19, 2018

Automatic merge from submit-queue (batch tested with PRs 62642, 62855, 62487, 62858, 62873). If you want to cherry-pick this change to another branch, please follow the instructions here.

@k8s-merge-robot k8s-merge-robot merged commit 9031f9a into kubernetes:master Apr 19, 2018

16 checks passed

Submit Queue Queued to run github e2e tests a second time.
Details
cla/linuxfoundation ceshihao authorized
Details
pull-kubernetes-bazel-build Job succeeded.
Details
pull-kubernetes-bazel-test Job succeeded.
Details
pull-kubernetes-cross Skipped
pull-kubernetes-e2e-gce Job succeeded.
Details
pull-kubernetes-e2e-gce-device-plugin-gpu Job succeeded.
Details
pull-kubernetes-e2e-gke Skipped
pull-kubernetes-e2e-kops-aws Job succeeded.
Details
pull-kubernetes-integration Job succeeded.
Details
pull-kubernetes-kubemark-e2e-gce Job succeeded.
Details
pull-kubernetes-local-e2e Skipped
pull-kubernetes-local-e2e-containerized Skipped
pull-kubernetes-node-e2e Job succeeded.
Details
pull-kubernetes-typecheck Job succeeded.
Details
pull-kubernetes-verify Job succeeded.
Details

@ceshihao ceshihao deleted the ceshihao:kubectl_get_pod_status branch Apr 20, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment