Repository navigation
Add regulator to filesystem - #1695
Conversation
It's easily possible for a flood of requests to trigger thousands of concurrent file accesses on the storage driver. Each file I/O call creates a new OS thread that is not reaped by the Golang runtime. By limiting it to only 100 at a time we can effectively bound the number of OS threads in use by the storage driver. Docker-DCO-1.1-Signed-off-by: Josh Hawn <[email protected]> (github: jlhawn) Signed-off-by: Tony Holdstock-Brown <[email protected]>
This commit refactors base.regulator into the 2.4 interfaces and adds a filesystem configuration option `maxthreads` to configure the regulator. By default `maxthreads` is set to 100. This means the FS driver is limited to 100 concurrent blocking file operations. Any subsequent operations will block in Go until previous filesystem operations complete. This ensures that the registry can never open thousands of simultaneous threads from os filesystem operations. Note that `maxthreads` can never be less than 25. Add test case covering parsable string maxthreads Signed-off-by: Tony Holdstock-Brown <[email protected]>
Signed-off-by: Tony Holdstock-Brown <[email protected]>
|
LGTM (although you could have just pushed to the old PR 😿 ) |
| case uint64: | ||
| maxThreads = v | ||
| case int, int32, int64: | ||
| maxThreads = uint64(reflect.ValueOf(v).Convert(reflect.TypeOf(threads)).Int()) |
There was a problem hiding this comment.
Minor issue: Should probably check that the value is non-negative before casting it to uint64
|
LGTM |
| } | ||
|
|
||
| if maxThreads < minThreads { | ||
| maxThreads = minThreads |
There was a problem hiding this comment.
Also, maybe this should log if it's overriding the thread limit because it's too low.
There was a problem hiding this comment.
Unfortunately no context is passed to drivers as they're instantiated, so we can't get the logger that's currently in use.
Maybe that could be added as another separate issue?
Signed-off-by: Tony Holdstock-Brown <[email protected]>
|
@SvenDowideit : what is the documentation build saying? |
|
Probably not available at the time, but looks like a lot of this code could be replaced with Also, do we have a description of the pathology that led to this change? It's odd to create a driver specific parameter to deal with a Go bug that is triggered by infrastructure conditions. For example, do we know that this resource exhaustion wasn't caused by another bug? |
…esystem Add regulator to filesystem
…esystem Add regulator to filesystem
This is a rebased and squashed version of #1674.
The previous PR was as follows:
This PR adds a regulator wrapper around the Filesystem driver.
The regulator ensures that there is an upper bound on the number
of concurrent blocking filesystem operations which spawn new
threads.
By default maxthreads is set to 100. This means the FS driver is
limited to 100 concurrent blocking file operations. Any subsequent
operations will block in Go until previous filesystem operations
complete.
This ensures that the registry can never open thousands of simultaneous
threads from os filesystem operations.
Note that maxthreads can never be less than 25.
PS: Thanks @jlhawn for the regulator implementation.