@@ -12,15 +12,15 @@ import (
1212
1313 statsV1 "github.com/containerd/cgroups/v3/cgroup1/stats"
1414 statsV2 "github.com/containerd/cgroups/v3/cgroup2/stats"
15- "github.com/docker/docker/api/types"
15+ containertypes "github.com/docker/docker/api/types/container "
1616 "github.com/docker/docker/container"
1717 "github.com/pkg/errors"
1818)
1919
20- func copyBlkioEntry (entries []* statsV1.BlkIOEntry ) []types .BlkioStatEntry {
21- out := make ([]types .BlkioStatEntry , len (entries ))
20+ func copyBlkioEntry (entries []* statsV1.BlkIOEntry ) []containertypes .BlkioStatEntry {
21+ out := make ([]containertypes .BlkioStatEntry , len (entries ))
2222 for i , re := range entries {
23- out [i ] = types .BlkioStatEntry {
23+ out [i ] = containertypes .BlkioStatEntry {
2424 Major : re .Major ,
2525 Minor : re .Minor ,
2626 Op : re .Op ,
@@ -30,7 +30,7 @@ func copyBlkioEntry(entries []*statsV1.BlkIOEntry) []types.BlkioStatEntry {
3030 return out
3131}
3232
33- func (daemon * Daemon ) stats (c * container.Container ) (* types. StatsJSON , error ) {
33+ func (daemon * Daemon ) stats (c * container.Container ) (* containertypes. StatsResponse , error ) {
3434 c .Lock ()
3535 task , err := c .GetRunningTask ()
3636 c .Unlock ()
@@ -44,7 +44,7 @@ func (daemon *Daemon) stats(c *container.Container) (*types.StatsJSON, error) {
4444 }
4545 return nil , err
4646 }
47- s := & types. StatsJSON {}
47+ s := & containertypes. StatsResponse {}
4848 s .Read = cs .Read
4949 stats := cs .Metrics
5050 switch t := stats .(type ) {
@@ -57,9 +57,9 @@ func (daemon *Daemon) stats(c *container.Container) (*types.StatsJSON, error) {
5757 }
5858}
5959
60- func (daemon * Daemon ) statsV1 (s * types. StatsJSON , stats * statsV1.Metrics ) (* types. StatsJSON , error ) {
60+ func (daemon * Daemon ) statsV1 (s * containertypes. StatsResponse , stats * statsV1.Metrics ) (* containertypes. StatsResponse , error ) {
6161 if stats .Blkio != nil {
62- s .BlkioStats = types .BlkioStats {
62+ s .BlkioStats = containertypes .BlkioStats {
6363 IoServiceBytesRecursive : copyBlkioEntry (stats .Blkio .IoServiceBytesRecursive ),
6464 IoServicedRecursive : copyBlkioEntry (stats .Blkio .IoServicedRecursive ),
6565 IoQueuedRecursive : copyBlkioEntry (stats .Blkio .IoQueuedRecursive ),
@@ -71,14 +71,14 @@ func (daemon *Daemon) statsV1(s *types.StatsJSON, stats *statsV1.Metrics) (*type
7171 }
7272 }
7373 if stats .CPU != nil {
74- s .CPUStats = types .CPUStats {
75- CPUUsage : types .CPUUsage {
74+ s .CPUStats = containertypes .CPUStats {
75+ CPUUsage : containertypes .CPUUsage {
7676 TotalUsage : stats .CPU .Usage .Total ,
7777 PercpuUsage : stats .CPU .Usage .PerCPU ,
7878 UsageInKernelmode : stats .CPU .Usage .Kernel ,
7979 UsageInUsermode : stats .CPU .Usage .User ,
8080 },
81- ThrottlingData : types .ThrottlingData {
81+ ThrottlingData : containertypes .ThrottlingData {
8282 Periods : stats .CPU .Throttling .Periods ,
8383 ThrottledPeriods : stats .CPU .Throttling .ThrottledPeriods ,
8484 ThrottledTime : stats .CPU .Throttling .ThrottledTime ,
@@ -122,15 +122,15 @@ func (daemon *Daemon) statsV1(s *types.StatsJSON, stats *statsV1.Metrics) (*type
122122 "total_unevictable" : stats .Memory .TotalUnevictable ,
123123 }
124124 if stats .Memory .Usage != nil {
125- s .MemoryStats = types .MemoryStats {
125+ s .MemoryStats = containertypes .MemoryStats {
126126 Stats : raw ,
127127 Usage : stats .Memory .Usage .Usage ,
128128 MaxUsage : stats .Memory .Usage .Max ,
129129 Limit : stats .Memory .Usage .Limit ,
130130 Failcnt : stats .Memory .Usage .Failcnt ,
131131 }
132132 } else {
133- s .MemoryStats = types .MemoryStats {
133+ s .MemoryStats = containertypes .MemoryStats {
134134 Stats : raw ,
135135 }
136136 }
@@ -142,7 +142,7 @@ func (daemon *Daemon) statsV1(s *types.StatsJSON, stats *statsV1.Metrics) (*type
142142 }
143143
144144 if stats .Pids != nil {
145- s .PidsStats = types .PidsStats {
145+ s .PidsStats = containertypes .PidsStats {
146146 Current : stats .Pids .Current ,
147147 Limit : stats .Pids .Limit ,
148148 }
@@ -151,40 +151,40 @@ func (daemon *Daemon) statsV1(s *types.StatsJSON, stats *statsV1.Metrics) (*type
151151 return s , nil
152152}
153153
154- func (daemon * Daemon ) statsV2 (s * types. StatsJSON , stats * statsV2.Metrics ) (* types. StatsJSON , error ) {
154+ func (daemon * Daemon ) statsV2 (s * containertypes. StatsResponse , stats * statsV2.Metrics ) (* containertypes. StatsResponse , error ) {
155155 if stats .Io != nil {
156- var isbr []types .BlkioStatEntry
156+ var isbr []containertypes .BlkioStatEntry
157157 for _ , re := range stats .Io .Usage {
158158 isbr = append (isbr ,
159- types .BlkioStatEntry {
159+ containertypes .BlkioStatEntry {
160160 Major : re .Major ,
161161 Minor : re .Minor ,
162162 Op : "read" ,
163163 Value : re .Rbytes ,
164164 },
165- types .BlkioStatEntry {
165+ containertypes .BlkioStatEntry {
166166 Major : re .Major ,
167167 Minor : re .Minor ,
168168 Op : "write" ,
169169 Value : re .Wbytes ,
170170 },
171171 )
172172 }
173- s .BlkioStats = types .BlkioStats {
173+ s .BlkioStats = containertypes .BlkioStats {
174174 IoServiceBytesRecursive : isbr ,
175175 // Other fields are unsupported
176176 }
177177 }
178178
179179 if stats .CPU != nil {
180- s .CPUStats = types .CPUStats {
181- CPUUsage : types .CPUUsage {
180+ s .CPUStats = containertypes .CPUStats {
181+ CPUUsage : containertypes .CPUUsage {
182182 TotalUsage : stats .CPU .UsageUsec * 1000 ,
183183 // PercpuUsage is not supported
184184 UsageInKernelmode : stats .CPU .SystemUsec * 1000 ,
185185 UsageInUsermode : stats .CPU .UserUsec * 1000 ,
186186 },
187- ThrottlingData : types .ThrottlingData {
187+ ThrottlingData : containertypes .ThrottlingData {
188188 Periods : stats .CPU .NrPeriods ,
189189 ThrottledPeriods : stats .CPU .NrThrottled ,
190190 ThrottledTime : stats .CPU .ThrottledUsec * 1000 ,
@@ -193,7 +193,7 @@ func (daemon *Daemon) statsV2(s *types.StatsJSON, stats *statsV2.Metrics) (*type
193193 }
194194
195195 if stats .Memory != nil {
196- s .MemoryStats = types .MemoryStats {
196+ s .MemoryStats = containertypes .MemoryStats {
197197 // Stats is not compatible with v1
198198 Stats : map [string ]uint64 {
199199 "anon" : stats .Memory .Anon ,
@@ -244,7 +244,7 @@ func (daemon *Daemon) statsV2(s *types.StatsJSON, stats *statsV2.Metrics) (*type
244244 }
245245
246246 if stats .Pids != nil {
247- s .PidsStats = types .PidsStats {
247+ s .PidsStats = containertypes .PidsStats {
248248 Current : stats .Pids .Current ,
249249 Limit : stats .Pids .Limit ,
250250 }
@@ -267,7 +267,7 @@ func (daemon *Daemon) getNetworkSandboxID(c *container.Container) (string, error
267267 return curr .NetworkSettings .SandboxID , nil
268268}
269269
270- func (daemon * Daemon ) getNetworkStats (c * container.Container ) (map [string ]types .NetworkStats , error ) {
270+ func (daemon * Daemon ) getNetworkStats (c * container.Container ) (map [string ]containertypes .NetworkStats , error ) {
271271 sandboxID , err := daemon .getNetworkSandboxID (c )
272272 if err != nil {
273273 return nil , err
@@ -283,10 +283,10 @@ func (daemon *Daemon) getNetworkStats(c *container.Container) (map[string]types.
283283 return nil , err
284284 }
285285
286- stats := make (map [string ]types .NetworkStats )
286+ stats := make (map [string ]containertypes .NetworkStats )
287287 // Convert libnetwork nw stats into api stats
288288 for ifName , ifStats := range lnstats {
289- stats [ifName ] = types .NetworkStats {
289+ stats [ifName ] = containertypes .NetworkStats {
290290 RxBytes : ifStats .RxBytes ,
291291 RxPackets : ifStats .RxPackets ,
292292 RxErrors : ifStats .RxErrors ,
0 commit comments