-
Notifications
You must be signed in to change notification settings - Fork 18.7k
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
api: ContainerCreate: clean up BC conditions #46720
api: ContainerCreate: clean up BC conditions #46720
Conversation
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
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
runconfig/errors.go
Outdated
@@ -31,6 +31,8 @@ const ( | |||
ErrUnsupportedNetworkAndAlias validationError = "network-scoped alias is supported only for containers in user defined networks" | |||
// ErrConflictUTSHostname conflict between the hostname and the UTS mode | |||
ErrConflictUTSHostname validationError = "conflicting options: hostname and the UTS mode" | |||
// ErrEmptyConfig when container config is nil | |||
ErrEmptyConfig validationError = "Config cannot be empty in order to create a container" |
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.
Do we know if anything checks for this error message? (Was considering to fix the capitalisation (lowercase Config
))
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.
At least not the CLI. Is that enough to consider fixing the capitalization?
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.
Yes, probably; if CI still passes on 17.06 (and docker-py
), we're probably good to go.
I'm ok with doing it separately though; perhaps better for this case to have a clear commit where we changed it (in case we missed it being used somewhere, and need to find a regression point)
639eb62
to
6f1beb4
Compare
if hostConfig.PidsLimit != nil && *hostConfig.PidsLimit <= 0 { | ||
// Don't set a limit if either no limit was specified, or "unlimited" was | ||
// explicitly set. | ||
// Both `0` and `-1` are accepted as "unlimited", and historically any | ||
// negative value was accepted, so treat those as "unlimited" as well. | ||
hostConfig.PidsLimit = 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.
Funny how this is different in postContainerUpdate
moby/api/server/router/container/container_routes.go
Lines 456 to 462 in e36260f
if updateConfig.PidsLimit != nil && *updateConfig.PidsLimit <= 0 { | |
// Both `0` and `-1` are accepted to set "unlimited" when updating. | |
// Historically, any negative value was accepted, so treat them as | |
// "unlimited" as well. | |
var unlimited int64 | |
updateConfig.PidsLimit = &unlimited | |
} |
The same error is already returned by `(*Daemon).containerCreate()` but since this function is also called by the cluster executor, the error has to be duplicated. Doing that allows to remove a nil check on container config in `postContainersCreate`. Signed-off-by: Albin Kerouanton <albinker@gmail.com>
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
- Merge BC conds for API < v1.42 together - Merge BC conds for API < v1.44 together - Re-order BC conds by API version - Move pids-limit normalization after BC conds Signed-off-by: Albin Kerouanton <albinker@gmail.com>
6f1beb4
to
4f0cab3
Compare
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.
- What I did
In
postContainersCreate
:hostConfig
andnetworkingConfig
when they're nil ;config
is nil ;config
,hostConfig
andnetworkingConfig
;- How to verify it
CI is green.
- A picture of a cute animal (not mandatory but encouraged)