kubernetes-client / java

Official Java client library for kubernetes
http://kubernetes.io/
Apache License 2.0
3.59k stars 1.91k forks source link

Exec not working for k8s 1.9, 1.10 servers #225

Closed rjeberhard closed 6 years ago

rjeberhard commented 6 years ago

The recent work on Exec and ExecExample is working great for k8s 1.7.x and 1.8.x servers; however, it's not working against 1.9 and 1.10.

The behavior with 1.9 and 1.10 is that no messages come in on channel 1, but instead there is an immediate empty message on channel 3 (the signaling channel).

I'm happy to help debug and resolve this, but I'd be grateful for insights into what changed in the API server's use of web sockets.

rjeberhard commented 6 years ago

I've been experimenting with kubectl --v=99 exec ... to see a successful flow. The only thing I can match with kubernetes-client/java Exec is that kubectl does a POST and this client does a GET. If I try a local change to use POST, the WebSockets subsystem complains that only GET is supported.

brendandburns commented 6 years ago

The flow is different for kubectl (at least it used to be...) Kubectl used the older SPDY based stream protocol, whereas the Java code uses the newer HTTP2 server flow.

Have you tried either of the other two streaming commands (PortForward or Attach)?

It would be interesting to see if those work...

brendandburns commented 6 years ago

I'll also try to reproduce this locally, but I swear I tested it against 1.9.6 on my Raspberry Pi cluster...

suchwerk commented 6 years ago

I have exactly the same issue (empty message on channel 3). On both 1.9 and 1.10 servers.

ERROR io.kubernetes.client.Exec - Error parsing exit code from status channel response java.lang.NullPointerException: null at io.kubernetes.client.Exec.parseExitCode(Exec.java:207) at io.kubernetes.client.Exec$ExecProcess$1.handleMessage(Exec.java:246) at io.kubernetes.client.util.WebSocketStreamHandler.bytesMessage(WebSocketStreamHandler.java:70) at io.kubernetes.client.util.WebSockets$Listener.onMessage(WebSockets.java:135) at com.squareup.okhttp.internal.ws.RealWebSocket$1.onMessage(RealWebSocket.java:62) at com.squareup.okhttp.internal.ws.WebSocketReader.readMessageFrame(WebSocketReader.java:242) at com.squareup.okhttp.internal.ws.WebSocketReader.processNextFrame(WebSocketReader.java:103) at com.squareup.okhttp.internal.ws.RealWebSocket.readMessage(RealWebSocket.java:97) at com.squareup.okhttp.ws.WebSocketCall.createWebSocket(WebSocketCall.java:153) at com.squareup.okhttp.ws.WebSocketCall.access$000(WebSocketCall.java:40) at com.squareup.okhttp.ws.WebSocketCall$1.onResponse(WebSocketCall.java:98) at com.squareup.okhttp.Call$AsyncCall.execute(Call.java:177) at com.squareup.okhttp.internal.NamedRunnable.run(NamedRunnable.java:33) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.base/java.lang.Thread.run(Thread.java:844)

Portforwarding does not work either java.lang.IllegalStateException at io.kubernetes.client.util.WebSocketStreamHandler.getInputStream(WebSocketStreamHandler.java:122)

brendandburns commented 6 years ago

For the first part of the issue, the problem looks like 1.9 and 1.10 changed the defaults for stdout and stderr from true to false.

I'm not seeing the error status problem reported by @suchwerk can you give more details for the repro?

Thanks!

brendandburns commented 6 years ago

@suchwerk can you open a separate issue for port-forward? Thanks!

brendandburns commented 6 years ago

Well I added a check to catch the NPE that's in the stack trace, but I don't think that fixes what you're seeing it just prevents the exception.

--brendan


From: suchwerk notifications@github.com Sent: Tuesday, April 3, 2018 2:25:22 AM To: kubernetes-client/java Cc: Brendan Burns; Mention Subject: Re: [kubernetes-client/java] Exec not working for k8s 1.9, 1.10 servers (#225)

@brendandburnshttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fbrendandburns&data=02%7C01%7Cbburns%40microsoft.com%7Cce2fdcbc577a428b70c008d59944de88%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636583443424270895&sdata=HPN%2B7Xw7uRGZYe6dqiN4X7QGyxJWvnqbSg4HtBdj7Ps%3D&reserved=0

I'm not seeing the error status problem reported by @suchwerkhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fsuchwerk&data=02%7C01%7Cbburns%40microsoft.com%7Cce2fdcbc577a428b70c008d59944de88%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636583443424270895&sdata=u9DmZFYVyx%2F4EkdyROgLT%2BdZlmElptEIjHTL%2BtYjjiI%3D&reserved=0 can you give more details for the repro?

I guess you mean the first stackrace? I have seen different error messages/stacktraces while setting setDebugging true or false.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fkubernetes-client%2Fjava%2Fissues%2F225%23issuecomment-378186751&data=02%7C01%7Cbburns%40microsoft.com%7Cce2fdcbc577a428b70c008d59944de88%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636583443424270895&sdata=uPY85%2F%2FTq8RCJ%2Ffw1JPsywbQh1NPD1rl7U4y6Vr60J4%3D&reserved=0, or mute the threadhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAFfDgru_OIdl6S-coBqmTNAcltnFysIrks5tk0ACgaJpZM4TCKWz&data=02%7C01%7Cbburns%40microsoft.com%7Cce2fdcbc577a428b70c008d59944de88%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636583443424270895&sdata=fNSxM17V4PRtiEHKJxU1qOYm97sMTJOvMhesvBZmkMM%3D&reserved=0.