Create a copy of stats value before modifications

Fixes #22030

Because the publisher uses this same value to all the
stats endpoints we need to make a copy of this as soon as we get it so
that we can make our modifications without it affecting others.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby 2016-04-18 11:12:07 -07:00
parent ac7e011ec9
commit d17ee4b506
2 changed files with 3 additions and 3 deletions

View File

@ -43,11 +43,11 @@ func (daemon *Daemon) ContainerStats(ctx context.Context, prefixOrName string, c
var preCPUStats types.CPUStats
getStatJSON := func(v interface{}) *types.StatsJSON {
ss := v.(*types.StatsJSON)
ss := v.(types.StatsJSON)
ss.PreCPUStats = preCPUStats
// ss.MemoryStats.Limit = uint64(update.MemoryLimit)
preCPUStats = ss.CPUStats
return ss
return &ss
}
enc := json.NewEncoder(outStream)

View File

@ -135,7 +135,7 @@ func (s *statsCollector) run() {
// FIXME: move to containerd
stats.CPUStats.SystemUsage = systemUsage
pair.publisher.Publish(stats)
pair.publisher.Publish(*stats)
}
}
}