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

kubectl: fix the Scheduled eventTime is <unknown> when printing event #90227

Merged
merged 1 commit into from Apr 20, 2020

Conversation

gosoon
Copy link
Contributor

@gosoon gosoon commented Apr 17, 2020

What type of PR is this?
/kind bug

What this PR does / why we need it:
When scheduler using v1beta1.events(#78447),the Scheduled event is not set the LastTimestamp and the FirstTimestamp,only set the EventTime,so use kubectl get event and kubectl describe pod xxx you will see that the timestamp of the scheduled event is <unknown>,as shown below,in those cases we fallback to eventTime.

$ kubectl get event
LAST SEEN   TYPE     REASON              OBJECT                        MESSAGE
<unknown>   Normal   Scheduled           pod/nginx-6c975b59f8-gvmjr    Successfully assigned default/nginx-6c975b59f8-gvmjr to minikube

$ kubectl describe pod xxx
......
Events:
  Type    Reason     Age        From               Message
  ----    ------     ----       ----               -------
  Normal  Scheduled  <unknown>  default-scheduler  Successfully assigned default/nginx-6c975b59f8-gvmjr to minikube
......

Which issue(s) this PR fixes:

Fixes # 89689

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

Fix kubectl printer to correctly handle timestamps of events emitted using events.k8s.io API

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

None

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/bug Categorizes issue or PR as related to a bug. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Apr 17, 2020
@k8s-ci-robot
Copy link
Contributor

Hi @gosoon. 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 the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Apr 17, 2020
@gosoon
Copy link
Contributor Author

gosoon commented Apr 17, 2020

/sig cli

@k8s-ci-robot k8s-ci-robot added sig/cli Categorizes an issue or PR as relevant to SIG CLI. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Apr 17, 2020
@gosoon
Copy link
Contributor Author

gosoon commented Apr 17, 2020

/area kubectl

@zhouya0
Copy link
Contributor

zhouya0 commented Apr 17, 2020

Thanks for your PR, but seems this is dup of #89999 which is still waiting for another review.
Maybe you could add kubectl describe part after that PR is merged.

@gosoon
Copy link
Contributor Author

gosoon commented Apr 17, 2020

Ok, I have changed the commit content and only fixed the kubectl describe pod xxx part.

@k8s-ci-robot k8s-ci-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Apr 17, 2020
@@ -3642,6 +3642,9 @@ func DescribeEvents(el *corev1.EventList, w PrefixWriter) {
interval = fmt.Sprintf("%s (x%d over %s)", translateTimestampSince(e.LastTimestamp), e.Count, translateTimestampSince(e.FirstTimestamp))
} else {
interval = translateTimestampSince(e.FirstTimestamp)
if e.FirstTimestamp.IsZero() {
interval = translateTimestampSince(metav1.Time(e.EventTime))
Copy link
Contributor

Choose a reason for hiding this comment

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

EventTime is metav1.MicroTime but not metav1.Time. So you need another translateMicroTimestampSince . Like #89999

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@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 Apr 17, 2020
@zhouya0
Copy link
Contributor

zhouya0 commented Apr 17, 2020

/ok-to-test
/lgtm

@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 Apr 17, 2020
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 17, 2020
Copy link
Contributor

@soltysh soltysh left a comment

Choose a reason for hiding this comment

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

/approve
/priority backlog
/retest

@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 Apr 20, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: gosoon, soltysh

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 Apr 20, 2020
@k8s-ci-robot k8s-ci-robot merged commit 5157383 into kubernetes:master Apr 20, 2020
@k8s-ci-robot k8s-ci-robot added this to the v1.19 milestone Apr 20, 2020
@dmcnaught
Copy link

We're seeing this issue in one of our 1.16.8 clusters. Can we get the fix added to a 1.16 point release?

@dmcnaught
Copy link

@gosoon We're having this problem with one of our 1.16 clusters and are wondering when/if there will be a 1.16 patch release to fix it. Do you know?

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Aug 26, 2020
k8s-ci-robot added a commit that referenced this pull request Sep 4, 2020
…90227-upstream-release-1.18

Automated cherry pick of #90227: kubectl: fix the Scheduled eventTime is <unknown> when use kubectl describe pod xxx
@cpanato
Copy link
Member

cpanato commented Oct 6, 2020

@dmcnaught Hello Duncan, 1.16 is no longer receiving the patch releases, I recommend you to upgrade your cluster to 1.17 at least.
The current supported Kubernetes versions are 1.17 / 1.18 and 1.19

k8s-ci-robot added a commit that referenced this pull request Oct 6, 2020
…90227-release-1.17

Automated cherry pick of #90227: kubectl: fix the Scheduled eventTime is <unknown> when use
@dmcnaught
Copy link

@dmcnaught Hello Duncan, 1.16 is no longer receiving the patch releases, I recommend you to upgrade your cluster to 1.17 at least.
The current supported Kubernetes versions are 1.17 / 1.18 and 1.19

yes - we upgraded to 1.17 in July/August.

There was a PR in our PaaS that helps up around the unknown timestamps: teamhephy/controller#129

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/kubectl 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/cli Categorizes an issue or PR as relevant to SIG CLI. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants