oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
74.47k stars 2.78k forks source link

@kubernetes/client-node exec doesn't work #15093

Open MarcusAhlfors opened 2 weeks ago

MarcusAhlfors commented 2 weeks ago

What version of Bun is running?

1.1.34+5e5e7c60f

What platform is your computer?

Linux 6.1.106-116.188.amzn2023.aarch64 aarch64 aarch64

What steps can reproduce the bug?

When trying to use kubernetes exec the call goes through but never returns anything or calls the callback. Below is the minimal code that seems to reproduce the problem. The code works in node. Other parts of @kubernetes/client-node seems to work.

import * as k8s from '@kubernetes/client-node';
import { CoreV1Api } from '@kubernetes/client-node';
import { PassThrough } from 'stream';

const kc = new k8s.KubeConfig();
kc.loadFromDefault();
const cluster: CoreV1Api = kc.makeApiClient(k8s.CoreV1Api);

(async () => {
  const stdoutTunnel = new PassThrough();
  const stderrTunnel = new PassThrough();
  const stdinTunnel = new PassThrough();
  await new k8s.Exec(kc).exec(
    'namespace',
    'podname',
    'containername',
    ['ls', '-la'],
    stdoutTunnel,
    stderrTunnel,
    stdinTunnel,
    false,
    async (status: k8s.V1Status) => console.log('STUFF HAPPENED', status)
  );
})();

What is the expected behavior?

I expect to see "STUFF HAPPENED" in console.log

What do you see instead?

Nothing is written to console.log

Additional information

The code works in node

MarcusAhlfors commented 2 weeks ago

Later I tried a version with raw Websockets using the ws npm package. There I see the same issue, works in node, but not in bun.

I finally got i working in bun also using raw tls.connect(), which i suspect ws also uses eventually.

So my (naive) takeaway is that @kubernetes/client-node is not to blame but probably bun or the ws package, or the combination.

MarcusAhlfors commented 2 weeks ago

Investigated this some more

So issues seems to be that buns own WebSocket implementation doesn't support adding own certificates.