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

CoreV1Event JSON validation fails due to missing reportingController field #3668

Closed
restenb opened this issue Aug 29, 2024 · 5 comments
Closed

Comments

@restenb
Copy link

restenb commented Aug 29, 2024

Describe the bug
On docker-desktop with the given k8s version, event JSONs contain the field reportingController. This is not included in CoreV1Event.java, and the validation fails with the error message

The field reportingController in the JSON string is not defined in the CoreV1Event properties.

Raw JSON returned:
{\"kind\":\"Event\",\"apiVersion\":\"events.k8s.io/v1\",\"metadata\":{\"name\":\"pod\",\"namespace\":\"pods\",\"uid\":\"312e32e1-0c8e-416f-ad47-a6958432bd24\",\"resourceVersion\":\"8108227\",\"creationTimestamp\":\"2024-08-29T14:37:04Z\",\"managedFields\":[{\"manager\":\"kube-scheduler\",\"operation\":\"Update\",\"apiVersion\":\"events.k8s.io/v1\",\"time\":\"2024-08-29T14:37:04Z\",\"fieldsType\":\"FieldsV1\",\"fieldsV1\":{\"f:action\":{},\"f:eventTime\":{},\"f:note\":{},\"f:reason\":{},\"f:regarding\":{},\"f:reportingController\":{},\"f:reportingInstance\":{},\"f:type\":{}}}]},\"eventTime\":\"2024-08-29T14:37:04.418330Z\",\"reportingController\":\"default-scheduler\",\"reportingInstance\":\"default-scheduler-docker-desktop\",\"action\":\"Binding\",\"reason\":\"Scheduled\",\"regarding\":{\"kind\":\"Pod\",\"namespace\":\"pods\",\"name\":\"pod\",\"uid\":\"52682376-1685-4d80-b507-9e13d827a728\",\"apiVersion\":\"v1\",\"resourceVersion\":\"8108224\"},\"note\":\"Successfully assigned pods/pod1 to docker-desktop\",\"type\":\"Normal\",\"deprecatedSource\":{},\"deprecatedFirstTimestamp\":null,\"deprecatedLastTimestamp\":null}"}

Client Version
21.0.1

Kubernetes Version
1.29.1

Java Version
Java 21

Expected behavior
The field is present or ignored in validation.

Server (please complete the following information):

  • OS: Windows 10 / Ubuntu 22 WSL
  • Environment: docker-desktop
@VanDavv

This comment was marked as outdated.

@brendandburns
Copy link
Contributor

What code is throwing this?

It looks like you are trying to parse an io.k8s.api.events.v1.Event into a io.k8s.api.core.v1.Event

the core event includes a reportingComponent vs a reportingController

You can find the full API specification here:
https://raw.githubusercontent.com/kubernetes/kubernetes/master/api/openapi-spec/swagger.json

@restenb
Copy link
Author

restenb commented Aug 30, 2024

That's strange, I'm creating a namespaced events watch using listNamespacedEvent(...) from EventsV1Api. When parsing the event out from the Watch object, this error message is seen:

{:type java.lang.IllegalArgumentException,
 :message "The field `reportingController` in the JSON string is not defined in the `CoreV1Event` properties.
 :at [io.kubernetes.client.openapi.models.CoreV1Event validateJsonObject "CoreV1Event.java" 605]}],
 :trace [[io.kubernetes.client.openapi.models.CoreV1Event validateJsonObject "CoreV1Event.java" 605] 
            [io.kubernetes.client.openapi.models.CoreV1Event$CustomTypeAdapterFactory$1 read "CoreV1Event.java" 678] 
            [io.kubernetes.client.openapi.models.CoreV1Event$CustomTypeAdapterFactory$1 read "CoreV1Event.java" 668]

It's obviously being parsed as CoreV1Event, while I assume the correct type would be EventsV1Event instead. Maybe it's a type conversion issue somehow in my code, but I'm not invoking CoreV1Event or casting anywhere and this still occurs...

@brendandburns
Copy link
Contributor

How are you creating the Watch? Can you send your sample code? Watch is a generic type, are you accidentally making it Watch<CoreV1Event>?

@restenb
Copy link
Author

restenb commented Sep 2, 2024

You are right of course. Things were complicated by being in a different language than Java, and I missed that the type being issued to the createWatch call in the end was CoreV1Event. Everything works again after switching to EventsV1Event.

@restenb restenb closed this as completed Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@VanDavv @brendandburns @restenb and others