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

KubernetesMockServer does not emit change events on custom resource deletion with a finalizer #5020

Closed
armisz opened this issue Mar 31, 2023 · 2 comments · Fixed by #5040
Closed
Assignees
Labels
bug component/kubernetes-server-mock Deals with the kubernetes-server-mock directory mainly
Milestone

Comments

@armisz
Copy link

armisz commented Mar 31, 2023

Describe the bug

The deletion of a custom resource during a JUnit 5 test (which uses KubernetesMockServer) does not trigger any resource events which can be processed by a ResourceEventHandler. The custom resource has a finalizer set.

Fabric8 Kubernetes Client version

6.5.1

Steps to reproduce

  1. Write a JUnit test which creates an modifies a custom resource. Emitted events are processed using a ResourceEventHandler.
  2. Delete the custom resource using the KubernetesClient. The custom resource has a finalizer set.
  3. No update or delete events will be caught in the ResourceEventHandler.
  4. Getting the custom resource using the KubernetesClient shows that the deletionTimestamp has been set.

I attach the last log entry of the unit test. Please note that the bug only shows in tests, the deletion of the custom resource works fine in production code (i.e. there are emitted events to be processed).

Expected behavior

After the deletion an update event will be sent.
When I remove the finalizer a delete event will be sent.

Runtime

Kubernetes (vanilla)

Kubernetes API Server version

1.24

Environment

Windows

Fabric8 Kubernetes Client Logs

[2023-03-31 18:04:26,014] [INFO] [MockWebServer /127.0.0.1:57355] [{}] [okhttp3.mockwebserver.MockWebServer] - MockWebServer[57316] received request: DELETE /apis/acme.com/v1/namespaces/acme/databaseschemas/db-schema-delete HTTP/1.1 and responded: HTTP/1.1 200 OK

Additional context

No response

@shawkins
Copy link
Contributor

I think this is because the finalizer handling logic is not incrementing the resourceVersion, so the informer logic does not know the resource has changed.

@armisz
Copy link
Author

armisz commented Apr 1, 2023

The state of the resource after the mock server has finished processing it is: resourceVersion is null, finalizers is empty.
Since I do not control the resourceVersion, I assume that this is a bug in the mock server.

@manusa manusa added component/kubernetes-server-mock Deals with the kubernetes-server-mock directory mainly bug labels Apr 4, 2023
@manusa manusa moved this to Planned in Eclipse JKube Apr 5, 2023
shawkins added a commit to shawkins/kubernetes-client that referenced this issue Apr 6, 2023
shawkins added a commit to shawkins/kubernetes-client that referenced this issue Apr 6, 2023
@manusa manusa added this to the 6.6.0 milestone Apr 11, 2023
@github-project-automation github-project-automation bot moved this from Planned to Done in Eclipse JKube Apr 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug component/kubernetes-server-mock Deals with the kubernetes-server-mock directory mainly
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants