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

Rewriting the folder structure in a hook #66

Closed
krotscheck opened this issue Apr 7, 2016 · 9 comments
Closed

Rewriting the folder structure in a hook #66

krotscheck opened this issue Apr 7, 2016 · 9 comments

Comments

@krotscheck
Copy link
Contributor

Heya! I have a rather odd use case - we've got a multi-cloud environment, and each of our mirrors is actually an AFS slave in each cloud, with two masters with all the data on them. The upside of this is that we only have two enormous mirrors, and each slave only keeps those things in cache that are frequently used. Downside... well, AFS has a practical folder size limit of ~64K files.

To resolve this with pip, rpm, etc, we've rewritten the folder structure, and hidden it behind mod_rewrite. For example: /foo becomes /f/foo, /bar becomes /b/bar, /q becomes /q/q. I'm currently trying to build a set of registry-static hooks which automatically generate this structure, and I need a bit of advice and/or troubleshooting help.

Firstly, relocating the tarballs is quick and simple. Yay! I can't, unfortunately, figure out how to relocate the various index.json files. Digging into follow-registry and patch-package-json showed me that the folder name for the json output is derived from the package name. Modifying that permanently changes the name of the package in the mirror, so that's not an option.

My current thought, is that I can update registry-static to provide an additional parameter in the data that gets sent to the hooks (peer to tarballs), which includes the actual output directory, and permit modifications to persist. This would propagate to where the tarballs live, etc.

I'd like to know if that's an approach you'd be comfortable with, and/or whether there's a different way to approach this problem, and if not - where the best place to apply those changes would be.

Thanks in advance :)

@davglass
Copy link
Owner

davglass commented Apr 7, 2016

My current thought, is that I can update registry-static to provide an additional parameter in the data that gets sent to the hooks (peer to tarballs), which includes the actual output directory, and permit modifications to persist. This would propagate to where the tarballs live, etc.

I'm totally fine with this idea, @bengl thoughts?

@bengl
Copy link
Collaborator

bengl commented Apr 7, 2016

If I'm reading this right, it may actually be easier to implement a shim blob-store over fs-blob-store that does whatever directory changes and modifications to JSON that are necessary.

If you could even do a rewrite rule on nginx to insert the appropriate directories so that it all looks normal to your npm clients, but I don't think that's strictly necessary.

@krotscheck
Copy link
Contributor Author

@bengl Ya know, I think that just might work. Let me see what I can come up with and get back to this thread :)

@krotscheck
Copy link
Contributor Author

And we have a winner! https://github.com/krotscheck/js-sorting-fs-blob-store
I'm still writing tests to make sure it's well covered, thanks for your help!

@davglass
Copy link
Owner

davglass commented Apr 8, 2016

Awesome! 🍻

@krotscheck
Copy link
Contributor Author

A couple more questions: Is it safe to kill the process and resume? Example:

#!/bin/bash

set -e

CMD="/usr/bin/registry-static"
CMD_ARGS="-d localhost -o /afs/.openstack.org/mirror/npm --blobstore afs-blob-store"

echo "Obtaining npm tokens and running registry-static."
k5start -t -f /etc/npm.keytab service/npm -- timeout -k 2m 30m $CMD $CMD_ARGS

echo "registry-static completed successfully, running vos release."
k5start -t -f /etc/afsadmin.keytab service/afsadmin -- vos release -v mirror.npm

Also, have either of you tried replacing the absolute tarball paths with relative URL's? Instead of http://foo.com/npm/my_mirror_package, use /npm/my_mirror_package? I can use mod_substitute to change things, but if it just works with folder paths, that'd be easier.

@davglass
Copy link
Owner

davglass commented Apr 8, 2016

It should be safe to kill it, it keeps a sequence file for the module that it's processing and will resume at that spot when it starts back up.

As for the relative path, I don't think the npm client can handle that. It should fetch the tarball exactly from the URL that it sees it in the json file that it parses.

@krotscheck
Copy link
Contributor Author

Gotcha, so mod_substitute's the way to go. Thanks for the insight.

@krotscheck
Copy link
Contributor Author

Closing, as our mirrors are up and running! (mostly- second discussion pending)

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

3 participants