commit 1a442bf06c55c4aa0a9efcf916a47ce243598187 Author: Daniel Demus Date: Tue Jan 7 13:37:36 2025 +0100 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..60afe2f --- /dev/null +++ b/.gitignore @@ -0,0 +1,37 @@ +# ---> Go +# If you prefer the allow list template instead of the deny list, see community template: +# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore +# +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib + +# Test binary, built with `go test -c` +*.test + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out + +# Dependency directories (remove the comment below to include it) +# vendor/ + +# Go workspace file +go.work + +# ---> VisualStudioCode +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +!.vscode/*.code-snippets + +# Local History for Visual Studio Code +.history/ + +# Built Visual Studio Code Extensions +*.vsix + diff --git a/0001-Add-reaper-StartLocked.patch b/0001-Add-reaper-StartLocked.patch new file mode 100644 index 0000000..610ec00 --- /dev/null +++ b/0001-Add-reaper-StartLocked.patch @@ -0,0 +1,33 @@ +From 788f2f928c1d0099d3861553bf82e83169811a29 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Robert-Andr=C3=A9=20Mauchin?= +Date: Tue, 1 Nov 2022 22:09:38 +0100 +Subject: [PATCH] Add reaper StartLocked + +--- + sys/reaper/reaper_unix.go | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +diff --git a/sys/reaper/reaper_unix.go b/sys/reaper/reaper_unix.go +index 6c4f13b90..a6d6a1e77 100644 +--- a/sys/reaper/reaper_unix.go ++++ b/sys/reaper/reaper_unix.go +@@ -101,6 +101,16 @@ func (m *Monitor) Start(c *exec.Cmd) (chan runc.Exit, error) { + return ec, nil + } + ++// StartLocked starts the command a registers the process with the reaper ++func (m *Monitor) StartLocked(c *exec.Cmd) (chan runc.Exit, error) { ++ ec := m.Subscribe() ++ if err := c.Start(); err != nil { ++ m.Unsubscribe(ec) ++ return nil, err ++ } ++ return ec, nil ++} ++ + // Wait blocks until a process is signal as dead. + // User should rely on the value of the exit status to determine if the + // command was successful or not. +-- +2.38.1 + diff --git a/0001-Revert-commit-for-Windows-metrics.patch b/0001-Revert-commit-for-Windows-metrics.patch new file mode 100644 index 0000000..ad64f33 --- /dev/null +++ b/0001-Revert-commit-for-Windows-metrics.patch @@ -0,0 +1,110 @@ +Index: cmd/ctr/commands/tasks/metrics.go +IDEA additional info: +Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP +<+>UTF-8 +=================================================================== +diff --git a/cmd/ctr/commands/tasks/metrics.go b/cmd/ctr/commands/tasks/metrics.go +--- a/cmd/ctr/commands/tasks/metrics.go ++++ b/cmd/ctr/commands/tasks/metrics.go (date 1732200040000) +@@ -23,7 +23,6 @@ + "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/cmd/ctr/commands" +@@ -75,8 +74,6 @@ + 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") + } +@@ -94,11 +91,6 @@ + printCgroupMetricsTable(w, v) + case *v2.Metrics: + printCgroup2MetricsTable(w, v) +- case *wstats.Statistics: +- if err := printWindowsStats(w, v); err != nil { +- return fmt.Errorf("cannot convert metrics data from windows.Statistics: %w", err) +- } +- } + return w.Flush() + case formatJSON: + marshaledJSON, err := json.MarshalIndent(data, "", " ") +@@ -151,72 +143,3 @@ + fmt.Fprintf(w, "memory.swap_limit\t%v\t\n", data.Memory.SwapLimit) + } + } +- +-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) +- } else if windowsStats.GetWindows() != nil { +- printWindowsContainerStatistics(w, windowsStats.GetWindows()) +- } +- // Print VM stats if its isolated +- if windowsStats.VM != nil { +- printWindowsVMStatistics(w, windowsStats.VM) +- } +- return nil +-} +- +-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/0002-Remove-windows-only-dep.patch b/0002-Remove-windows-only-dep.patch new file mode 100644 index 0000000..7abcc5b --- /dev/null +++ b/0002-Remove-windows-only-dep.patch @@ -0,0 +1,17 @@ +Index: pkg/cri/server/helpers.go +IDEA additional info: +Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP +<+>UTF-8 +=================================================================== +diff --git a/pkg/cri/server/helpers.go b/pkg/cri/server/helpers.go +--- a/pkg/cri/server/helpers.go ++++ b/pkg/cri/server/helpers.go (date 1736286303484) +@@ -370,8 +370,6 @@ + return &runcoptions.Options{} + case plugin.RuntimeLinuxV1: + return &runctypes.RuncOptions{} +- case runtimeRunhcsV1: +- return &runhcsoptions.Options{} + default: + return &runtimeoptions.Options{} + } diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..46b1fa5 --- /dev/null +++ b/LICENSE @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) 2025 demus + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..fa46f62 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# golang-rpm + +Template repo for golang fedora packaging \ No newline at end of file diff --git a/golang-github-containerd.spec b/golang-github-containerd.spec new file mode 100644 index 0000000..cab6cd5 --- /dev/null +++ b/golang-github-containerd.spec @@ -0,0 +1,211 @@ +## START: Set by rpmautospec +## (rpmautospec version 0.6.3) +## RPMAUTOSPEC: autorelease, autochangelog +%define autorelease(e:s:pb:n) %{?-p:0.}%{lua: + release_number = 1; + base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}")); + print(release_number + base_release_number - 1); +}%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{!?-n:%{?dist}} +## END: Set by rpmautospec + +# Generated by go2rpm 1.11.0 +%global debug_package %{nil} +%bcond_without check +%bcond_with bootstrap + +# https://github.com/containerd/containerd +%global goipath github.com/containerd/containerd +Version: 1.7.24 + +%gometa -L + +%global common_description %{expand: +An open and reliable container runtime.} + +%global golicenses LICENSE NOTICE +%global godocs docs ROADMAP.md SCOPE.md code-of-conduct.md\\\ + BUILDING.md README.md RELEASES.md +%global godevelheader %{expand: +# This package exists as a temporary measure to prepare for the de-vendoring of +# the docker stack. +# Once the rest of the containerd/docker/moby ecosystem is de-vendored, this +# package will be retired. +# Therefore, it's marked as deprecated() so nothing new will depend on it. +Provides: deprecated() +# Replace old containerd-devel package +Provides: containerd-devel = %{?epoch:%{epoch}:}%{version}-%{release} +Obsoletes: containerd-devel < 1.6.23-6 +} + +Name: golang-github-containerd +Release: %autorelease +Summary: An open and reliable container runtime + +License: Apache-2.0 +URL: %{gourl} +Source: %{gosource} + +# Carve out code requiring github.com/Microsoft/hcsshim +Patch0: 0001-Revert-commit-for-Windows-metrics.patch +Patch1: 0002-Remove-windows-only-dep.patch +# Backport for github.com/containerd/typeurl update +# To use with latest go-runc +Patch2: 0001-Add-reaper-StartLocked.patch + + +%if %{without bootstrap} +BuildRequires: golang(github.com/containerd/aufs/plugin) +%endif +BuildRequires: golang(github.com/containerd/btrfs) +BuildRequires: golang(github.com/containerd/cgroups) +BuildRequires: golang(github.com/containerd/cgroups/stats/v1) +BuildRequires: golang(github.com/containerd/cgroups/v2) +BuildRequires: golang(github.com/containerd/cgroups/v2/stats) +BuildRequires: golang(github.com/containerd/console) +BuildRequires: golang(github.com/containerd/continuity) +BuildRequires: golang(github.com/containerd/continuity/fs) +BuildRequires: golang(github.com/containerd/continuity/fs/fstest) +BuildRequires: golang(github.com/containerd/continuity/sysx) +BuildRequires: golang(github.com/containerd/fifo) +BuildRequires: golang(github.com/containerd/go-cni) +BuildRequires: golang(github.com/containerd/go-runc) +BuildRequires: golang(github.com/containerd/imgcrypt) +BuildRequires: golang(github.com/containerd/imgcrypt/images/encryption) +BuildRequires: golang(github.com/containerd/nri) +BuildRequires: golang(github.com/containerd/nri/types/v1) +BuildRequires: golang(github.com/containerd/ttrpc) +BuildRequires: golang(github.com/containerd/ttrpc/plugin) +BuildRequires: golang(github.com/containerd/typeurl) +%if %{without bootstrap} +BuildRequires: golang(github.com/containerd/zfs/plugin) +%endif +BuildRequires: golang(github.com/containernetworking/plugins/pkg/ns) +BuildRequires: golang(github.com/coreos/go-systemd/v22/daemon) +BuildRequires: golang(github.com/davecgh/go-spew/spew) +BuildRequires: golang(github.com/docker/go-events) +BuildRequires: golang(github.com/docker/go-metrics) +BuildRequires: golang(github.com/docker/go-units) +BuildRequires: golang(github.com/emicklei/go-restful) +BuildRequires: golang(github.com/fsnotify/fsnotify) +BuildRequires: golang(github.com/gogo/googleapis/google/rpc) +BuildRequires: golang(github.com/gogo/protobuf/gogoproto) +BuildRequires: golang(github.com/gogo/protobuf/proto) +BuildRequires: golang(github.com/gogo/protobuf/protoc-gen-gogo/descriptor) +BuildRequires: golang(github.com/gogo/protobuf/protoc-gen-gogo/generator) +BuildRequires: golang(github.com/gogo/protobuf/sortkeys) +BuildRequires: golang(github.com/gogo/protobuf/types) +BuildRequires: golang(github.com/gogo/protobuf/vanity) +BuildRequires: golang(github.com/gogo/protobuf/vanity/command) +BuildRequires: golang(github.com/google/uuid) +BuildRequires: golang(github.com/grpc-ecosystem/go-grpc-middleware) +BuildRequires: golang(github.com/grpc-ecosystem/go-grpc-prometheus) +BuildRequires: golang(github.com/hashicorp/go-multierror) +BuildRequires: golang(github.com/imdario/mergo) +BuildRequires: golang(github.com/intel/goresctrl/pkg/rdt) +BuildRequires: golang(github.com/klauspost/compress/zstd) +# BuildRequires: golang(github.com/Microsoft/hcsshim/cmd/containerd-shim-runhcs-v1/options) +# BuildRequires: golang(github.com/Microsoft/hcsshim/cmd/containerd-shim-runhcs-v1/stats) +BuildRequires: golang(github.com/moby/locker) +BuildRequires: golang(github.com/moby/sys/mountinfo) +BuildRequires: golang(github.com/moby/sys/signal) +BuildRequires: golang(github.com/moby/sys/symlink) +BuildRequires: golang(github.com/opencontainers/go-digest) +BuildRequires: golang(github.com/opencontainers/go-digest/digestset) +BuildRequires: golang(github.com/opencontainers/image-spec/identity) +BuildRequires: golang(github.com/opencontainers/image-spec/specs-go) +BuildRequires: golang(github.com/opencontainers/image-spec/specs-go/v1) +BuildRequires: golang(github.com/opencontainers/runc/libcontainer/user) +BuildRequires: golang(github.com/opencontainers/runtime-spec/specs-go) +BuildRequires: golang(github.com/opencontainers/selinux/go-selinux) +BuildRequires: golang(github.com/opencontainers/selinux/go-selinux/label) +BuildRequires: golang(github.com/pelletier/go-toml) +BuildRequires: golang(github.com/prometheus/client_golang/prometheus) +BuildRequires: golang(github.com/sirupsen/logrus) +BuildRequires: golang(github.com/stretchr/testify/require) +BuildRequires: golang(github.com/tchap/go-patricia/patricia) +BuildRequires: golang(github.com/urfave/cli) +BuildRequires: golang(github.com/vishvananda/netlink) +BuildRequires: golang(go.etcd.io/bbolt) +BuildRequires: golang(go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc) +BuildRequires: golang(go.opentelemetry.io/otel) +BuildRequires: golang(go.opentelemetry.io/otel/attribute) +BuildRequires: golang(go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc) +BuildRequires: golang(go.opentelemetry.io/otel/propagation) +BuildRequires: golang(go.opentelemetry.io/otel/sdk/resource) +BuildRequires: golang(go.opentelemetry.io/otel/sdk/trace) +BuildRequires: golang(go.opentelemetry.io/otel/semconv/v1.4.0) +BuildRequires: golang(go.opentelemetry.io/otel/trace) +BuildRequires: golang(golang.org/x/net/context) +BuildRequires: golang(golang.org/x/net/context/ctxhttp) +BuildRequires: golang(golang.org/x/sync/errgroup) +BuildRequires: golang(golang.org/x/sync/semaphore) +BuildRequires: golang(golang.org/x/sys/execabs) +BuildRequires: golang(golang.org/x/sys/unix) +BuildRequires: golang(google.golang.org/grpc) +BuildRequires: golang(google.golang.org/grpc/backoff) +BuildRequires: golang(google.golang.org/grpc/codes) +BuildRequires: golang(google.golang.org/grpc/credentials) +BuildRequires: golang(google.golang.org/grpc/credentials/insecure) +BuildRequires: golang(google.golang.org/grpc/grpclog) +BuildRequires: golang(google.golang.org/grpc/health) +BuildRequires: golang(google.golang.org/grpc/health/grpc_health_v1) +BuildRequires: golang(google.golang.org/grpc/metadata) +BuildRequires: golang(google.golang.org/grpc/status) +BuildRequires: golang(gotest.tools/v3/assert) +BuildRequires: golang(gotest.tools/v3/assert/cmp) +BuildRequires: golang(k8s.io/api/core/v1) +BuildRequires: golang(k8s.io/apimachinery/pkg/api/errors) +BuildRequires: golang(k8s.io/apimachinery/pkg/api/resource) +BuildRequires: golang(k8s.io/apimachinery/pkg/apis/meta/v1) +BuildRequires: golang(k8s.io/apimachinery/pkg/types) +BuildRequires: golang(k8s.io/apimachinery/pkg/util/httpstream) +BuildRequires: golang(k8s.io/apimachinery/pkg/util/httpstream/spdy) +BuildRequires: golang(k8s.io/apimachinery/pkg/util/net) +BuildRequires: golang(k8s.io/apimachinery/pkg/util/remotecommand) +BuildRequires: golang(k8s.io/apimachinery/pkg/util/runtime) +BuildRequires: golang(k8s.io/apimachinery/pkg/util/sets) +BuildRequires: golang(k8s.io/apiserver/pkg/server/httplog) +BuildRequires: golang(k8s.io/apiserver/pkg/util/wsstream) +BuildRequires: golang(k8s.io/client-go/tools/remotecommand) +BuildRequires: golang(k8s.io/client-go/util/cert) +BuildRequires: golang(k8s.io/component-base/logs/logreduction) +BuildRequires: golang(k8s.io/cri-api/pkg/apis/runtime/v1) +BuildRequires: golang(k8s.io/cri-api/pkg/apis/runtime/v1alpha2) +BuildRequires: golang(k8s.io/klog/v2) +BuildRequires: golang(k8s.io/utils/clock) +BuildRequires: golang(k8s.io/utils/exec) + +%if %{with check} +# Tests +BuildRequires: golang(github.com/containerd/continuity/testutil) +BuildRequires: golang(github.com/containerd/continuity/testutil/loopback) +BuildRequires: golang(github.com/google/go-cmp/cmp) +BuildRequires: golang(github.com/google/go-cmp/cmp/cmpopts) +BuildRequires: golang(github.com/stretchr/testify/assert) +BuildRequires: golang(google.golang.org/protobuf/proto) +BuildRequires: golang(k8s.io/utils/clock/testing) +%endif + +%description %{common_description} + +%gopkg + +%prep +%goprep -A +%autopatch -p1 + +%install +%gopkginstall + +%if %{with check} +%check +%gocheck -d pkg/cri/server -t integration -d platforms +%endif + +%gopkgfiles + +%changelog +## START: Generated by rpmautospec +* Fri Apr 12 2024 Maxwell G - 1.6.23-1 +- Initial package (rhbz#2274601). +## END: Generated by rpmautospec