1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

ContainerStats: return early on unsupported API versions

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2019-07-10 21:47:50 +02:00
parent aa8249ae1b
commit 7d9126e149
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C

View file

@ -21,6 +21,10 @@ func (daemon *Daemon) ContainerStats(ctx context.Context, prefixOrName string, c
// Engine API version (used for backwards compatibility) // Engine API version (used for backwards compatibility)
apiVersion := config.Version apiVersion := config.Version
if runtime.GOOS == "windows" && versions.LessThan(apiVersion, "1.21") {
return errors.New("API versions pre v1.21 do not support stats on Windows")
}
container, err := daemon.GetContainer(prefixOrName) container, err := daemon.GetContainer(prefixOrName)
if err != nil { if err != nil {
return err return err
@ -70,9 +74,6 @@ func (daemon *Daemon) ContainerStats(ctx context.Context, prefixOrName string, c
var statsJSON interface{} var statsJSON interface{}
statsJSONPost120 := getStatJSON(v) statsJSONPost120 := getStatJSON(v)
if versions.LessThan(apiVersion, "1.21") { if versions.LessThan(apiVersion, "1.21") {
if runtime.GOOS == "windows" {
return errors.New("API versions pre v1.21 do not support stats on Windows")
}
var ( var (
rxBytes uint64 rxBytes uint64
rxPackets uint64 rxPackets uint64