Skip to content
This repository has been archived by the owner on Aug 31, 2022. It is now read-only.

Wrong GetTimestampMs value of FailedScheduling event #194

Open
lobshunter opened this issue Apr 16, 2022 · 1 comment · May be fixed by #195
Open

Wrong GetTimestampMs value of FailedScheduling event #194

lobshunter opened this issue Apr 16, 2022 · 1 comment · May be fixed by #195

Comments

@lobshunter
Copy link

On kubernetes 1.19.x version, kube-scheduler emits FailedScheduling event with FirstTimestamp field set to null.

$ kubectl get event mypod.16e645b5c10bc186 -o json | jq
{
  "action": "Scheduling",
  "apiVersion": "v1",
  "eventTime": "2022-04-16T04:22:40.408032Z",
  "firstTimestamp": null,
  "involvedObject": {
    "apiVersion": "v1",
    "kind": "Pod",
    "name": "mypod",
    "namespace": "mynamespace",
    "resourceVersion": "775554465",
    "uid": "1901567b-4b02-4b9c-a67f-2c8977a818d6"
  },
  "kind": "Event",
  "lastTimestamp": null,
  "message": "0/1 nodes are available: 1 node(s) didn't match node selector.",
  "metadata": {
    "creationTimestamp": "2022-04-16T04:22:40Z",
    "name": "mypod.16e645b5c10bc186",
    "namespace": "mynamespace",
    "resourceVersion": "775554468",
    "selfLink": "/api/v1/namespaces/mynamespace/events/mypod.16e645b5c10bc186",
    "uid": "dd5843da-a3f1-404a-9f40-2c592a256054"
  },
  "reason": "FailedScheduling",
  "reportingComponent": "default-scheduler",
  "reportingInstance": "default-scheduler-172.16.4.67",
  "source": {},
  "type": "Warning"
}

GetTimestampMs method should read timestamp from eventTime instead. Otherwise the timestamp is regarded as zero value, such timestamp cause issues(e.g. Loki sink rejects the event).

I will submit a PR for this and check the behavior of different versions of kube-scheduler.

@lobshunter
Copy link
Author

lobshunter commented Apr 16, 2022

There are two very similar EventRecorder implementations in client-go, one uses EventTime, the other uses FirstTimestamp and LastTimestamp.😅

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant