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

EnableKubernetesMockClient && junit5 - KubernetesMockServer stopped to work correctly from the version 7.0.x #6847

Open
svagner opened this issue Jan 31, 2025 · 4 comments

Comments

@svagner
Copy link

svagner commented Jan 31, 2025

Describe the bug

Example of code:

import io.fabric8.kubernetes.api.model.PodList;
import io.fabric8.kubernetes.api.model.PodListBuilder;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.server.mock.EnableKubernetesMockClient;
import io.fabric8.kubernetes.client.server.mock.KubernetesMockServer;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertNotNull;

@EnableKubernetesMockClient
class KubernetesClientTest {
    KubernetesClient client;
    KubernetesMockServer server;

    @Test
    void testPodList() {
        // Mock the server response
        server.expect().get().withPath("/api/v1/namespaces/default/pods")
              .andReturn(200, new PodListBuilder().build())
              .once();

        // Use the client to list pods
        PodList podList = client.pods().inNamespace("default").list();
        assertNotNull(podList);
    }
}

Result:

io.fabric8.kubernetes.client.KubernetesClientException: Connection was closed
	at [email protected]/io.fabric8.kubernetes.client.dsl.internal.OperationSupport.waitForResult(OperationSupport.java:509)
	at [email protected]/io.fabric8.kubernetes.client.dsl.internal.BaseOperation.list(BaseOperation.java:451)
	at [email protected]/io.fabric8.kubernetes.client.dsl.internal.BaseOperation.list(BaseOperation.java:419)
	at [email protected]/io.fabric8.kubernetes.client.dsl.internal.BaseOperation.list(BaseOperation.java:98)
	at my.package@SNAPSHOT/my.package.KubernetesClientTest.testPodList(KubernetesClientTest.java:30)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
Caused by: io.vertx.core.http.HttpClosedException: Connection was closed

Fabric8 Kubernetes Client version

7.0.1

Steps to reproduce

  • Run the test from the bug description

Expected behavior

  • in version 6.13.4 the same code works without any issues and return results.

Runtime

minikube

Kubernetes API Server version

1.25.3@latest

Environment

macOS

Fabric8 Kubernetes Client Logs

System.setProperty("kubernetes.client.logging.level", "FINE"); 

doesn't provide any details anymore

Additional context

No response

@manusa
Copy link
Member

manusa commented Jan 31, 2025

Could you try with 7.1.0 which was released yesterday.
It might be related to a bug with the Vertx client.

(also note that you mention in the issue that you're using 7.0.1, but your stacktrace reports 7.0.0, 7.0.1 should correct that bug too).

@svagner
Copy link
Author

svagner commented Jan 31, 2025

7.1.0 has the same problem:(

@manusa
Copy link
Member

manusa commented Jan 31, 2025

7.1.0 has the same problem:(

Could you share the new stack trace?

@svagner
Copy link
Author

svagner commented Jan 31, 2025

o.fabric8.kubernetes.client.KubernetesClientException: Connection was closed
        at [email protected]/io.fabric8.kubernetes.client.dsl.internal.OperationSupport.waitForResult(OperationSupport.java:509)
        at [email protected]/io.fabric8.kubernetes.client.dsl.internal.BaseOperation.list(BaseOperation.java:451)
        at [email protected]/io.fabric8.kubernetes.client.dsl.internal.BaseOperation.list(BaseOperation.java:419)
        at [email protected]/io.fabric8.kubernetes.client.dsl.internal.BaseOperation.list(BaseOperation.java:98)
        at my.package@SNAPSHOT/my.package.KubernetesClientTest.testPodList(KubernetesClientTest.java:30)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
Caused by: io.vertx.core.http.HttpClosedException: Connection was closed

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

2 participants