athens icon indicating copy to clipboard operation
athens copied to clipboard

Content-Length Support is required to make local pkgsite working

Open auzhva opened this issue 3 years ago • 8 comments

Is your feature request related to a problem? Please describe.

I'm trying to setup internal copy of pkgsite for private modules. It requires go proxy to be set up to get module content. Trying to use Athens for this purpose.

To read modules pkgsite relies on Content-Length header to be delivered by go proxy alongside with actual content.

See GetZipSize function. And its usage in fetch module. Which is quite extensive and intended to protect over oversized zip files.

Describe the solution you'd like Athens to send Content-Length header in it's responses

Describe alternatives you've considered No ideas yet

auzhva avatar Oct 11 '20 14:10 auzhva

I'm also running into this.

jaredallard avatar Oct 13 '20 02:10 jaredallard

Did a quick hack that makes this work: https://github.com/getoutreach/athens/commit/0a01d905e09e54bf439ddc562b1057a7fe11f0bc

jaredallard avatar Oct 13 '20 03:10 jaredallard

@jaredallard great - would you be ok with submitting a PR with that change?

arschles avatar Oct 22 '20 23:10 arschles

Works ok. The only caveat - from source code it looks a bit memory-consumption worrying as it keeps zip file in memory.

As of temporal solution looks fine and works.

auzhva avatar Oct 23 '20 07:10 auzhva

@arschles So sorry, didn't see this. And yeah, my only concern with submitting it is the memory usage. I'll see if I can get something better out by end of the month!

jaredallard avatar Nov 16 '20 02:11 jaredallard

@AlexeyUzhva if memory is a concern, one thing we can do is store the content size in storage when the module is first stored.

@jaredallard sounds good! can you do me a favor and @ me on a PR if/when you submit one?

arschles avatar Nov 19 '20 20:11 arschles

@AlexeyUzhva if memory is a concern, one thing we can do is store the content size in storage when the module is first stored.

That would be awesome!

Any chance that could get to the release? Any plans to add so?

auzhva avatar Mar 07 '21 08:03 auzhva

@AlexeyUzhva @jaredallard so we do have https://github.com/gomods/athens/pull/1681 (which is in the new v0.11.0 release). iirc, in most cases it's done in memory but we could probably use that abstraction to pre-compute the sizes and store them. Would having that feature (which presumably would eliminate an OOM issue) fix something for you?

From what pkgsite does, it looks like they just fail if the size is too big.

arschles avatar Mar 11 '21 20:03 arschles