kubernetes-client / javascript

Javascript client
Apache License 2.0
1.97k stars 500 forks source link

ZlibError: zlib: unexpected end of file for cp.cpFromPod method #1521

Closed bodycombathuang closed 1 month ago

bodycombathuang commented 6 months ago

when I use cp.cpFromPod for a file with size about 6MB, I get error c:\typescript\node_modules\minizlib\index.js:154 this[_onError](new ZlibError(err)) ^ ZlibError: zlib: unexpected end of file at Unzip.write (c:\typescript\node_modules\minizlib\index.js:154:22) at Unzip.flush (c:\typescript\node_modules\minizlib\index.js:105:10) at Unzip.end (c:\typescript\node_modules\minizlib\index.js:111:10) at Unpack.end (c:\typescript\node_modules\tar\lib\parse.js:544:21) at Pipe.end (c:\typescript\node_modules\fs-minipass\node_modules\minipass\index.js:75:17) at ReadStream.[emitEnd2] (c:\typescript\node_modules\fs-minipass\node_modules\minipass\index.js:522:9) at ReadStream.[emitEnd] (c:\typescript\node_modules\fs-minipass\node_modules\minipass\index.js:507:21) at ReadStream.emit (c:\typescript\node_modules\fs-minipass\node_modules\minipass\index.js:458:27) at ReadStream.emit (c:\typescript\node_modules\fs-minipass\index.js:175:22) at ReadStream.[maybeEmitEnd] (c:\typescript\node_modules\fs-minipass\node_modules\minipass\index.js:440:12) { code: 'Z_BUF_ERROR', errno: -5, recoverable: false, file: 'C:\Users\zhhuan\AppData\Local\Temp/8a34ec6b-69f2-41f5-8026-af4c23168279', cwd: 'c:/typescript/json', tarCode: 'TAR_ABORT' }

I used latest version

brendandburns commented 6 months ago

I suspect that the network connection is getting interrupted, can you try to reproduce this locally with a minikube cluster where network isn't a problem?

brendandburns commented 6 months ago

There's also this PR that may help:

https://github.com/kubernetes-client/javascript/pull/1396

bodycombathuang commented 6 months ago

hi @brendandburns 1396 does not provide any workaround or solution if the file size is small, (several bytes), I cannot reproduce, it is reproduced for file that is larger than 5MB each time

bodycombathuang commented 6 months ago

https://github.com/kubernetes-client/javascript/blob/master/src/cp.ts async ({ status }) => { writerStream.close(); if (status === 'Failure' || errStream.size()) { throw new Error(Error from cpFromPod - details: \n ${errStream.getContentsAsString()}); } await tar.x({ file: tmpFileName, cwd: tgtPath, }); },

i guess it is because tar.x command is executed before "tar zcf" command is finished

k8s-triage-robot commented 3 months ago

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

You can:

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot commented 2 months ago

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

You can:

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

k8s-triage-robot commented 1 month ago

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues according to the following rules:

You can:

Please send feedback to sig-contributor-experience at kubernetes/community.

/close not-planned

k8s-ci-robot commented 1 month ago

@k8s-triage-robot: Closing this issue, marking it as "Not Planned".

In response to [this](https://github.com/kubernetes-client/javascript/issues/1521#issuecomment-2168553252): >The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs. > >This bot triages issues according to the following rules: >- After 90d of inactivity, `lifecycle/stale` is applied >- After 30d of inactivity since `lifecycle/stale` was applied, `lifecycle/rotten` is applied >- After 30d of inactivity since `lifecycle/rotten` was applied, the issue is closed > >You can: >- Reopen this issue with `/reopen` >- Mark this issue as fresh with `/remove-lifecycle rotten` >- Offer to help out with [Issue Triage][1] > >Please send feedback to sig-contributor-experience at [kubernetes/community](https://github.com/kubernetes/community). > >/close not-planned > >[1]: https://www.kubernetes.dev/docs/guide/issue-triage/ Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes-sigs/prow](https://github.com/kubernetes-sigs/prow/issues/new?title=Prow%20issue:) repository.