Skip to content
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

dockershim: fix started and finished timestamp of the container status #99585

Merged
merged 1 commit into from Mar 9, 2021

Conversation

Iceber
Copy link
Member

@Iceber Iceber commented Mar 1, 2021

Signed-off-by: Iceber Gu wei.cai-nat@daocloud.io

What type of PR is this?

/kind bug

What this PR does / why we need it:

When use crictl,Finished time is always 1754-08-31T06:49:24.128654848+08:05 in the run and create states, because FinishedAt is -6795364578871345152

[root@iceber-3 ~]# crictl inspect 587444fc34ec9
{
  "status": {
    "id": "587444fc34ec9846c163d0c74bbf985ac73662817a89e16b7328b955a03ef902",
    "metadata": {
      "attempt": 6,
      "name": "dx-arch-stolon-sentinel"
    },
    "state": "CONTAINER_RUNNING",
    "createdAt": "2021-03-01T16:45:23.390180141+08:00",
    "startedAt": "2021-03-01T16:45:23.544299436+08:00",
    "finishedAt": "1754-08-31T06:49:24.128654848+08:05",
    "exitCode": 0,

I think the default started and finished timestamp should be 0(zero value), not -6795364578871345152.

Which issue(s) this PR fixes:

Special notes for your reviewer:

fix crictl: kubernetes-sigs/cri-tools#724

Convert runtimeapi.ContainerStatus to kubecontainer.Status in the toKubeContainerStatus

if status.State != runtimeapi.ContainerState_CONTAINER_CREATED {
// If container is not in the created state, we have tried and
// started the container. Set the StartedAt time.
cStatus.StartedAt = time.Unix(0, status.StartedAt)
}
if status.State == runtimeapi.ContainerState_CONTAINER_EXITED {
cStatus.Reason = status.Reason
cStatus.Message = status.Message
cStatus.ExitCode = int(status.ExitCode)
cStatus.FinishedAt = time.Unix(0, status.FinishedAt)
}
return cStatus
}

Does this PR introduce a user-facing change?

Return zero time (midnight on Jan. 1, 1970) instead of negative number when reporting startedAt and finishedAt of the not started or a running Pod when using dockershim as a runtime.

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Mar 1, 2021
@k8s-ci-robot
Copy link
Contributor

Welcome @Iceber!

It looks like this is your first PR to kubernetes/kubernetes 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/kubernetes has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Mar 1, 2021
@k8s-ci-robot
Copy link
Contributor

Hi @Iceber. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added area/kubelet sig/node Categorizes an issue or PR as relevant to SIG Node. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Mar 1, 2021
@pacoxu
Copy link
Member

pacoxu commented Mar 1, 2021

/ok-to-test

Add a release note like below. You may change the word.

fix the wrong FinishedAt of container status

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Mar 1, 2021
@Iceber
Copy link
Member Author

Iceber commented Mar 1, 2021

I am going to modify the pull-kubernetes-bazel-test

@Iceber Iceber changed the title dockershim: fix FinishedAt of the container status [WIP] dockershim: fix FinishedAt of the container status Mar 1, 2021
@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Mar 1, 2021
@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Mar 1, 2021
@Iceber Iceber changed the title [WIP] dockershim: fix FinishedAt of the container status dockershim: fix started and finished timestamp of the container status Mar 1, 2021
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 1, 2021
Signed-off-by: Iceber Gu <wei.cai-nat@daocloud.io>
@k8s-ci-robot k8s-ci-robot removed the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Mar 2, 2021
@ehashman ehashman added this to Triage in SIG Node PR Triage Mar 2, 2021
@ehashman
Copy link
Member

ehashman commented Mar 2, 2021

/priority backlog
/assign @SergeyKanzhelev

@k8s-ci-robot k8s-ci-robot added priority/backlog Higher priority than priority/awaiting-more-evidence. and removed needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Mar 2, 2021
@ehashman ehashman moved this from Triage to Needs Reviewer in SIG Node PR Triage Mar 2, 2021
@pacoxu
Copy link
Member

pacoxu commented Mar 4, 2021

LGTM
leave to sig-node review

var state runtimeapi.ContainerState
var reason, message string
ct, st, ft := createdAt.UnixNano(), int64(0), int64(0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would the better fix be to change the defaults in getContainerTimestamps? This way if docker returns bad times, kubernetes will report the same

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, never mind. I got it. I wonder what docker returns as a Finish time that is converted to -6795364578871345152?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docker returns as a Finished time that is converted to 0(0001-01-01T00:00:00Z)

@SergeyKanzhelev
Copy link
Member

Please change the release note to:

Return zero time (midnight on Jan. 1, 1970) instead of negative number when reporting startedAt and finishedAt of the not started or a running Pod when using dockershim as a runtime.

@SergeyKanzhelev
Copy link
Member

/lgtm
/hold

hold for changing the release note

@k8s-ci-robot k8s-ci-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm "Looks good to me", indicates that a PR is ready to be merged. labels Mar 4, 2021
@SergeyKanzhelev
Copy link
Member

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 5, 2021
@Iceber
Copy link
Member Author

Iceber commented Mar 5, 2021

@SergeyKanzhelev the release note has been changed
PTAL, Thanks

@SergeyKanzhelev SergeyKanzhelev moved this from Needs Reviewer to Needs Approver in SIG Node PR Triage Mar 5, 2021
@mrunalp
Copy link
Contributor

mrunalp commented Mar 9, 2021

/approve

@mrunalp mrunalp moved this from Needs Approver to Done in SIG Node PR Triage Mar 9, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Iceber, mrunalp

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-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 9, 2021
@Iceber
Copy link
Member Author

Iceber commented Mar 9, 2021

/test pull-kubernetes-e2e-kind

@k8s-ci-robot k8s-ci-robot merged commit 40d8aed into kubernetes:master Mar 9, 2021
@k8s-ci-robot k8s-ci-robot added this to the v1.21 milestone Mar 9, 2021
@Iceber Iceber deleted the fix-finished-at branch March 12, 2021 09:40
@pacoxu pacoxu mentioned this pull request Aug 6, 2021
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/kubelet cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. priority/backlog Higher priority than priority/awaiting-more-evidence. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/node Categorizes an issue or PR as relevant to SIG Node. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
Development

Successfully merging this pull request may close these issues.

None yet

6 participants