fabric8io / kubernetes-client

Java client for Kubernetes & OpenShift
http://fabric8.io
Apache License 2.0
3.41k stars 1.46k forks source link

MockServer is rejecting ServerSideApply operation making it impossible to test #5360

Closed AbdelrhmanHamouda closed 1 year ago

AbdelrhmanHamouda commented 1 year ago

Describe the bug

Hello,

In my code I have this job = client.batch().v1().jobs().inNamespace(namespace).resource(job).forceConflicts().serverSideApply();

And in my test, I use junt5 and use the @EnableKubernetesMockClient(https = false, crud = true)

When I run the test, I see the following message from the mock server and the test fails

Jul 26, 2023 4:14:54 PM okhttp3.mockwebserver.MockWebServer$3 processOneRequest
INFO: MockWebServer[56771] received request: PATCH /apis/batch/v1/namespaces/default/jobs/team-perftest-master?fieldManager=fabric8&force=true HTTP/1.1 and responded: HTTP/1.1 404 Client Error

I didn't have force at the start, but even when I added it, it is still not working.

Side note: I tested this with a small minikube cluster and ServerSideApply works without an issue.

Fabric8 Kubernetes Client version

6.7.2

Steps to reproduce

as mentioned in the description

Expected behavior

For the MockClint to accept the request and return 2xx

Runtime

other (please specify in additional context)

Kubernetes API Server version

other (please specify in additional context)

Environment

macOS

Fabric8 Kubernetes Client Logs

Jul 26, 2023 4:14:54 PM okhttp3.mockwebserver.MockWebServer$3 processOneRequest
INFO: MockWebServer[56771] received request: PATCH /apis/batch/v1/namespaces/default/jobs/team-perftest-master?fieldManager=fabric8&force=true HTTP/1.1 and responded: HTTP/1.1 404 Client Error

2023-07-26 16:14:54,166 ERROR [Test worker] com.locust.operator.controller.utils.resource.manage.ResourceCreationManager: Exception occurred during Job creation: Failure executing: PATCH

Additional context

I am upgrading from an older version of the client where CreateOrReplace() was used and working

rohanKanojia commented 1 year ago

Could this be duplicate of https://github.com/fabric8io/kubernetes-client/issues/5337 ?

AbdelrhmanHamouda commented 1 year ago

@rohanKanojia True, thank you for sharing this. After reading through the issue, it is clear that it is the same point.