-
Notifications
You must be signed in to change notification settings - Fork 144
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
Add --max-size flag to limit size of repositories #72
Conversation
@fd0 I have refactored to make the changes you recommended over in the other PR. But let's move the discussion here. :) |
There are a "lot" of changed lines because I made the methods get a Also, I now account for the size as blobs are deleted, for example when a prune happens. |
stat, err := os.Stat(path) | ||
if err != nil { | ||
if err == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically unrelated to my PR's purpose, but this fixes what I think was a bug that existed before, and with my PR, would affect the size counting if left unfixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, great catch
CI fails because golint is broken right now:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just one minor thing.
@@ -41,6 +41,7 @@ func init() { | |||
flags.BoolVar(&server.Debug, "debug", server.Debug, "output debug messages") | |||
flags.StringVar(&server.Listen, "listen", server.Listen, "listen address") | |||
flags.StringVar(&server.Log, "log", server.Log, "log HTTP requests in the combined log format") | |||
flags.Int64Var(&server.MaxRepoSize, "max-size", server.MaxRepoSize, "the maximum size of the repository in bytes") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, why is the default (the third parameter) set to server.MaxRepoSize
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just in case the server variable is ever initialized with a default MaxRepoSize, then it will be preserved by the flag, instead of overwriting it with 0 or some hard-coded default in a different place. That's all. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, fine with me ;)
* Add --max-size flag to limit repository size * Only update repo size on successful write * Use initial size as current size for first SaveBlob * Apply LimitReader to request body * Use HTTP 413 for size overage responses * Refactor size limiting; do checks after every write * Remove extra commented lines, d'oh * Account for deleting blobs when counting space usage * Remove extra commented line * Fix unrelated bug (inverted err check) * Update comment to trigger new CI build
The --max-size limits the number of bytes that can be stored to a repo. It only takes effect on SaveBlob.
Closes #65
Can see previous discussion at https://github.com/mholt/rest-server/pull/1
/cc @dotlambda