Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to 2.0.2 #5

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
182 changes: 182 additions & 0 deletions patches/0001-disable-windows-support-in-ctr-metric.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
From: Shengjing Zhu <[email protected]>
Date: Wed, 16 Sep 2020 15:15:44 +0800
Subject: disable windows support in ctr metric

Forwarded: not-needed
diff --git a/cmd/ctr/commands/tasks/metrics.go b/cmd/ctr/commands/tasks/metrics.go
index 7b15d1f97..de7a3f861 100644
--- a/cmd/ctr/commands/tasks/metrics.go
+++ b/cmd/ctr/commands/tasks/metrics.go
@@ -23,7 +23,6 @@ import (
"os"
"text/tabwriter"

- wstats "github.com/Microsoft/hcsshim/cmd/containerd-shim-runhcs-v1/stats"
v1 "github.com/containerd/cgroups/v3/cgroup1/stats"
v2 "github.com/containerd/cgroups/v3/cgroup2/stats"
"github.com/containerd/containerd/v2/cmd/ctr/commands"
@@ -74,10 +73,8 @@ var metricsCommand = &cli.Command{
data = &v1.Metrics{}
case typeurl.Is(metric.Data, (*v2.Metrics)(nil)):
data = &v2.Metrics{}
- case typeurl.Is(metric.Data, (*wstats.Statistics)(nil)):
- data = &wstats.Statistics{}
default:
- return errors.New("cannot convert metric data to cgroups.Metrics or windows.Statistics")
+ return errors.New("cannot convert metric data to cgroups.Metrics")
}
if err := typeurl.UnmarshalTo(metric.Data, data); err != nil {
return err
@@ -93,8 +90,6 @@ var metricsCommand = &cli.Command{
printCgroupMetricsTable(w, v)
case *v2.Metrics:
printCgroup2MetricsTable(w, v)
- case *wstats.Statistics:
- printWindowsStats(w, v)
}
return w.Flush()
case formatJSON:
@@ -148,57 +143,3 @@ func printCgroup2MetricsTable(w *tabwriter.Writer, data *v2.Metrics) {
fmt.Fprintf(w, "memory.swap_limit\t%v\t\n", data.Memory.SwapLimit)
}
}
-
-func printWindowsStats(w *tabwriter.Writer, windowsStats *wstats.Statistics) {
- if windowsStats.GetLinux() != nil {
- stats := windowsStats.GetLinux()
- printCgroupMetricsTable(w, stats)
- } else if windowsStats.GetWindows() != nil {
- printWindowsContainerStatistics(w, windowsStats.GetWindows())
- }
- // Print VM stats if its isolated
- if windowsStats.VM != nil {
- printWindowsVMStatistics(w, windowsStats.VM)
- }
-}
-
-func printWindowsContainerStatistics(w *tabwriter.Writer, stats *wstats.WindowsContainerStatistics) {
- fmt.Fprintf(w, "METRIC\tVALUE\t\n")
- fmt.Fprintf(w, "timestamp\t%s\t\n", stats.Timestamp)
- fmt.Fprintf(w, "start_time\t%s\t\n", stats.ContainerStartTime)
- fmt.Fprintf(w, "uptime_ns\t%d\t\n", stats.UptimeNS)
- if stats.Processor != nil {
- fmt.Fprintf(w, "cpu.total_runtime_ns\t%d\t\n", stats.Processor.TotalRuntimeNS)
- fmt.Fprintf(w, "cpu.runtime_user_ns\t%d\t\n", stats.Processor.RuntimeUserNS)
- fmt.Fprintf(w, "cpu.runtime_kernel_ns\t%d\t\n", stats.Processor.RuntimeKernelNS)
- }
- if stats.Memory != nil {
- fmt.Fprintf(w, "memory.commit_bytes\t%d\t\n", stats.Memory.MemoryUsageCommitBytes)
- fmt.Fprintf(w, "memory.commit_peak_bytes\t%d\t\n", stats.Memory.MemoryUsageCommitPeakBytes)
- fmt.Fprintf(w, "memory.private_working_set_bytes\t%d\t\n", stats.Memory.MemoryUsagePrivateWorkingSetBytes)
- }
- if stats.Storage != nil {
- fmt.Fprintf(w, "storage.read_count_normalized\t%d\t\n", stats.Storage.ReadCountNormalized)
- fmt.Fprintf(w, "storage.read_size_bytes\t%d\t\n", stats.Storage.ReadSizeBytes)
- fmt.Fprintf(w, "storage.write_count_normalized\t%d\t\n", stats.Storage.WriteCountNormalized)
- fmt.Fprintf(w, "storage.write_size_bytes\t%d\t\n", stats.Storage.WriteSizeBytes)
- }
-}
-
-func printWindowsVMStatistics(w *tabwriter.Writer, stats *wstats.VirtualMachineStatistics) {
- fmt.Fprintf(w, "METRIC\tVALUE\t\n")
- if stats.Processor != nil {
- fmt.Fprintf(w, "vm.cpu.total_runtime_ns\t%d\t\n", stats.Processor.TotalRuntimeNS)
- }
- if stats.Memory != nil {
- fmt.Fprintf(w, "vm.memory.working_set_bytes\t%d\t\n", stats.Memory.WorkingSetBytes)
- fmt.Fprintf(w, "vm.memory.virtual_node_count\t%d\t\n", stats.Memory.VirtualNodeCount)
- fmt.Fprintf(w, "vm.memory.available\t%d\t\n", stats.Memory.VmMemory.AvailableMemory)
- fmt.Fprintf(w, "vm.memory.available_buffer\t%d\t\n", stats.Memory.VmMemory.AvailableMemoryBuffer)
- fmt.Fprintf(w, "vm.memory.reserved\t%d\t\n", stats.Memory.VmMemory.ReservedMemory)
- fmt.Fprintf(w, "vm.memory.assigned\t%d\t\n", stats.Memory.VmMemory.AssignedMemory)
- fmt.Fprintf(w, "vm.memory.slp_active\t%t\t\n", stats.Memory.VmMemory.SlpActive)
- fmt.Fprintf(w, "vm.memory.balancing_enabled\t%t\t\n", stats.Memory.VmMemory.BalancingEnabled)
- fmt.Fprintf(w, "vm.memory.dm_operation_in_progress\t%t\t\n", stats.Memory.VmMemory.DmOperationInProgress)
- }
-}
diff --git a/internal/cri/server/container_stats_list.go b/internal/cri/server/container_stats_list.go
index eabcae7fe..0b0395d7e 100644
--- a/internal/cri/server/container_stats_list.go
+++ b/internal/cri/server/container_stats_list.go
@@ -23,7 +23,6 @@ import (
"reflect"
"time"

- wstats "github.com/Microsoft/hcsshim/cmd/containerd-shim-runhcs-v1/stats"
cg1 "github.com/containerd/cgroups/v3/cgroup1/stats"
cg2 "github.com/containerd/cgroups/v3/cgroup2/stats"
"github.com/containerd/log"
@@ -102,10 +101,6 @@ func (c *criService) getMetricsHandler(ctx context.Context, sandboxID string) (m
snapshotter := c.RuntimeSnapshotter(ctx, ociRuntime)

switch p.OS {
- case "windows":
- return func(meta containerstore.Metadata, stats *types.Metric) (containerStats, error) {
- return c.windowsContainerMetrics(meta, stats, snapshotter)
- }, nil
case "linux":
return func(meta containerstore.Metadata, stats *types.Metric) (containerStats, error) {
return c.linuxContainerMetrics(meta, stats, snapshotter)
@@ -301,62 +296,6 @@ func matchLabelSelector(selector, labels map[string]string) bool {
return true
}

-func (c *criService) windowsContainerMetrics(
- meta containerstore.Metadata,
- stats *types.Metric,
- snapshotter string,
-) (containerStats, error) {
- var cs runtime.ContainerStats
- var usedBytes, inodesUsed uint64
- sn, err := c.GetSnapshot(meta.ID, snapshotter)
- // If snapshotstore doesn't have cached snapshot information
- // set WritableLayer usage to zero
- if err == nil {
- usedBytes = sn.Size
- inodesUsed = sn.Inodes
- }
- cs.WritableLayer = &runtime.FilesystemUsage{
- Timestamp: sn.Timestamp,
- FsId: &runtime.FilesystemIdentifier{
- Mountpoint: c.imageFSPaths[snapshotter],
- },
- UsedBytes: &runtime.UInt64Value{Value: usedBytes},
- InodesUsed: &runtime.UInt64Value{Value: inodesUsed},
- }
- cs.Attributes = &runtime.ContainerAttributes{
- Id: meta.ID,
- Metadata: meta.Config.GetMetadata(),
- Labels: meta.Config.GetLabels(),
- Annotations: meta.Config.GetAnnotations(),
- }
-
- if stats != nil {
- s, err := typeurl.UnmarshalAny(stats.Data)
- if err != nil {
- return containerStats{}, fmt.Errorf("failed to extract container metrics: %w", err)
- }
- wstats := s.(*wstats.Statistics).GetWindows()
- if wstats == nil {
- return containerStats{}, errors.New("windows stats is empty")
- }
- if wstats.Processor != nil {
- cs.Cpu = &runtime.CpuUsage{
- Timestamp: (protobuf.FromTimestamp(wstats.Timestamp)).UnixNano(),
- UsageCoreNanoSeconds: &runtime.UInt64Value{Value: wstats.Processor.TotalRuntimeNS},
- }
- }
- if wstats.Memory != nil {
- cs.Memory = &runtime.MemoryUsage{
- Timestamp: (protobuf.FromTimestamp(wstats.Timestamp)).UnixNano(),
- WorkingSetBytes: &runtime.UInt64Value{
- Value: wstats.Memory.MemoryUsagePrivateWorkingSetBytes,
- },
- }
- }
- }
- return containerStats{&cs, 0}, nil
-}
-
func (c *criService) linuxContainerMetrics(
meta containerstore.Metadata,
stats *types.Metric,
52 changes: 52 additions & 0 deletions patches/0003-Disable-opentelemetry.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
From: Shengjing Zhu <[email protected]>
Date: Mon, 21 Feb 2022 00:53:36 +0800
Subject: Disable opentelemetry

go.opentelemetry.io/contrib is not packaged.

Forwarded: not-needed
diff --git a/cmd/containerd/server/server.go b/cmd/containerd/server/server.go
index 482276e7b..c7785c57a 100644
--- a/cmd/containerd/server/server.go
+++ b/cmd/containerd/server/server.go
@@ -40,7 +40,6 @@ import (
grpc_prometheus "github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus"
v1 "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/prometheus/client_golang/prometheus"
- "go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
"google.golang.org/grpc"
"google.golang.org/grpc/backoff"
"google.golang.org/grpc/credentials"
@@ -161,7 +160,6 @@ func New(ctx context.Context, config *srvconfig.Config) (*Server, error) {
prometheus.MustRegister(prometheusServerMetrics)

serverOpts := []grpc.ServerOption{
- grpc.StatsHandler(otelgrpc.NewServerHandler()),
grpc.ChainStreamInterceptor(
streamNamespaceInterceptor,
prometheusServerMetrics.StreamServerInterceptor(),
diff --git a/pkg/tracing/tracing.go b/pkg/tracing/tracing.go
index 48d760feb..809f6cae8 100644
--- a/pkg/tracing/tracing.go
+++ b/pkg/tracing/tracing.go
@@ -21,7 +21,6 @@ import (
"net/http"
"strings"

- "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/codes"
@@ -46,12 +45,6 @@ func WithAttribute(k string, v interface{}) SpanOpt {

// UpdateHTTPClient updates the http client with the necessary otel transport
func UpdateHTTPClient(client *http.Client, name string) {
- client.Transport = otelhttp.NewTransport(
- client.Transport,
- otelhttp.WithSpanNameFormatter(func(operation string, r *http.Request) string {
- return name
- }),
- )
}

// StartSpan starts child span in a context.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
From: Shengjing Zhu <[email protected]>
Date: Tue, 1 Mar 2022 21:38:59 +0800
Subject: Add Debian specific CNI bin dir to ctr run command

Forwarded: not-needed
diff --git a/cmd/ctr/commands/run/run.go b/cmd/ctr/commands/run/run.go
index 799e37305..5b56f5f2e 100644
--- a/cmd/ctr/commands/run/run.go
+++ b/cmd/ctr/commands/run/run.go
@@ -191,7 +191,7 @@ var Command = &cli.Command{
}
var network gocni.CNI
if enableCNI {
- if network, err = gocni.New(gocni.WithDefaultConf); err != nil {
+ if network, err = gocni.New(gocni.WithPluginDir([]string{gocni.DefaultCNIDir, "/usr/lib/cni"}), gocni.WithDefaultConf); err != nil {
return err
}
}
diff --git a/internal/cri/config/config_unix.go b/internal/cri/config/config_unix.go
index 7322700b4..fbd569c5d 100644
--- a/internal/cri/config/config_unix.go
+++ b/internal/cri/config/config_unix.go
@@ -72,7 +72,7 @@ func DefaultRuntimeConfig() RuntimeConfig {

return RuntimeConfig{
CniConfig: CniConfig{
- NetworkPluginBinDir: "/opt/cni/bin",
+ NetworkPluginBinDir: "/usr/lib/cni",
NetworkPluginConfDir: "/etc/cni/net.d",
NetworkPluginMaxConfNum: 1, // only one CNI plugin config file will be loaded
NetworkPluginSetupSerially: false,
77 changes: 77 additions & 0 deletions patches/0010-Avoid-dependency-on-component-base.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
From: Reinhard Tartler <[email protected]>
Date: Sun, 1 Sep 2024 09:05:27 -0400
Subject: Avoid dependency on component-base

only used for integration tests
diff --git a/integration/remote/remote_runtime.go b/integration/remote/remote_runtime.go
index 956ca5488..e743edc30 100644
--- a/integration/remote/remote_runtime.go
+++ b/integration/remote/remote_runtime.go
@@ -41,7 +41,6 @@ import (

"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
- "k8s.io/component-base/logs/logreduction"
runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1"
"k8s.io/klog/v2"
utilexec "k8s.io/utils/exec"
@@ -54,8 +53,6 @@ import (
type RuntimeService struct {
timeout time.Duration
runtimeClient runtimeapi.RuntimeServiceClient
- // Cache last per-container error message to reduce log spam
- logReduction *logreduction.LogReduction
}

const (
@@ -84,7 +81,6 @@ func NewRuntimeService(endpoint string, connectionTimeout time.Duration) (intern
return &RuntimeService{
timeout: connectionTimeout,
runtimeClient: runtimeapi.NewRuntimeServiceClient(conn),
- logReduction: logreduction.NewLogReduction(identicalErrorDelay),
}, nil
}

@@ -281,7 +277,6 @@ func (r *RuntimeService) StopContainer(containerID string, timeout int64, opts .
ctx, cancel := getContextWithTimeout(t)
defer cancel()

- r.logReduction.ClearID(containerID)
_, err := r.runtimeClient.StopContainer(ctx, &runtimeapi.StopContainerRequest{
ContainerId: containerID,
Timeout: timeout,
@@ -302,7 +297,6 @@ func (r *RuntimeService) RemoveContainer(containerID string, opts ...grpc.CallOp
ctx, cancel := getContextWithTimeout(r.timeout)
defer cancel()

- r.logReduction.ClearID(containerID)
_, err := r.runtimeClient.RemoveContainer(ctx, &runtimeapi.RemoveContainerRequest{
ContainerId: containerID,
}, opts...)
@@ -343,13 +337,8 @@ func (r *RuntimeService) ContainerStatus(containerID string, opts ...grpc.CallOp
ContainerId: containerID,
}, opts...)
if err != nil {
- // Don't spam the log with endless messages about the same failure.
- if r.logReduction.ShouldMessageBePrinted(err.Error(), containerID) {
- klog.Errorf("ContainerStatus %q from runtime service failed: %v", containerID, err)
- }
return nil, err
}
- r.logReduction.ClearID(containerID)
klog.V(10).Infof("[RuntimeService] ContainerStatus Response (containerID=%v, status=%v)", containerID, resp.Status)

if resp.Status != nil {
@@ -552,12 +541,8 @@ func (r *RuntimeService) ContainerStats(containerID string, opts ...grpc.CallOpt
ContainerId: containerID,
}, opts...)
if err != nil {
- if r.logReduction.ShouldMessageBePrinted(err.Error(), containerID) {
- klog.Errorf("ContainerStats %q from runtime service failed: %v", containerID, err)
- }
return nil, err
}
- r.logReduction.ClearID(containerID)
klog.V(10).Infof("[RuntimeService] ContainerStats Response (containerID=%v, stats=%v)", containerID, resp.GetStats())

return resp.GetStats(), nil
Loading