Merge pull request #39488 from thaJeztah/stats_early_check

ContainerStats: return early on unsupported API versions
This commit is contained in:
Akihiro Suda 2019-07-14 13:30:34 +09:00 committed by GitHub
commit e6faa02697
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 3 deletions

View File

@ -21,6 +21,10 @@ func (daemon *Daemon) ContainerStats(ctx context.Context, prefixOrName string, c
// Engine API version (used for backwards compatibility)
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)
if err != nil {
return err
@ -70,9 +74,6 @@ func (daemon *Daemon) ContainerStats(ctx context.Context, prefixOrName string, c
var statsJSON interface{}
statsJSONPost120 := getStatJSON(v)
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 (
rxBytes uint64
rxPackets uint64