Update dependencies after protobuf update in hcsshim
Signed-off-by: Kirtana Ashok <kiashok@microsoft.com> (cherry picked from commit d129b6f890bceb56b050bbb23ad330bb5699f78c) Signed-off-by: Kirtana Ashok <kiashok@microsoft.com>
This commit is contained in:
parent
e7e5619fed
commit
a645ff2e68
@ -27,7 +27,6 @@ import (
|
||||
v1 "github.com/containerd/cgroups/v3/cgroup1/stats"
|
||||
v2 "github.com/containerd/cgroups/v3/cgroup2/stats"
|
||||
"github.com/containerd/containerd/cmd/ctr/commands"
|
||||
"github.com/containerd/containerd/protobuf/proto"
|
||||
"github.com/containerd/typeurl/v2"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
@ -154,22 +153,8 @@ func printCgroup2MetricsTable(w *tabwriter.Writer, data *v2.Metrics) {
|
||||
|
||||
func printWindowsStats(w *tabwriter.Writer, windowsStats *wstats.Statistics) error {
|
||||
if windowsStats.GetLinux() != nil {
|
||||
var stats v1.Metrics
|
||||
|
||||
// It cannot be casted to v1.Metrics since windowsStats is still generated by gogo/protobuf.
|
||||
linux := windowsStats.GetLinux()
|
||||
|
||||
// But Marshal/Unmarshal works because the underlying protobuf message is compatible.
|
||||
data, err := linux.Marshal()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = proto.Unmarshal(data, &stats)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
printCgroupMetricsTable(w, &stats)
|
||||
stats := windowsStats.GetLinux()
|
||||
printCgroupMetricsTable(w, stats)
|
||||
} else if windowsStats.GetWindows() != nil {
|
||||
printWindowsContainerStatistics(w, windowsStats.GetWindows())
|
||||
}
|
||||
|
@ -303,13 +303,13 @@ func (c *criService) windowsContainerMetrics(
|
||||
}
|
||||
if wstats.Processor != nil {
|
||||
cs.Cpu = &runtime.CpuUsage{
|
||||
Timestamp: wstats.Timestamp.UnixNano(),
|
||||
Timestamp: (protobuf.FromTimestamp(wstats.Timestamp)).UnixNano(),
|
||||
UsageCoreNanoSeconds: &runtime.UInt64Value{Value: wstats.Processor.TotalRuntimeNS},
|
||||
}
|
||||
}
|
||||
if wstats.Memory != nil {
|
||||
cs.Memory = &runtime.MemoryUsage{
|
||||
Timestamp: wstats.Timestamp.UnixNano(),
|
||||
Timestamp: (protobuf.FromTimestamp(wstats.Timestamp)).UnixNano(),
|
||||
WorkingSetBytes: &runtime.UInt64Value{
|
||||
Value: wstats.Memory.MemoryUsagePrivateWorkingSetBytes,
|
||||
},
|
||||
|
@ -31,6 +31,7 @@ import (
|
||||
containerstore "github.com/containerd/containerd/pkg/cri/store/container"
|
||||
sandboxstore "github.com/containerd/containerd/pkg/cri/store/sandbox"
|
||||
"github.com/containerd/containerd/pkg/cri/store/stats"
|
||||
"github.com/containerd/containerd/protobuf"
|
||||
"github.com/containerd/typeurl/v2"
|
||||
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
|
||||
)
|
||||
@ -282,14 +283,14 @@ func (c *criService) convertToCRIStats(stats *wstats.Statistics) (*runtime.Windo
|
||||
}
|
||||
if wstats.Processor != nil {
|
||||
cs.Cpu = &runtime.WindowsCpuUsage{
|
||||
Timestamp: wstats.Timestamp.UnixNano(),
|
||||
Timestamp: (protobuf.FromTimestamp(wstats.Timestamp)).UnixNano(),
|
||||
UsageCoreNanoSeconds: &runtime.UInt64Value{Value: wstats.Processor.TotalRuntimeNS},
|
||||
}
|
||||
}
|
||||
|
||||
if wstats.Memory != nil {
|
||||
cs.Memory = &runtime.WindowsMemoryUsage{
|
||||
Timestamp: wstats.Timestamp.UnixNano(),
|
||||
Timestamp: (protobuf.FromTimestamp(wstats.Timestamp)).UnixNano(),
|
||||
WorkingSetBytes: &runtime.UInt64Value{
|
||||
Value: wstats.Memory.MemoryUsagePrivateWorkingSetBytes,
|
||||
},
|
||||
|
@ -24,6 +24,7 @@ import (
|
||||
containerstore "github.com/containerd/containerd/pkg/cri/store/container"
|
||||
sandboxstore "github.com/containerd/containerd/pkg/cri/store/sandbox"
|
||||
"github.com/containerd/containerd/pkg/cri/store/stats"
|
||||
"github.com/containerd/containerd/protobuf"
|
||||
"github.com/stretchr/testify/assert"
|
||||
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
|
||||
)
|
||||
@ -384,7 +385,7 @@ func sandboxPod(id string, timestamp time.Time, cachedCPU uint64) sandboxstore.S
|
||||
func windowsStat(timestamp time.Time, cpu uint64, memory uint64) *wstats.Statistics_Windows {
|
||||
return &wstats.Statistics_Windows{
|
||||
Windows: &wstats.WindowsContainerStatistics{
|
||||
Timestamp: timestamp,
|
||||
Timestamp: protobuf.ToTimestamp(timestamp),
|
||||
Processor: &wstats.WindowsContainerProcessorStatistics{
|
||||
TotalRuntimeNS: cpu,
|
||||
},
|
||||
|
@ -22,6 +22,7 @@ import (
|
||||
|
||||
wstats "github.com/Microsoft/hcsshim/cmd/containerd-shim-runhcs-v1/stats"
|
||||
"github.com/containerd/containerd/api/types"
|
||||
"github.com/containerd/containerd/protobuf"
|
||||
"github.com/containerd/typeurl/v2"
|
||||
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
|
||||
|
||||
@ -67,13 +68,13 @@ func (c *criService) containerMetrics(
|
||||
}
|
||||
if wstats.Processor != nil {
|
||||
cs.Cpu = &runtime.CpuUsage{
|
||||
Timestamp: wstats.Timestamp.UnixNano(),
|
||||
Timestamp: (protobuf.FromTimestamp(wstats.Timestamp)).UnixNano(),
|
||||
UsageCoreNanoSeconds: &runtime.UInt64Value{Value: wstats.Processor.TotalRuntimeNS},
|
||||
}
|
||||
}
|
||||
if wstats.Memory != nil {
|
||||
cs.Memory = &runtime.MemoryUsage{
|
||||
Timestamp: wstats.Timestamp.UnixNano(),
|
||||
Timestamp: (protobuf.FromTimestamp(wstats.Timestamp)).UnixNano(),
|
||||
WorkingSetBytes: &runtime.UInt64Value{
|
||||
Value: wstats.Memory.MemoryUsagePrivateWorkingSetBytes,
|
||||
},
|
||||
|
@ -31,6 +31,7 @@ import (
|
||||
containerstore "github.com/containerd/containerd/pkg/cri/store/container"
|
||||
sandboxstore "github.com/containerd/containerd/pkg/cri/store/sandbox"
|
||||
"github.com/containerd/containerd/pkg/cri/store/stats"
|
||||
"github.com/containerd/containerd/protobuf"
|
||||
"github.com/containerd/typeurl/v2"
|
||||
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
|
||||
)
|
||||
@ -282,14 +283,14 @@ func (c *criService) convertToCRIStats(stats *wstats.Statistics) (*runtime.Windo
|
||||
}
|
||||
if wstats.Processor != nil {
|
||||
cs.Cpu = &runtime.WindowsCpuUsage{
|
||||
Timestamp: wstats.Timestamp.UnixNano(),
|
||||
Timestamp: (protobuf.FromTimestamp(wstats.Timestamp)).UnixNano(),
|
||||
UsageCoreNanoSeconds: &runtime.UInt64Value{Value: wstats.Processor.TotalRuntimeNS},
|
||||
}
|
||||
}
|
||||
|
||||
if wstats.Memory != nil {
|
||||
cs.Memory = &runtime.WindowsMemoryUsage{
|
||||
Timestamp: wstats.Timestamp.UnixNano(),
|
||||
Timestamp: (protobuf.FromTimestamp(wstats.Timestamp)).UnixNano(),
|
||||
WorkingSetBytes: &runtime.UInt64Value{
|
||||
Value: wstats.Memory.MemoryUsagePrivateWorkingSetBytes,
|
||||
},
|
||||
|
@ -24,6 +24,7 @@ import (
|
||||
containerstore "github.com/containerd/containerd/pkg/cri/store/container"
|
||||
sandboxstore "github.com/containerd/containerd/pkg/cri/store/sandbox"
|
||||
"github.com/containerd/containerd/pkg/cri/store/stats"
|
||||
"github.com/containerd/containerd/protobuf"
|
||||
"github.com/stretchr/testify/assert"
|
||||
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
|
||||
)
|
||||
@ -384,7 +385,7 @@ func sandboxPod(id string, timestamp time.Time, cachedCPU uint64) sandboxstore.S
|
||||
func windowsStat(timestamp time.Time, cpu uint64, memory uint64) *wstats.Statistics_Windows {
|
||||
return &wstats.Statistics_Windows{
|
||||
Windows: &wstats.WindowsContainerStatistics{
|
||||
Timestamp: timestamp,
|
||||
Timestamp: protobuf.ToTimestamp(timestamp),
|
||||
Processor: &wstats.WindowsContainerProcessorStatistics{
|
||||
TotalRuntimeNS: cpu,
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user