Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -37,7 +37,7 @@ type CopyToContainerOptions struct {
|
| 37 | 37 |
// The OSType field is set to the server's platform to allow |
| 38 | 38 |
// platform-specific handling of the response. |
| 39 | 39 |
// |
| 40 |
-// TODO(thaJeztah): remove this wrapper, and make OSType part of [StatsJSON]. |
|
| 40 |
+// TODO(thaJeztah): remove this wrapper, and make OSType part of [StatsResponse]. |
|
| 41 | 41 |
type StatsResponseReader struct {
|
| 42 | 42 |
Body io.ReadCloser `json:"body"` |
| 43 | 43 |
OSType string `json:"ostype"` |
| 44 | 44 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,181 @@ |
| 0 |
+package container |
|
| 1 |
+ |
|
| 2 |
+import "time" |
|
| 3 |
+ |
|
| 4 |
+// ThrottlingData stores CPU throttling stats of one running container. |
|
| 5 |
+// Not used on Windows. |
|
| 6 |
+type ThrottlingData struct {
|
|
| 7 |
+ // Number of periods with throttling active |
|
| 8 |
+ Periods uint64 `json:"periods"` |
|
| 9 |
+ // Number of periods when the container hits its throttling limit. |
|
| 10 |
+ ThrottledPeriods uint64 `json:"throttled_periods"` |
|
| 11 |
+ // Aggregate time the container was throttled for in nanoseconds. |
|
| 12 |
+ ThrottledTime uint64 `json:"throttled_time"` |
|
| 13 |
+} |
|
| 14 |
+ |
|
| 15 |
+// CPUUsage stores All CPU stats aggregated since container inception. |
|
| 16 |
+type CPUUsage struct {
|
|
| 17 |
+ // Total CPU time consumed. |
|
| 18 |
+ // Units: nanoseconds (Linux) |
|
| 19 |
+ // Units: 100's of nanoseconds (Windows) |
|
| 20 |
+ TotalUsage uint64 `json:"total_usage"` |
|
| 21 |
+ |
|
| 22 |
+ // Total CPU time consumed per core (Linux). Not used on Windows. |
|
| 23 |
+ // Units: nanoseconds. |
|
| 24 |
+ PercpuUsage []uint64 `json:"percpu_usage,omitempty"` |
|
| 25 |
+ |
|
| 26 |
+ // Time spent by tasks of the cgroup in kernel mode (Linux). |
|
| 27 |
+ // Time spent by all container processes in kernel mode (Windows). |
|
| 28 |
+ // Units: nanoseconds (Linux). |
|
| 29 |
+ // Units: 100's of nanoseconds (Windows). Not populated for Hyper-V Containers. |
|
| 30 |
+ UsageInKernelmode uint64 `json:"usage_in_kernelmode"` |
|
| 31 |
+ |
|
| 32 |
+ // Time spent by tasks of the cgroup in user mode (Linux). |
|
| 33 |
+ // Time spent by all container processes in user mode (Windows). |
|
| 34 |
+ // Units: nanoseconds (Linux). |
|
| 35 |
+ // Units: 100's of nanoseconds (Windows). Not populated for Hyper-V Containers |
|
| 36 |
+ UsageInUsermode uint64 `json:"usage_in_usermode"` |
|
| 37 |
+} |
|
| 38 |
+ |
|
| 39 |
+// CPUStats aggregates and wraps all CPU related info of container |
|
| 40 |
+type CPUStats struct {
|
|
| 41 |
+ // CPU Usage. Linux and Windows. |
|
| 42 |
+ CPUUsage CPUUsage `json:"cpu_usage"` |
|
| 43 |
+ |
|
| 44 |
+ // System Usage. Linux only. |
|
| 45 |
+ SystemUsage uint64 `json:"system_cpu_usage,omitempty"` |
|
| 46 |
+ |
|
| 47 |
+ // Online CPUs. Linux only. |
|
| 48 |
+ OnlineCPUs uint32 `json:"online_cpus,omitempty"` |
|
| 49 |
+ |
|
| 50 |
+ // Throttling Data. Linux only. |
|
| 51 |
+ ThrottlingData ThrottlingData `json:"throttling_data,omitempty"` |
|
| 52 |
+} |
|
| 53 |
+ |
|
| 54 |
+// MemoryStats aggregates all memory stats since container inception on Linux. |
|
| 55 |
+// Windows returns stats for commit and private working set only. |
|
| 56 |
+type MemoryStats struct {
|
|
| 57 |
+ // Linux Memory Stats |
|
| 58 |
+ |
|
| 59 |
+ // current res_counter usage for memory |
|
| 60 |
+ Usage uint64 `json:"usage,omitempty"` |
|
| 61 |
+ // maximum usage ever recorded. |
|
| 62 |
+ MaxUsage uint64 `json:"max_usage,omitempty"` |
|
| 63 |
+ // TODO(vishh): Export these as stronger types. |
|
| 64 |
+ // all the stats exported via memory.stat. |
|
| 65 |
+ Stats map[string]uint64 `json:"stats,omitempty"` |
|
| 66 |
+ // number of times memory usage hits limits. |
|
| 67 |
+ Failcnt uint64 `json:"failcnt,omitempty"` |
|
| 68 |
+ Limit uint64 `json:"limit,omitempty"` |
|
| 69 |
+ |
|
| 70 |
+ // Windows Memory Stats |
|
| 71 |
+ // See https://technet.microsoft.com/en-us/magazine/ff382715.aspx |
|
| 72 |
+ |
|
| 73 |
+ // committed bytes |
|
| 74 |
+ Commit uint64 `json:"commitbytes,omitempty"` |
|
| 75 |
+ // peak committed bytes |
|
| 76 |
+ CommitPeak uint64 `json:"commitpeakbytes,omitempty"` |
|
| 77 |
+ // private working set |
|
| 78 |
+ PrivateWorkingSet uint64 `json:"privateworkingset,omitempty"` |
|
| 79 |
+} |
|
| 80 |
+ |
|
| 81 |
+// BlkioStatEntry is one small entity to store a piece of Blkio stats |
|
| 82 |
+// Not used on Windows. |
|
| 83 |
+type BlkioStatEntry struct {
|
|
| 84 |
+ Major uint64 `json:"major"` |
|
| 85 |
+ Minor uint64 `json:"minor"` |
|
| 86 |
+ Op string `json:"op"` |
|
| 87 |
+ Value uint64 `json:"value"` |
|
| 88 |
+} |
|
| 89 |
+ |
|
| 90 |
+// BlkioStats stores All IO service stats for data read and write. |
|
| 91 |
+// This is a Linux specific structure as the differences between expressing |
|
| 92 |
+// block I/O on Windows and Linux are sufficiently significant to make |
|
| 93 |
+// little sense attempting to morph into a combined structure. |
|
| 94 |
+type BlkioStats struct {
|
|
| 95 |
+ // number of bytes transferred to and from the block device |
|
| 96 |
+ IoServiceBytesRecursive []BlkioStatEntry `json:"io_service_bytes_recursive"` |
|
| 97 |
+ IoServicedRecursive []BlkioStatEntry `json:"io_serviced_recursive"` |
|
| 98 |
+ IoQueuedRecursive []BlkioStatEntry `json:"io_queue_recursive"` |
|
| 99 |
+ IoServiceTimeRecursive []BlkioStatEntry `json:"io_service_time_recursive"` |
|
| 100 |
+ IoWaitTimeRecursive []BlkioStatEntry `json:"io_wait_time_recursive"` |
|
| 101 |
+ IoMergedRecursive []BlkioStatEntry `json:"io_merged_recursive"` |
|
| 102 |
+ IoTimeRecursive []BlkioStatEntry `json:"io_time_recursive"` |
|
| 103 |
+ SectorsRecursive []BlkioStatEntry `json:"sectors_recursive"` |
|
| 104 |
+} |
|
| 105 |
+ |
|
| 106 |
+// StorageStats is the disk I/O stats for read/write on Windows. |
|
| 107 |
+type StorageStats struct {
|
|
| 108 |
+ ReadCountNormalized uint64 `json:"read_count_normalized,omitempty"` |
|
| 109 |
+ ReadSizeBytes uint64 `json:"read_size_bytes,omitempty"` |
|
| 110 |
+ WriteCountNormalized uint64 `json:"write_count_normalized,omitempty"` |
|
| 111 |
+ WriteSizeBytes uint64 `json:"write_size_bytes,omitempty"` |
|
| 112 |
+} |
|
| 113 |
+ |
|
| 114 |
+// NetworkStats aggregates the network stats of one container |
|
| 115 |
+type NetworkStats struct {
|
|
| 116 |
+ // Bytes received. Windows and Linux. |
|
| 117 |
+ RxBytes uint64 `json:"rx_bytes"` |
|
| 118 |
+ // Packets received. Windows and Linux. |
|
| 119 |
+ RxPackets uint64 `json:"rx_packets"` |
|
| 120 |
+ // Received errors. Not used on Windows. Note that we don't `omitempty` this |
|
| 121 |
+ // field as it is expected in the >=v1.21 API stats structure. |
|
| 122 |
+ RxErrors uint64 `json:"rx_errors"` |
|
| 123 |
+ // Incoming packets dropped. Windows and Linux. |
|
| 124 |
+ RxDropped uint64 `json:"rx_dropped"` |
|
| 125 |
+ // Bytes sent. Windows and Linux. |
|
| 126 |
+ TxBytes uint64 `json:"tx_bytes"` |
|
| 127 |
+ // Packets sent. Windows and Linux. |
|
| 128 |
+ TxPackets uint64 `json:"tx_packets"` |
|
| 129 |
+ // Sent errors. Not used on Windows. Note that we don't `omitempty` this |
|
| 130 |
+ // field as it is expected in the >=v1.21 API stats structure. |
|
| 131 |
+ TxErrors uint64 `json:"tx_errors"` |
|
| 132 |
+ // Outgoing packets dropped. Windows and Linux. |
|
| 133 |
+ TxDropped uint64 `json:"tx_dropped"` |
|
| 134 |
+ // Endpoint ID. Not used on Linux. |
|
| 135 |
+ EndpointID string `json:"endpoint_id,omitempty"` |
|
| 136 |
+ // Instance ID. Not used on Linux. |
|
| 137 |
+ InstanceID string `json:"instance_id,omitempty"` |
|
| 138 |
+} |
|
| 139 |
+ |
|
| 140 |
+// PidsStats contains the stats of a container's pids |
|
| 141 |
+type PidsStats struct {
|
|
| 142 |
+ // Current is the number of pids in the cgroup |
|
| 143 |
+ Current uint64 `json:"current,omitempty"` |
|
| 144 |
+ // Limit is the hard limit on the number of pids in the cgroup. |
|
| 145 |
+ // A "Limit" of 0 means that there is no limit. |
|
| 146 |
+ Limit uint64 `json:"limit,omitempty"` |
|
| 147 |
+} |
|
| 148 |
+ |
|
| 149 |
+// Stats is Ultimate struct aggregating all types of stats of one container |
|
| 150 |
+type Stats struct {
|
|
| 151 |
+ // Common stats |
|
| 152 |
+ Read time.Time `json:"read"` |
|
| 153 |
+ PreRead time.Time `json:"preread"` |
|
| 154 |
+ |
|
| 155 |
+ // Linux specific stats, not populated on Windows. |
|
| 156 |
+ PidsStats PidsStats `json:"pids_stats,omitempty"` |
|
| 157 |
+ BlkioStats BlkioStats `json:"blkio_stats,omitempty"` |
|
| 158 |
+ |
|
| 159 |
+ // Windows specific stats, not populated on Linux. |
|
| 160 |
+ NumProcs uint32 `json:"num_procs"` |
|
| 161 |
+ StorageStats StorageStats `json:"storage_stats,omitempty"` |
|
| 162 |
+ |
|
| 163 |
+ // Shared stats |
|
| 164 |
+ CPUStats CPUStats `json:"cpu_stats,omitempty"` |
|
| 165 |
+ PreCPUStats CPUStats `json:"precpu_stats,omitempty"` // "Pre"="Previous" |
|
| 166 |
+ MemoryStats MemoryStats `json:"memory_stats,omitempty"` |
|
| 167 |
+} |
|
| 168 |
+ |
|
| 169 |
+// StatsResponse is newly used Networks. |
|
| 170 |
+// |
|
| 171 |
+// TODO(thaJeztah): unify with [Stats]. This wrapper was to account for pre-api v1.21 changes, see https://github.com/moby/moby/commit/d3379946ec96fb6163cb8c4517d7d5a067045801 |
|
| 172 |
+type StatsResponse struct {
|
|
| 173 |
+ Stats |
|
| 174 |
+ |
|
| 175 |
+ Name string `json:"name,omitempty"` |
|
| 176 |
+ ID string `json:"id,omitempty"` |
|
| 177 |
+ |
|
| 178 |
+ // Networks request version >=1.21 |
|
| 179 |
+ Networks map[string]NetworkStats `json:"networks,omitempty"` |
|
| 180 |
+} |
| 0 | 181 |
deleted file mode 100644 |
| ... | ... |
@@ -1,181 +0,0 @@ |
| 1 |
-// Package types is used for API stability in the types and response to the |
|
| 2 |
-// consumers of the API stats endpoint. |
|
| 3 |
-package types // import "github.com/docker/docker/api/types" |
|
| 4 |
- |
|
| 5 |
-import "time" |
|
| 6 |
- |
|
| 7 |
-// ThrottlingData stores CPU throttling stats of one running container. |
|
| 8 |
-// Not used on Windows. |
|
| 9 |
-type ThrottlingData struct {
|
|
| 10 |
- // Number of periods with throttling active |
|
| 11 |
- Periods uint64 `json:"periods"` |
|
| 12 |
- // Number of periods when the container hits its throttling limit. |
|
| 13 |
- ThrottledPeriods uint64 `json:"throttled_periods"` |
|
| 14 |
- // Aggregate time the container was throttled for in nanoseconds. |
|
| 15 |
- ThrottledTime uint64 `json:"throttled_time"` |
|
| 16 |
-} |
|
| 17 |
- |
|
| 18 |
-// CPUUsage stores All CPU stats aggregated since container inception. |
|
| 19 |
-type CPUUsage struct {
|
|
| 20 |
- // Total CPU time consumed. |
|
| 21 |
- // Units: nanoseconds (Linux) |
|
| 22 |
- // Units: 100's of nanoseconds (Windows) |
|
| 23 |
- TotalUsage uint64 `json:"total_usage"` |
|
| 24 |
- |
|
| 25 |
- // Total CPU time consumed per core (Linux). Not used on Windows. |
|
| 26 |
- // Units: nanoseconds. |
|
| 27 |
- PercpuUsage []uint64 `json:"percpu_usage,omitempty"` |
|
| 28 |
- |
|
| 29 |
- // Time spent by tasks of the cgroup in kernel mode (Linux). |
|
| 30 |
- // Time spent by all container processes in kernel mode (Windows). |
|
| 31 |
- // Units: nanoseconds (Linux). |
|
| 32 |
- // Units: 100's of nanoseconds (Windows). Not populated for Hyper-V Containers. |
|
| 33 |
- UsageInKernelmode uint64 `json:"usage_in_kernelmode"` |
|
| 34 |
- |
|
| 35 |
- // Time spent by tasks of the cgroup in user mode (Linux). |
|
| 36 |
- // Time spent by all container processes in user mode (Windows). |
|
| 37 |
- // Units: nanoseconds (Linux). |
|
| 38 |
- // Units: 100's of nanoseconds (Windows). Not populated for Hyper-V Containers |
|
| 39 |
- UsageInUsermode uint64 `json:"usage_in_usermode"` |
|
| 40 |
-} |
|
| 41 |
- |
|
| 42 |
-// CPUStats aggregates and wraps all CPU related info of container |
|
| 43 |
-type CPUStats struct {
|
|
| 44 |
- // CPU Usage. Linux and Windows. |
|
| 45 |
- CPUUsage CPUUsage `json:"cpu_usage"` |
|
| 46 |
- |
|
| 47 |
- // System Usage. Linux only. |
|
| 48 |
- SystemUsage uint64 `json:"system_cpu_usage,omitempty"` |
|
| 49 |
- |
|
| 50 |
- // Online CPUs. Linux only. |
|
| 51 |
- OnlineCPUs uint32 `json:"online_cpus,omitempty"` |
|
| 52 |
- |
|
| 53 |
- // Throttling Data. Linux only. |
|
| 54 |
- ThrottlingData ThrottlingData `json:"throttling_data,omitempty"` |
|
| 55 |
-} |
|
| 56 |
- |
|
| 57 |
-// MemoryStats aggregates all memory stats since container inception on Linux. |
|
| 58 |
-// Windows returns stats for commit and private working set only. |
|
| 59 |
-type MemoryStats struct {
|
|
| 60 |
- // Linux Memory Stats |
|
| 61 |
- |
|
| 62 |
- // current res_counter usage for memory |
|
| 63 |
- Usage uint64 `json:"usage,omitempty"` |
|
| 64 |
- // maximum usage ever recorded. |
|
| 65 |
- MaxUsage uint64 `json:"max_usage,omitempty"` |
|
| 66 |
- // TODO(vishh): Export these as stronger types. |
|
| 67 |
- // all the stats exported via memory.stat. |
|
| 68 |
- Stats map[string]uint64 `json:"stats,omitempty"` |
|
| 69 |
- // number of times memory usage hits limits. |
|
| 70 |
- Failcnt uint64 `json:"failcnt,omitempty"` |
|
| 71 |
- Limit uint64 `json:"limit,omitempty"` |
|
| 72 |
- |
|
| 73 |
- // Windows Memory Stats |
|
| 74 |
- // See https://technet.microsoft.com/en-us/magazine/ff382715.aspx |
|
| 75 |
- |
|
| 76 |
- // committed bytes |
|
| 77 |
- Commit uint64 `json:"commitbytes,omitempty"` |
|
| 78 |
- // peak committed bytes |
|
| 79 |
- CommitPeak uint64 `json:"commitpeakbytes,omitempty"` |
|
| 80 |
- // private working set |
|
| 81 |
- PrivateWorkingSet uint64 `json:"privateworkingset,omitempty"` |
|
| 82 |
-} |
|
| 83 |
- |
|
| 84 |
-// BlkioStatEntry is one small entity to store a piece of Blkio stats |
|
| 85 |
-// Not used on Windows. |
|
| 86 |
-type BlkioStatEntry struct {
|
|
| 87 |
- Major uint64 `json:"major"` |
|
| 88 |
- Minor uint64 `json:"minor"` |
|
| 89 |
- Op string `json:"op"` |
|
| 90 |
- Value uint64 `json:"value"` |
|
| 91 |
-} |
|
| 92 |
- |
|
| 93 |
-// BlkioStats stores All IO service stats for data read and write. |
|
| 94 |
-// This is a Linux specific structure as the differences between expressing |
|
| 95 |
-// block I/O on Windows and Linux are sufficiently significant to make |
|
| 96 |
-// little sense attempting to morph into a combined structure. |
|
| 97 |
-type BlkioStats struct {
|
|
| 98 |
- // number of bytes transferred to and from the block device |
|
| 99 |
- IoServiceBytesRecursive []BlkioStatEntry `json:"io_service_bytes_recursive"` |
|
| 100 |
- IoServicedRecursive []BlkioStatEntry `json:"io_serviced_recursive"` |
|
| 101 |
- IoQueuedRecursive []BlkioStatEntry `json:"io_queue_recursive"` |
|
| 102 |
- IoServiceTimeRecursive []BlkioStatEntry `json:"io_service_time_recursive"` |
|
| 103 |
- IoWaitTimeRecursive []BlkioStatEntry `json:"io_wait_time_recursive"` |
|
| 104 |
- IoMergedRecursive []BlkioStatEntry `json:"io_merged_recursive"` |
|
| 105 |
- IoTimeRecursive []BlkioStatEntry `json:"io_time_recursive"` |
|
| 106 |
- SectorsRecursive []BlkioStatEntry `json:"sectors_recursive"` |
|
| 107 |
-} |
|
| 108 |
- |
|
| 109 |
-// StorageStats is the disk I/O stats for read/write on Windows. |
|
| 110 |
-type StorageStats struct {
|
|
| 111 |
- ReadCountNormalized uint64 `json:"read_count_normalized,omitempty"` |
|
| 112 |
- ReadSizeBytes uint64 `json:"read_size_bytes,omitempty"` |
|
| 113 |
- WriteCountNormalized uint64 `json:"write_count_normalized,omitempty"` |
|
| 114 |
- WriteSizeBytes uint64 `json:"write_size_bytes,omitempty"` |
|
| 115 |
-} |
|
| 116 |
- |
|
| 117 |
-// NetworkStats aggregates the network stats of one container |
|
| 118 |
-type NetworkStats struct {
|
|
| 119 |
- // Bytes received. Windows and Linux. |
|
| 120 |
- RxBytes uint64 `json:"rx_bytes"` |
|
| 121 |
- // Packets received. Windows and Linux. |
|
| 122 |
- RxPackets uint64 `json:"rx_packets"` |
|
| 123 |
- // Received errors. Not used on Windows. Note that we don't `omitempty` this |
|
| 124 |
- // field as it is expected in the >=v1.21 API stats structure. |
|
| 125 |
- RxErrors uint64 `json:"rx_errors"` |
|
| 126 |
- // Incoming packets dropped. Windows and Linux. |
|
| 127 |
- RxDropped uint64 `json:"rx_dropped"` |
|
| 128 |
- // Bytes sent. Windows and Linux. |
|
| 129 |
- TxBytes uint64 `json:"tx_bytes"` |
|
| 130 |
- // Packets sent. Windows and Linux. |
|
| 131 |
- TxPackets uint64 `json:"tx_packets"` |
|
| 132 |
- // Sent errors. Not used on Windows. Note that we don't `omitempty` this |
|
| 133 |
- // field as it is expected in the >=v1.21 API stats structure. |
|
| 134 |
- TxErrors uint64 `json:"tx_errors"` |
|
| 135 |
- // Outgoing packets dropped. Windows and Linux. |
|
| 136 |
- TxDropped uint64 `json:"tx_dropped"` |
|
| 137 |
- // Endpoint ID. Not used on Linux. |
|
| 138 |
- EndpointID string `json:"endpoint_id,omitempty"` |
|
| 139 |
- // Instance ID. Not used on Linux. |
|
| 140 |
- InstanceID string `json:"instance_id,omitempty"` |
|
| 141 |
-} |
|
| 142 |
- |
|
| 143 |
-// PidsStats contains the stats of a container's pids |
|
| 144 |
-type PidsStats struct {
|
|
| 145 |
- // Current is the number of pids in the cgroup |
|
| 146 |
- Current uint64 `json:"current,omitempty"` |
|
| 147 |
- // Limit is the hard limit on the number of pids in the cgroup. |
|
| 148 |
- // A "Limit" of 0 means that there is no limit. |
|
| 149 |
- Limit uint64 `json:"limit,omitempty"` |
|
| 150 |
-} |
|
| 151 |
- |
|
| 152 |
-// Stats is Ultimate struct aggregating all types of stats of one container |
|
| 153 |
-type Stats struct {
|
|
| 154 |
- // Common stats |
|
| 155 |
- Read time.Time `json:"read"` |
|
| 156 |
- PreRead time.Time `json:"preread"` |
|
| 157 |
- |
|
| 158 |
- // Linux specific stats, not populated on Windows. |
|
| 159 |
- PidsStats PidsStats `json:"pids_stats,omitempty"` |
|
| 160 |
- BlkioStats BlkioStats `json:"blkio_stats,omitempty"` |
|
| 161 |
- |
|
| 162 |
- // Windows specific stats, not populated on Linux. |
|
| 163 |
- NumProcs uint32 `json:"num_procs"` |
|
| 164 |
- StorageStats StorageStats `json:"storage_stats,omitempty"` |
|
| 165 |
- |
|
| 166 |
- // Shared stats |
|
| 167 |
- CPUStats CPUStats `json:"cpu_stats,omitempty"` |
|
| 168 |
- PreCPUStats CPUStats `json:"precpu_stats,omitempty"` // "Pre"="Previous" |
|
| 169 |
- MemoryStats MemoryStats `json:"memory_stats,omitempty"` |
|
| 170 |
-} |
|
| 171 |
- |
|
| 172 |
-// StatsJSON is newly used Networks |
|
| 173 |
-type StatsJSON struct {
|
|
| 174 |
- Stats |
|
| 175 |
- |
|
| 176 |
- Name string `json:"name,omitempty"` |
|
| 177 |
- ID string `json:"id,omitempty"` |
|
| 178 |
- |
|
| 179 |
- // Networks request version >=1.21 |
|
| 180 |
- Networks map[string]NetworkStats `json:"networks,omitempty"` |
|
| 181 |
-} |
| ... | ... |
@@ -114,6 +114,67 @@ type CopyToContainerOptions = container.CopyToContainerOptions |
| 114 | 114 |
// Deprecated: use [container.StatsResponseReader]. |
| 115 | 115 |
type ContainerStats = container.StatsResponseReader |
| 116 | 116 |
|
| 117 |
+// ThrottlingData stores CPU throttling stats of one running container. |
|
| 118 |
+// Not used on Windows. |
|
| 119 |
+// |
|
| 120 |
+// Deprecated: use [container.ThrottlingData]. |
|
| 121 |
+type ThrottlingData = container.ThrottlingData |
|
| 122 |
+ |
|
| 123 |
+// CPUUsage stores All CPU stats aggregated since container inception. |
|
| 124 |
+// |
|
| 125 |
+// Deprecated: use [container.CPUUsage]. |
|
| 126 |
+type CPUUsage = container.CPUUsage |
|
| 127 |
+ |
|
| 128 |
+// CPUStats aggregates and wraps all CPU related info of container |
|
| 129 |
+// |
|
| 130 |
+// Deprecated: use [container.CPUStats]. |
|
| 131 |
+type CPUStats = container.CPUStats |
|
| 132 |
+ |
|
| 133 |
+// MemoryStats aggregates all memory stats since container inception on Linux. |
|
| 134 |
+// Windows returns stats for commit and private working set only. |
|
| 135 |
+// |
|
| 136 |
+// Deprecated: use [container.MemoryStats]. |
|
| 137 |
+type MemoryStats = container.MemoryStats |
|
| 138 |
+ |
|
| 139 |
+// BlkioStatEntry is one small entity to store a piece of Blkio stats |
|
| 140 |
+// Not used on Windows. |
|
| 141 |
+// |
|
| 142 |
+// Deprecated: use [container.BlkioStatEntry]. |
|
| 143 |
+type BlkioStatEntry = container.BlkioStatEntry |
|
| 144 |
+ |
|
| 145 |
+// BlkioStats stores All IO service stats for data read and write. |
|
| 146 |
+// This is a Linux specific structure as the differences between expressing |
|
| 147 |
+// block I/O on Windows and Linux are sufficiently significant to make |
|
| 148 |
+// little sense attempting to morph into a combined structure. |
|
| 149 |
+// |
|
| 150 |
+// Deprecated: use [container.BlkioStats]. |
|
| 151 |
+type BlkioStats = container.BlkioStats |
|
| 152 |
+ |
|
| 153 |
+// StorageStats is the disk I/O stats for read/write on Windows. |
|
| 154 |
+// |
|
| 155 |
+// Deprecated: use [container.StorageStats]. |
|
| 156 |
+type StorageStats = container.StorageStats |
|
| 157 |
+ |
|
| 158 |
+// NetworkStats aggregates the network stats of one container |
|
| 159 |
+// |
|
| 160 |
+// Deprecated: use [container.NetworkStats]. |
|
| 161 |
+type NetworkStats = container.NetworkStats |
|
| 162 |
+ |
|
| 163 |
+// PidsStats contains the stats of a container's pids |
|
| 164 |
+// |
|
| 165 |
+// Deprecated: use [container.PidsStats]. |
|
| 166 |
+type PidsStats = container.PidsStats |
|
| 167 |
+ |
|
| 168 |
+// Stats is Ultimate struct aggregating all types of stats of one container |
|
| 169 |
+// |
|
| 170 |
+// Deprecated: use [container.Stats]. |
|
| 171 |
+type Stats = container.Stats |
|
| 172 |
+ |
|
| 173 |
+// StatsJSON is newly used Networks |
|
| 174 |
+// |
|
| 175 |
+// Deprecated: use [container.StatsResponse]. |
|
| 176 |
+type StatsJSON = container.StatsResponse |
|
| 177 |
+ |
|
| 117 | 178 |
// EventsOptions holds parameters to filter events with. |
| 118 | 179 |
// |
| 119 | 180 |
// Deprecated: use [events.ListOptions]. |
| ... | ... |
@@ -8,8 +8,8 @@ import ( |
| 8 | 8 |
"time" |
| 9 | 9 |
|
| 10 | 10 |
"github.com/containerd/log" |
| 11 |
- "github.com/docker/docker/api/types" |
|
| 12 | 11 |
"github.com/docker/docker/api/types/backend" |
| 12 |
+ containertypes "github.com/docker/docker/api/types/container" |
|
| 13 | 13 |
"github.com/docker/docker/container" |
| 14 | 14 |
"github.com/docker/docker/errdefs" |
| 15 | 15 |
) |
| ... | ... |
@@ -30,7 +30,7 @@ func (daemon *Daemon) ContainerStats(ctx context.Context, prefixOrName string, c |
| 30 | 30 |
|
| 31 | 31 |
// If the container is either not running or restarting and requires no stream, return an empty stats. |
| 32 | 32 |
if (!ctr.IsRunning() || ctr.IsRestarting()) && !config.Stream {
|
| 33 |
- return enc.Encode(&types.StatsJSON{
|
|
| 33 |
+ return enc.Encode(&containertypes.StatsResponse{
|
|
| 34 | 34 |
Name: ctr.Name, |
| 35 | 35 |
ID: ctr.ID, |
| 36 | 36 |
}) |
| ... | ... |
@@ -45,10 +45,10 @@ func (daemon *Daemon) ContainerStats(ctx context.Context, prefixOrName string, c |
| 45 | 45 |
return enc.Encode(stats) |
| 46 | 46 |
} |
| 47 | 47 |
|
| 48 |
- var preCPUStats types.CPUStats |
|
| 48 |
+ var preCPUStats containertypes.CPUStats |
|
| 49 | 49 |
var preRead time.Time |
| 50 |
- getStatJSON := func(v interface{}) *types.StatsJSON {
|
|
| 51 |
- ss := v.(types.StatsJSON) |
|
| 50 |
+ getStatJSON := func(v interface{}) *containertypes.StatsResponse {
|
|
| 51 |
+ ss := v.(containertypes.StatsResponse) |
|
| 52 | 52 |
ss.Name = ctr.Name |
| 53 | 53 |
ss.ID = ctr.ID |
| 54 | 54 |
ss.PreCPUStats = preCPUStats |
| ... | ... |
@@ -99,7 +99,7 @@ func (daemon *Daemon) unsubscribeToContainerStats(c *container.Container, ch cha |
| 99 | 99 |
} |
| 100 | 100 |
|
| 101 | 101 |
// GetContainerStats collects all the stats published by a container |
| 102 |
-func (daemon *Daemon) GetContainerStats(container *container.Container) (*types.StatsJSON, error) {
|
|
| 102 |
+func (daemon *Daemon) GetContainerStats(container *container.Container) (*containertypes.StatsResponse, error) {
|
|
| 103 | 103 |
stats, err := daemon.stats(container) |
| 104 | 104 |
if err != nil {
|
| 105 | 105 |
goto done |
| ... | ... |
@@ -124,7 +124,7 @@ done: |
| 124 | 124 |
return stats, nil |
| 125 | 125 |
case errdefs.ErrConflict, errdefs.ErrNotFound: |
| 126 | 126 |
// return empty stats containing only name and ID if not running or not found |
| 127 |
- return &types.StatsJSON{
|
|
| 127 |
+ return &containertypes.StatsResponse{
|
|
| 128 | 128 |
Name: container.Name, |
| 129 | 129 |
ID: container.ID, |
| 130 | 130 |
}, nil |
| ... | ... |
@@ -4,7 +4,7 @@ import ( |
| 4 | 4 |
"sync" |
| 5 | 5 |
"time" |
| 6 | 6 |
|
| 7 |
- "github.com/docker/docker/api/types" |
|
| 7 |
+ containertypes "github.com/docker/docker/api/types/container" |
|
| 8 | 8 |
"github.com/docker/docker/container" |
| 9 | 9 |
"github.com/moby/pubsub" |
| 10 | 10 |
) |
| ... | ... |
@@ -31,7 +31,7 @@ func NewCollector(supervisor supervisor, interval time.Duration) *Collector {
|
| 31 | 31 |
|
| 32 | 32 |
type supervisor interface {
|
| 33 | 33 |
// GetContainerStats collects all the stats related to a container |
| 34 |
- GetContainerStats(container *container.Container) (*types.StatsJSON, error) |
|
| 34 |
+ GetContainerStats(container *container.Container) (*containertypes.StatsResponse, error) |
|
| 35 | 35 |
} |
| 36 | 36 |
|
| 37 | 37 |
// Collect registers the container with the collector and adds it to |
| ... | ... |
@@ -105,7 +105,7 @@ func (s *Collector) Run() {
|
| 105 | 105 |
for _, pair := range pairs {
|
| 106 | 106 |
stats, err := s.supervisor.GetContainerStats(pair.container) |
| 107 | 107 |
if err != nil {
|
| 108 |
- stats = &types.StatsJSON{
|
|
| 108 |
+ stats = &containertypes.StatsResponse{
|
|
| 109 | 109 |
Name: pair.container.Name, |
| 110 | 110 |
ID: pair.container.ID, |
| 111 | 111 |
} |
| ... | ... |
@@ -12,15 +12,15 @@ import ( |
| 12 | 12 |
|
| 13 | 13 |
statsV1 "github.com/containerd/cgroups/v3/cgroup1/stats" |
| 14 | 14 |
statsV2 "github.com/containerd/cgroups/v3/cgroup2/stats" |
| 15 |
- "github.com/docker/docker/api/types" |
|
| 15 |
+ containertypes "github.com/docker/docker/api/types/container" |
|
| 16 | 16 |
"github.com/docker/docker/container" |
| 17 | 17 |
"github.com/pkg/errors" |
| 18 | 18 |
) |
| 19 | 19 |
|
| 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)) |
|
| 22 | 22 |
for i, re := range entries {
|
| 23 |
- out[i] = types.BlkioStatEntry{
|
|
| 23 |
+ out[i] = containertypes.BlkioStatEntry{
|
|
| 24 | 24 |
Major: re.Major, |
| 25 | 25 |
Minor: re.Minor, |
| 26 | 26 |
Op: re.Op, |
| ... | ... |
@@ -30,7 +30,7 @@ func copyBlkioEntry(entries []*statsV1.BlkIOEntry) []types.BlkioStatEntry {
|
| 30 | 30 |
return out |
| 31 | 31 |
} |
| 32 | 32 |
|
| 33 |
-func (daemon *Daemon) stats(c *container.Container) (*types.StatsJSON, error) {
|
|
| 33 |
+func (daemon *Daemon) stats(c *container.Container) (*containertypes.StatsResponse, error) {
|
|
| 34 | 34 |
c.Lock() |
| 35 | 35 |
task, err := c.GetRunningTask() |
| 36 | 36 |
c.Unlock() |
| ... | ... |
@@ -44,7 +44,7 @@ func (daemon *Daemon) stats(c *container.Container) (*types.StatsJSON, error) {
|
| 44 | 44 |
} |
| 45 | 45 |
return nil, err |
| 46 | 46 |
} |
| 47 |
- s := &types.StatsJSON{}
|
|
| 47 |
+ s := &containertypes.StatsResponse{}
|
|
| 48 | 48 |
s.Read = cs.Read |
| 49 | 49 |
stats := cs.Metrics |
| 50 | 50 |
switch t := stats.(type) {
|
| ... | ... |
@@ -57,9 +57,9 @@ func (daemon *Daemon) stats(c *container.Container) (*types.StatsJSON, error) {
|
| 57 | 57 |
} |
| 58 | 58 |
} |
| 59 | 59 |
|
| 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) {
|
|
| 61 | 61 |
if stats.Blkio != nil {
|
| 62 |
- s.BlkioStats = types.BlkioStats{
|
|
| 62 |
+ s.BlkioStats = containertypes.BlkioStats{
|
|
| 63 | 63 |
IoServiceBytesRecursive: copyBlkioEntry(stats.Blkio.IoServiceBytesRecursive), |
| 64 | 64 |
IoServicedRecursive: copyBlkioEntry(stats.Blkio.IoServicedRecursive), |
| 65 | 65 |
IoQueuedRecursive: copyBlkioEntry(stats.Blkio.IoQueuedRecursive), |
| ... | ... |
@@ -71,14 +71,14 @@ func (daemon *Daemon) statsV1(s *types.StatsJSON, stats *statsV1.Metrics) (*type |
| 71 | 71 |
} |
| 72 | 72 |
} |
| 73 | 73 |
if stats.CPU != nil {
|
| 74 |
- s.CPUStats = types.CPUStats{
|
|
| 75 |
- CPUUsage: types.CPUUsage{
|
|
| 74 |
+ s.CPUStats = containertypes.CPUStats{
|
|
| 75 |
+ CPUUsage: containertypes.CPUUsage{
|
|
| 76 | 76 |
TotalUsage: stats.CPU.Usage.Total, |
| 77 | 77 |
PercpuUsage: stats.CPU.Usage.PerCPU, |
| 78 | 78 |
UsageInKernelmode: stats.CPU.Usage.Kernel, |
| 79 | 79 |
UsageInUsermode: stats.CPU.Usage.User, |
| 80 | 80 |
}, |
| 81 |
- ThrottlingData: types.ThrottlingData{
|
|
| 81 |
+ ThrottlingData: containertypes.ThrottlingData{
|
|
| 82 | 82 |
Periods: stats.CPU.Throttling.Periods, |
| 83 | 83 |
ThrottledPeriods: stats.CPU.Throttling.ThrottledPeriods, |
| 84 | 84 |
ThrottledTime: stats.CPU.Throttling.ThrottledTime, |
| ... | ... |
@@ -122,7 +122,7 @@ func (daemon *Daemon) statsV1(s *types.StatsJSON, stats *statsV1.Metrics) (*type |
| 122 | 122 |
"total_unevictable": stats.Memory.TotalUnevictable, |
| 123 | 123 |
} |
| 124 | 124 |
if stats.Memory.Usage != nil {
|
| 125 |
- s.MemoryStats = types.MemoryStats{
|
|
| 125 |
+ s.MemoryStats = containertypes.MemoryStats{
|
|
| 126 | 126 |
Stats: raw, |
| 127 | 127 |
Usage: stats.Memory.Usage.Usage, |
| 128 | 128 |
MaxUsage: stats.Memory.Usage.Max, |
| ... | ... |
@@ -130,7 +130,7 @@ func (daemon *Daemon) statsV1(s *types.StatsJSON, stats *statsV1.Metrics) (*type |
| 130 | 130 |
Failcnt: stats.Memory.Usage.Failcnt, |
| 131 | 131 |
} |
| 132 | 132 |
} else {
|
| 133 |
- s.MemoryStats = types.MemoryStats{
|
|
| 133 |
+ s.MemoryStats = containertypes.MemoryStats{
|
|
| 134 | 134 |
Stats: raw, |
| 135 | 135 |
} |
| 136 | 136 |
} |
| ... | ... |
@@ -142,7 +142,7 @@ func (daemon *Daemon) statsV1(s *types.StatsJSON, stats *statsV1.Metrics) (*type |
| 142 | 142 |
} |
| 143 | 143 |
|
| 144 | 144 |
if stats.Pids != nil {
|
| 145 |
- s.PidsStats = types.PidsStats{
|
|
| 145 |
+ s.PidsStats = containertypes.PidsStats{
|
|
| 146 | 146 |
Current: stats.Pids.Current, |
| 147 | 147 |
Limit: stats.Pids.Limit, |
| 148 | 148 |
} |
| ... | ... |
@@ -151,18 +151,18 @@ func (daemon *Daemon) statsV1(s *types.StatsJSON, stats *statsV1.Metrics) (*type |
| 151 | 151 |
return s, nil |
| 152 | 152 |
} |
| 153 | 153 |
|
| 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) {
|
|
| 155 | 155 |
if stats.Io != nil {
|
| 156 |
- var isbr []types.BlkioStatEntry |
|
| 156 |
+ var isbr []containertypes.BlkioStatEntry |
|
| 157 | 157 |
for _, re := range stats.Io.Usage {
|
| 158 | 158 |
isbr = append(isbr, |
| 159 |
- types.BlkioStatEntry{
|
|
| 159 |
+ containertypes.BlkioStatEntry{
|
|
| 160 | 160 |
Major: re.Major, |
| 161 | 161 |
Minor: re.Minor, |
| 162 | 162 |
Op: "read", |
| 163 | 163 |
Value: re.Rbytes, |
| 164 | 164 |
}, |
| 165 |
- types.BlkioStatEntry{
|
|
| 165 |
+ containertypes.BlkioStatEntry{
|
|
| 166 | 166 |
Major: re.Major, |
| 167 | 167 |
Minor: re.Minor, |
| 168 | 168 |
Op: "write", |
| ... | ... |
@@ -170,21 +170,21 @@ func (daemon *Daemon) statsV2(s *types.StatsJSON, stats *statsV2.Metrics) (*type |
| 170 | 170 |
}, |
| 171 | 171 |
) |
| 172 | 172 |
} |
| 173 |
- s.BlkioStats = types.BlkioStats{
|
|
| 173 |
+ s.BlkioStats = containertypes.BlkioStats{
|
|
| 174 | 174 |
IoServiceBytesRecursive: isbr, |
| 175 | 175 |
// Other fields are unsupported |
| 176 | 176 |
} |
| 177 | 177 |
} |
| 178 | 178 |
|
| 179 | 179 |
if stats.CPU != nil {
|
| 180 |
- s.CPUStats = types.CPUStats{
|
|
| 181 |
- CPUUsage: types.CPUUsage{
|
|
| 180 |
+ s.CPUStats = containertypes.CPUStats{
|
|
| 181 |
+ CPUUsage: containertypes.CPUUsage{
|
|
| 182 | 182 |
TotalUsage: stats.CPU.UsageUsec * 1000, |
| 183 | 183 |
// PercpuUsage is not supported |
| 184 | 184 |
UsageInKernelmode: stats.CPU.SystemUsec * 1000, |
| 185 | 185 |
UsageInUsermode: stats.CPU.UserUsec * 1000, |
| 186 | 186 |
}, |
| 187 |
- ThrottlingData: types.ThrottlingData{
|
|
| 187 |
+ ThrottlingData: containertypes.ThrottlingData{
|
|
| 188 | 188 |
Periods: stats.CPU.NrPeriods, |
| 189 | 189 |
ThrottledPeriods: stats.CPU.NrThrottled, |
| 190 | 190 |
ThrottledTime: stats.CPU.ThrottledUsec * 1000, |
| ... | ... |
@@ -193,7 +193,7 @@ func (daemon *Daemon) statsV2(s *types.StatsJSON, stats *statsV2.Metrics) (*type |
| 193 | 193 |
} |
| 194 | 194 |
|
| 195 | 195 |
if stats.Memory != nil {
|
| 196 |
- s.MemoryStats = types.MemoryStats{
|
|
| 196 |
+ s.MemoryStats = containertypes.MemoryStats{
|
|
| 197 | 197 |
// Stats is not compatible with v1 |
| 198 | 198 |
Stats: map[string]uint64{
|
| 199 | 199 |
"anon": stats.Memory.Anon, |
| ... | ... |
@@ -244,7 +244,7 @@ func (daemon *Daemon) statsV2(s *types.StatsJSON, stats *statsV2.Metrics) (*type |
| 244 | 244 |
} |
| 245 | 245 |
|
| 246 | 246 |
if stats.Pids != nil {
|
| 247 |
- s.PidsStats = types.PidsStats{
|
|
| 247 |
+ s.PidsStats = containertypes.PidsStats{
|
|
| 248 | 248 |
Current: stats.Pids.Current, |
| 249 | 249 |
Limit: stats.Pids.Limit, |
| 250 | 250 |
} |
| ... | ... |
@@ -267,7 +267,7 @@ func (daemon *Daemon) getNetworkSandboxID(c *container.Container) (string, error |
| 267 | 267 |
return curr.NetworkSettings.SandboxID, nil |
| 268 | 268 |
} |
| 269 | 269 |
|
| 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) {
|
|
| 271 | 271 |
sandboxID, err := daemon.getNetworkSandboxID(c) |
| 272 | 272 |
if err != nil {
|
| 273 | 273 |
return nil, err |
| ... | ... |
@@ -283,10 +283,10 @@ func (daemon *Daemon) getNetworkStats(c *container.Container) (map[string]types. |
| 283 | 283 |
return nil, err |
| 284 | 284 |
} |
| 285 | 285 |
|
| 286 |
- stats := make(map[string]types.NetworkStats) |
|
| 286 |
+ stats := make(map[string]containertypes.NetworkStats) |
|
| 287 | 287 |
// Convert libnetwork nw stats into api stats |
| 288 | 288 |
for ifName, ifStats := range lnstats {
|
| 289 |
- stats[ifName] = types.NetworkStats{
|
|
| 289 |
+ stats[ifName] = containertypes.NetworkStats{
|
|
| 290 | 290 |
RxBytes: ifStats.RxBytes, |
| 291 | 291 |
RxPackets: ifStats.RxPackets, |
| 292 | 292 |
RxErrors: ifStats.RxErrors, |
| ... | ... |
@@ -3,13 +3,13 @@ package daemon // import "github.com/docker/docker/daemon" |
| 3 | 3 |
import ( |
| 4 | 4 |
"context" |
| 5 | 5 |
|
| 6 |
- "github.com/docker/docker/api/types" |
|
| 6 |
+ containertypes "github.com/docker/docker/api/types/container" |
|
| 7 | 7 |
"github.com/docker/docker/container" |
| 8 | 8 |
"github.com/docker/docker/errdefs" |
| 9 | 9 |
"github.com/docker/docker/pkg/platform" |
| 10 | 10 |
) |
| 11 | 11 |
|
| 12 |
-func (daemon *Daemon) stats(c *container.Container) (*types.StatsJSON, error) {
|
|
| 12 |
+func (daemon *Daemon) stats(c *container.Container) (*containertypes.StatsResponse, error) {
|
|
| 13 | 13 |
c.Lock() |
| 14 | 14 |
task, err := c.GetRunningTask() |
| 15 | 15 |
c.Unlock() |
| ... | ... |
@@ -27,15 +27,15 @@ func (daemon *Daemon) stats(c *container.Container) (*types.StatsJSON, error) {
|
| 27 | 27 |
} |
| 28 | 28 |
|
| 29 | 29 |
// Start with an empty structure |
| 30 |
- s := &types.StatsJSON{}
|
|
| 30 |
+ s := &containertypes.StatsResponse{}
|
|
| 31 | 31 |
s.Stats.Read = stats.Read |
| 32 | 32 |
s.Stats.NumProcs = platform.NumProcs() |
| 33 | 33 |
|
| 34 | 34 |
if stats.HCSStats != nil {
|
| 35 | 35 |
hcss := stats.HCSStats |
| 36 | 36 |
// Populate the CPU/processor statistics |
| 37 |
- s.CPUStats = types.CPUStats{
|
|
| 38 |
- CPUUsage: types.CPUUsage{
|
|
| 37 |
+ s.CPUStats = containertypes.CPUStats{
|
|
| 38 |
+ CPUUsage: containertypes.CPUUsage{
|
|
| 39 | 39 |
TotalUsage: hcss.Processor.TotalRuntime100ns, |
| 40 | 40 |
UsageInKernelmode: hcss.Processor.RuntimeKernel100ns, |
| 41 | 41 |
UsageInUsermode: hcss.Processor.RuntimeUser100ns, |
| ... | ... |
@@ -43,14 +43,14 @@ func (daemon *Daemon) stats(c *container.Container) (*types.StatsJSON, error) {
|
| 43 | 43 |
} |
| 44 | 44 |
|
| 45 | 45 |
// Populate the memory statistics |
| 46 |
- s.MemoryStats = types.MemoryStats{
|
|
| 46 |
+ s.MemoryStats = containertypes.MemoryStats{
|
|
| 47 | 47 |
Commit: hcss.Memory.UsageCommitBytes, |
| 48 | 48 |
CommitPeak: hcss.Memory.UsageCommitPeakBytes, |
| 49 | 49 |
PrivateWorkingSet: hcss.Memory.UsagePrivateWorkingSetBytes, |
| 50 | 50 |
} |
| 51 | 51 |
|
| 52 | 52 |
// Populate the storage statistics |
| 53 |
- s.StorageStats = types.StorageStats{
|
|
| 53 |
+ s.StorageStats = containertypes.StorageStats{
|
|
| 54 | 54 |
ReadCountNormalized: hcss.Storage.ReadCountNormalized, |
| 55 | 55 |
ReadSizeBytes: hcss.Storage.ReadSizeBytes, |
| 56 | 56 |
WriteCountNormalized: hcss.Storage.WriteCountNormalized, |
| ... | ... |
@@ -58,9 +58,9 @@ func (daemon *Daemon) stats(c *container.Container) (*types.StatsJSON, error) {
|
| 58 | 58 |
} |
| 59 | 59 |
|
| 60 | 60 |
// Populate the network statistics |
| 61 |
- s.Networks = make(map[string]types.NetworkStats) |
|
| 61 |
+ s.Networks = make(map[string]containertypes.NetworkStats) |
|
| 62 | 62 |
for _, nstats := range hcss.Network {
|
| 63 |
- s.Networks[nstats.EndpointId] = types.NetworkStats{
|
|
| 63 |
+ s.Networks[nstats.EndpointId] = containertypes.NetworkStats{
|
|
| 64 | 64 |
RxBytes: nstats.BytesReceived, |
| 65 | 65 |
RxPackets: nstats.PacketsReceived, |
| 66 | 66 |
RxDropped: nstats.DroppedPacketsIncoming, |
| ... | ... |
@@ -74,8 +74,8 @@ func (daemon *Daemon) stats(c *container.Container) (*types.StatsJSON, error) {
|
| 74 | 74 |
} |
| 75 | 75 |
|
| 76 | 76 |
// Windows network stats are obtained directly through HCS, hence this is a no-op. |
| 77 |
-func (daemon *Daemon) getNetworkStats(c *container.Container) (map[string]types.NetworkStats, error) {
|
|
| 78 |
- return make(map[string]types.NetworkStats), nil |
|
| 77 |
+func (daemon *Daemon) getNetworkStats(c *container.Container) (map[string]containertypes.NetworkStats, error) {
|
|
| 78 |
+ return make(map[string]containertypes.NetworkStats), nil |
|
| 79 | 79 |
} |
| 80 | 80 |
|
| 81 | 81 |
// getSystemCPUUsage returns the host system's cpu usage in |
| ... | ... |
@@ -178,7 +178,7 @@ func (s *DockerAPISuite) TestGetContainerStats(c *testing.T) {
|
| 178 | 178 |
case sr := <-bc: |
| 179 | 179 |
dec := json.NewDecoder(sr.stats.Body) |
| 180 | 180 |
defer sr.stats.Body.Close() |
| 181 |
- var s *types.Stats |
|
| 181 |
+ var s *container.Stats |
|
| 182 | 182 |
// decode only one object from the stream |
| 183 | 183 |
assert.NilError(c, dec.Decode(&s)) |
| 184 | 184 |
} |
| ... | ... |
@@ -11,7 +11,7 @@ import ( |
| 11 | 11 |
"testing" |
| 12 | 12 |
"time" |
| 13 | 13 |
|
| 14 |
- "github.com/docker/docker/api/types" |
|
| 14 |
+ "github.com/docker/docker/api/types/container" |
|
| 15 | 15 |
"github.com/docker/docker/api/types/system" |
| 16 | 16 |
"github.com/docker/docker/client" |
| 17 | 17 |
"github.com/docker/docker/integration-cli/cli" |
| ... | ... |
@@ -34,7 +34,7 @@ func (s *DockerAPISuite) TestAPIStatsNoStreamGetCpu(c *testing.T) {
|
| 34 | 34 |
assert.Equal(c, resp.Header.Get("Content-Type"), "application/json")
|
| 35 | 35 |
assert.Equal(c, resp.Header.Get("Content-Type"), "application/json")
|
| 36 | 36 |
|
| 37 |
- var v *types.Stats |
|
| 37 |
+ var v *container.Stats |
|
| 38 | 38 |
err = json.NewDecoder(body).Decode(&v) |
| 39 | 39 |
assert.NilError(c, err) |
| 40 | 40 |
body.Close() |
| ... | ... |
@@ -173,8 +173,8 @@ func (s *DockerAPISuite) TestAPIStatsNetworkStatsVersioning(c *testing.T) {
|
| 173 | 173 |
assert.Assert(c, jsonBlobHasGTE121NetworkStats(statsJSONBlob), "Stats JSON blob from API does not look like a >=v1.21 API stats structure", statsJSONBlob) |
| 174 | 174 |
} |
| 175 | 175 |
|
| 176 |
-func getNetworkStats(c *testing.T, id string) map[string]types.NetworkStats {
|
|
| 177 |
- var st *types.StatsJSON |
|
| 176 |
+func getNetworkStats(c *testing.T, id string) map[string]container.NetworkStats {
|
|
| 177 |
+ var st *container.StatsResponse |
|
| 178 | 178 |
|
| 179 | 179 |
_, body, err := request.Get(testutil.GetContext(c), "/containers/"+id+"/stats?stream=false") |
| 180 | 180 |
assert.NilError(c, err) |
| ... | ... |
@@ -263,7 +263,7 @@ func (s *DockerAPISuite) TestAPIStatsNoStreamConnectedContainers(c *testing.T) {
|
| 263 | 263 |
if resp.Header.Get("Content-Type") != "application/json" {
|
| 264 | 264 |
ch <- fmt.Errorf("Invalid 'Content-Type' %v", resp.Header.Get("Content-Type"))
|
| 265 | 265 |
} |
| 266 |
- var v *types.Stats |
|
| 266 |
+ var v *container.Stats |
|
| 267 | 267 |
if err := json.NewDecoder(body).Decode(&v); err != nil {
|
| 268 | 268 |
ch <- err |
| 269 | 269 |
} |
| ... | ... |
@@ -12,7 +12,7 @@ import ( |
| 12 | 12 |
"time" |
| 13 | 13 |
|
| 14 | 14 |
"github.com/creack/pty" |
| 15 |
- "github.com/docker/docker/api/types" |
|
| 15 |
+ "github.com/docker/docker/api/types/container" |
|
| 16 | 16 |
"github.com/docker/docker/client" |
| 17 | 17 |
"github.com/docker/docker/integration-cli/cli" |
| 18 | 18 |
"github.com/docker/docker/testutil" |
| ... | ... |
@@ -185,7 +185,7 @@ func (s *DockerCLIUpdateSuite) TestUpdateStats(c *testing.T) {
|
| 185 | 185 |
assert.NilError(c, err) |
| 186 | 186 |
assert.Equal(c, resp.Header.Get("Content-Type"), "application/json")
|
| 187 | 187 |
|
| 188 |
- var v *types.Stats |
|
| 188 |
+ var v *container.Stats |
|
| 189 | 189 |
err = json.NewDecoder(body).Decode(&v) |
| 190 | 190 |
assert.NilError(c, err) |
| 191 | 191 |
body.Close() |
| ... | ... |
@@ -6,7 +6,7 @@ import ( |
| 6 | 6 |
"reflect" |
| 7 | 7 |
"testing" |
| 8 | 8 |
|
| 9 |
- "github.com/docker/docker/api/types" |
|
| 9 |
+ containertypes "github.com/docker/docker/api/types/container" |
|
| 10 | 10 |
"github.com/docker/docker/integration/internal/container" |
| 11 | 11 |
"gotest.tools/v3/assert" |
| 12 | 12 |
is "gotest.tools/v3/assert/cmp" |
| ... | ... |
@@ -28,11 +28,11 @@ func TestStats(t *testing.T) {
|
| 28 | 28 |
assert.NilError(t, err) |
| 29 | 29 |
defer resp.Body.Close() |
| 30 | 30 |
|
| 31 |
- var v types.Stats |
|
| 31 |
+ var v containertypes.Stats |
|
| 32 | 32 |
err = json.NewDecoder(resp.Body).Decode(&v) |
| 33 | 33 |
assert.NilError(t, err) |
| 34 | 34 |
assert.Check(t, is.Equal(int64(v.MemoryStats.Limit), info.MemTotal)) |
| 35 |
- assert.Check(t, !reflect.DeepEqual(v.PreCPUStats, types.CPUStats{}))
|
|
| 35 |
+ assert.Check(t, !reflect.DeepEqual(v.PreCPUStats, containertypes.CPUStats{}))
|
|
| 36 | 36 |
err = json.NewDecoder(resp.Body).Decode(&v) |
| 37 | 37 |
assert.Assert(t, is.ErrorContains(err, ""), io.EOF) |
| 38 | 38 |
|
| ... | ... |
@@ -40,11 +40,11 @@ func TestStats(t *testing.T) {
|
| 40 | 40 |
assert.NilError(t, err) |
| 41 | 41 |
defer resp.Body.Close() |
| 42 | 42 |
|
| 43 |
- v = types.Stats{}
|
|
| 43 |
+ v = containertypes.Stats{}
|
|
| 44 | 44 |
err = json.NewDecoder(resp.Body).Decode(&v) |
| 45 | 45 |
assert.NilError(t, err) |
| 46 | 46 |
assert.Check(t, is.Equal(int64(v.MemoryStats.Limit), info.MemTotal)) |
| 47 |
- assert.Check(t, is.DeepEqual(v.PreCPUStats, types.CPUStats{}))
|
|
| 47 |
+ assert.Check(t, is.DeepEqual(v.PreCPUStats, containertypes.CPUStats{}))
|
|
| 48 | 48 |
err = json.NewDecoder(resp.Body).Decode(&v) |
| 49 | 49 |
assert.Assert(t, is.ErrorContains(err, ""), io.EOF) |
| 50 | 50 |
} |