kubernetes / client-go

Go client for Kubernetes.
Apache License 2.0
9.12k stars 2.95k forks source link

EventRecorder comment contradicts with Event field comment #1375

Open npinaeva opened 2 months ago

npinaeva commented 2 months ago

EventRecorder interface used for events/v1 says https://github.com/kubernetes/client-go/blob/53c7e93bf282a011512dee21bf4acb71b49aca1c/tools/internal/events/interfaces.go#L35-L38 implying that the field should be machine-readable. At the same time Event.Reason comment says

    // reason is why the action was taken. It is human-readable.
    // This field cannot be empty for new Events and it can have at most 128 characters.

https://github.com/kubernetes/api/blob/9dc1a952bda9aeb400aa6409b7d89eff50d6ea77/events/v1/types.go#L61-L63 implying it should be human-readable. Also, Event.Action field says it should be machine-readable, so I would expect it to be used for switch statements. I am confused, please help.

sundaram2021 commented 2 months ago

The reason field serves both machine-readable and human-readable purposes.

These are not mutually exclusive; the key is to balance readability for both humans and machines. A concise, formatted reason like PodScheduled can serve both purposes effectively.

some thing like can be a solution .....