From 39a2709c46df848fba125025657a5ef2c4de0c1f Mon Sep 17 00:00:00 2001 From: HoneyLiuJiaYi Date: Mon, 8 Aug 2022 17:36:00 +0800 Subject: [PATCH] fix issue:https://github.com/containerd/cgroups/pull/231/commits/5fe29ea5da6fabfc03a19dd41d2ef56510dacd83 --- .github/workflows/ci.yml | 10 +++++----- Protobuild.toml | 4 ++-- README.md | 10 +++++----- blkio.go | 2 +- blkio_test.go | 4 ++-- cgroup.go | 4 ++-- cmd/cgctl/main.go | 4 ++-- cmd/go.mod | 6 +++--- control.go | 2 +- cpu.go | 2 +- cpuacct.go | 2 +- go.mod | 6 +++++- go.sum | 10 ++++++++++ hugetlb.go | 2 +- memory.go | 2 +- memory_test.go | 2 +- pids.go | 2 +- pids_test.go | 2 +- rdma.go | 2 +- stats/v1/metrics.pb.go | 4 ++-- stats/v1/metrics.pb.txt | 2 +- subsystem.go | 2 +- ticks.go | 2 +- v2/manager.go | 2 +- v2/stats/metrics.pb.go | 4 ++-- v2/stats/metrics.pb.txt | 2 +- v2/utils.go | 2 +- 27 files changed, 56 insertions(+), 42 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9548a4da..da524486 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,7 +39,7 @@ jobs: - name: Checkout cgroups uses: actions/checkout@v2 with: - path: src/github.com/containerd/cgroups + path: src/github.com/KubrickLiu/cgroups fetch-depth: 25 - name: Checkout common project repo @@ -66,7 +66,7 @@ jobs: GITHUB_COMMIT_URL: ${{ github.event.pull_request.commits_url }} DCO_VERBOSITY: "-q" DCO_RANGE: "" - working-directory: src/github.com/containerd/cgroups + working-directory: src/github.com/KubrickLiu/cgroups run: | set -x if [ -z "${GITHUB_COMMIT_URL}" ]; then @@ -78,7 +78,7 @@ jobs: - name: Headers run: ../project/script/validate/fileheader ../project/ - working-directory: src/github.com/containerd/cgroups + working-directory: src/github.com/KubrickLiu/cgroups test: name: Test cgroups @@ -105,10 +105,10 @@ jobs: - name: Checkout cgroups uses: actions/checkout@v2 with: - path: src/github.com/containerd/cgroups + path: src/github.com/KubrickLiu/cgroups - name: Run cgroup tests run: | sudo -E PATH=$PATH GOPATH=$GOPATH \ $(command -v go) test -v -race -coverprofile=coverage.txt -covermode=atomic ./... - working-directory: src/github.com/containerd/cgroups + working-directory: src/github.com/KubrickLiu/cgroups diff --git a/Protobuild.toml b/Protobuild.toml index 1c4c802f..1e7a59bf 100644 --- a/Protobuild.toml +++ b/Protobuild.toml @@ -31,14 +31,14 @@ plugins = ["grpc"] # Aggregrate the API descriptors to lock down API changes. [[descriptors]] -prefix = "github.com/containerd/cgroups/stats/v1" +prefix = "github.com/KubrickLiu/cgroups/stats/v1" target = "stats/v1/metrics.pb.txt" ignore_files = [ "google/protobuf/descriptor.proto", "gogoproto/gogo.proto" ] [[descriptors]] -prefix = "github.com/containerd/cgroups/v2/stats" +prefix = "github.com/KubrickLiu/cgroups/v2/stats" target = "v2/stats/metrics.pb.txt" ignore_files = [ "google/protobuf/descriptor.proto", diff --git a/README.md b/README.md index d2073af3..cbdc7eca 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ # cgroups -[![Build Status](https://github.com/containerd/cgroups/workflows/CI/badge.svg)](https://github.com/containerd/cgroups/actions?query=workflow%3ACI) +[![Build Status](https://github.com/KubrickLiu/cgroups/workflows/CI/badge.svg)](https://github.com/KubrickLiu/cgroups/actions?query=workflow%3ACI) [![codecov](https://codecov.io/gh/containerd/cgroups/branch/main/graph/badge.svg)](https://codecov.io/gh/containerd/cgroups) -[![GoDoc](https://godoc.org/github.com/containerd/cgroups?status.svg)](https://godoc.org/github.com/containerd/cgroups) -[![Go Report Card](https://goreportcard.com/badge/github.com/containerd/cgroups)](https://goreportcard.com/report/github.com/containerd/cgroups) +[![GoDoc](https://godoc.org/github.com/KubrickLiu/cgroups?status.svg)](https://godoc.org/github.com/KubrickLiu/cgroups) +[![Go Report Card](https://goreportcard.com/badge/github.com/KubrickLiu/cgroups)](https://goreportcard.com/report/github.com/KubrickLiu/cgroups) Go package for creating, managing, inspecting, and destroying cgroups. The resources format for settings on the cgroup uses the OCI runtime-spec found @@ -153,13 +153,13 @@ so the resulting slice would be located here on disk: ```go import ( - cgroupsv2 "github.com/containerd/cgroups/v2" + cgroupsv2 "github.com/KubrickLiu/cgroups/v2" specs "github.com/opencontainers/runtime-spec/specs-go" ) res := cgroupsv2.Resources{} // dummy PID of -1 is used for creating a "general slice" to be used as a parent cgroup. -// see https://github.com/containerd/cgroups/blob/1df78138f1e1e6ee593db155c6b369466f577651/v2/manager.go#L732-L735 +// see https://github.com/KubrickLiu/cgroups/blob/1df78138f1e1e6ee593db155c6b369466f577651/v2/manager.go#L732-L735 m, err := cgroupsv2.NewSystemd("/", "my-cgroup-abc.slice", -1, &res) if err != nil { return err diff --git a/blkio.go b/blkio.go index f59c75bb..83a9310a 100644 --- a/blkio.go +++ b/blkio.go @@ -25,7 +25,7 @@ import ( "strconv" "strings" - v1 "github.com/containerd/cgroups/stats/v1" + v1 "github.com/KubrickLiu/cgroups/stats/v1" specs "github.com/opencontainers/runtime-spec/specs-go" ) diff --git a/blkio_test.go b/blkio_test.go index 07b2a967..89234481 100644 --- a/blkio_test.go +++ b/blkio_test.go @@ -21,7 +21,7 @@ import ( "strings" "testing" - v1 "github.com/containerd/cgroups/stats/v1" + v1 "github.com/KubrickLiu/cgroups/stats/v1" ) const data = `major minor #blocks name @@ -45,7 +45,7 @@ func TestGetDevices(t *testing.T) { t.Fatal(err) } for dev, expected := range map[deviceKey]string{ - deviceKey{7, 0}: "/dev/loop0", + deviceKey{7, 0}: "/dev/loop0", deviceKey{259, 0}: "/dev/nvme0n1", deviceKey{259, 1}: "/dev/nvme0n1p1", } { diff --git a/cgroup.go b/cgroup.go index 0fab1cec..40ecae8a 100644 --- a/cgroup.go +++ b/cgroup.go @@ -25,7 +25,7 @@ import ( "strings" "sync" - v1 "github.com/containerd/cgroups/stats/v1" + v1 "github.com/KubrickLiu/cgroups/stats/v1" "github.com/opencontainers/runtime-spec/specs-go" ) @@ -84,7 +84,7 @@ func Load(hierarchy Hierarchy, path Path, opts ...InitOpts) (Cgroup, error) { for _, s := range pathers(subsystems) { p, err := path(s.Name()) if err != nil { - if errors.Is(err, os.ErrNotExist) { + if errors.Is(err, os.ErrNotExist) { return nil, ErrCgroupDeleted } if err == ErrControllerNotActive { diff --git a/cmd/cgctl/main.go b/cmd/cgctl/main.go index 47388d3e..30cdc7ee 100644 --- a/cmd/cgctl/main.go +++ b/cmd/cgctl/main.go @@ -22,8 +22,8 @@ import ( "os" "strconv" - "github.com/containerd/cgroups" - v2 "github.com/containerd/cgroups/v2" + "github.com/KubrickLiu/cgroups" + v2 "github.com/KubrickLiu/cgroups/v2" "github.com/sirupsen/logrus" "github.com/urfave/cli" ) diff --git a/cmd/go.mod b/cmd/go.mod index ec928734..cd1ec72d 100644 --- a/cmd/go.mod +++ b/cmd/go.mod @@ -1,11 +1,11 @@ -module github.com/containerd/cgroups/cmd +module github.com/KubrickLiu/cgroups/cmd go 1.16 -replace github.com/containerd/cgroups => ../ +replace github.com/KubrickLiu/cgroups => ../ require ( - github.com/containerd/cgroups v0.0.0-00010101000000-000000000000 + github.com/KubrickLiu/cgroups v0.0.0-00010101000000-000000000000 github.com/sirupsen/logrus v1.8.1 github.com/urfave/cli v1.22.5 ) diff --git a/control.go b/control.go index 5fcaac6d..2430e0e0 100644 --- a/control.go +++ b/control.go @@ -19,7 +19,7 @@ package cgroups import ( "os" - v1 "github.com/containerd/cgroups/stats/v1" + v1 "github.com/KubrickLiu/cgroups/stats/v1" specs "github.com/opencontainers/runtime-spec/specs-go" ) diff --git a/cpu.go b/cpu.go index 27024f17..2ee34651 100644 --- a/cpu.go +++ b/cpu.go @@ -22,7 +22,7 @@ import ( "path/filepath" "strconv" - v1 "github.com/containerd/cgroups/stats/v1" + v1 "github.com/KubrickLiu/cgroups/stats/v1" specs "github.com/opencontainers/runtime-spec/specs-go" ) diff --git a/cpuacct.go b/cpuacct.go index 4fd5f1e6..c9bfe673 100644 --- a/cpuacct.go +++ b/cpuacct.go @@ -25,7 +25,7 @@ import ( "strconv" "strings" - v1 "github.com/containerd/cgroups/stats/v1" + v1 "github.com/KubrickLiu/cgroups/stats/v1" ) const nanosecondsInSecond = 1000000000 diff --git a/go.mod b/go.mod index 11bf8dfc..563da413 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/containerd/cgroups +module github.com/KubrickLiu/cgroups go 1.17 @@ -16,7 +16,11 @@ require ( ) require ( + github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/russross/blackfriday/v2 v2.0.1 // indirect + github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect + github.com/urfave/cli v1.22.9 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 75686c66..110351da 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,10 @@ +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/cilium/ebpf v0.4.0 h1:QlHdikaxALkqWasW8hAC1mfR0jdmvbfaBdBPFmRSglA= github.com/cilium/ebpf v0.4.0/go.mod h1:4tRaxcgiL706VnOzHOdBlY8IEAIdxINsQBcU4xJJXRs= github.com/coreos/go-systemd/v22 v22.3.2 h1:D9/bQk5vlXQFZ6Kwuu6zaiXJ9oTPe68++AzAJc1DzSI= github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= +github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY= +github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -27,6 +30,10 @@ github.com/opencontainers/runtime-spec v1.0.2 h1:UfAcuLBJB9Coz72x1hgl8O5RVzTdNia github.com/opencontainers/runtime-spec v1.0.2/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q= +github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo= +github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE= github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -36,6 +43,8 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/urfave/cli v1.22.9 h1:cv3/KhXGBGjEXLC4bH0sLuJ9BewaAbpk5oyMOveu4pw= +github.com/urfave/cli v1.22.9/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= @@ -86,6 +95,7 @@ golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8T gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/hugetlb.go b/hugetlb.go index c0eb03b2..9d4440dc 100644 --- a/hugetlb.go +++ b/hugetlb.go @@ -22,7 +22,7 @@ import ( "strconv" "strings" - v1 "github.com/containerd/cgroups/stats/v1" + v1 "github.com/KubrickLiu/cgroups/stats/v1" specs "github.com/opencontainers/runtime-spec/specs-go" ) diff --git a/memory.go b/memory.go index e271866e..7b9a0bd7 100644 --- a/memory.go +++ b/memory.go @@ -25,7 +25,7 @@ import ( "strconv" "strings" - v1 "github.com/containerd/cgroups/stats/v1" + v1 "github.com/KubrickLiu/cgroups/stats/v1" specs "github.com/opencontainers/runtime-spec/specs-go" "golang.org/x/sys/unix" ) diff --git a/memory_test.go b/memory_test.go index b3be7624..6524c082 100644 --- a/memory_test.go +++ b/memory_test.go @@ -24,7 +24,7 @@ import ( "strings" "testing" - v1 "github.com/containerd/cgroups/stats/v1" + v1 "github.com/KubrickLiu/cgroups/stats/v1" ) const memoryData = `cache 1 diff --git a/pids.go b/pids.go index ce78e44c..fe02f99f 100644 --- a/pids.go +++ b/pids.go @@ -23,7 +23,7 @@ import ( "strconv" "strings" - v1 "github.com/containerd/cgroups/stats/v1" + v1 "github.com/KubrickLiu/cgroups/stats/v1" specs "github.com/opencontainers/runtime-spec/specs-go" ) diff --git a/pids_test.go b/pids_test.go index b473191a..10a87759 100644 --- a/pids_test.go +++ b/pids_test.go @@ -24,7 +24,7 @@ import ( "strconv" "testing" - v1 "github.com/containerd/cgroups/stats/v1" + v1 "github.com/KubrickLiu/cgroups/stats/v1" "github.com/opencontainers/runtime-spec/specs-go" ) diff --git a/rdma.go b/rdma.go index 3b59b107..16261ae5 100644 --- a/rdma.go +++ b/rdma.go @@ -24,7 +24,7 @@ import ( "strconv" "strings" - v1 "github.com/containerd/cgroups/stats/v1" + v1 "github.com/KubrickLiu/cgroups/stats/v1" specs "github.com/opencontainers/runtime-spec/specs-go" ) diff --git a/stats/v1/metrics.pb.go b/stats/v1/metrics.pb.go index 6d2d4177..af373972 100644 --- a/stats/v1/metrics.pb.go +++ b/stats/v1/metrics.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: github.com/containerd/cgroups/stats/v1/metrics.proto +// source: github.com/KubrickLiu/cgroups/stats/v1/metrics.proto package v1 @@ -720,7 +720,7 @@ func init() { } func init() { - proto.RegisterFile("github.com/containerd/cgroups/stats/v1/metrics.proto", fileDescriptor_a17b2d87c332bfaa) + proto.RegisterFile("github.com/KubrickLiu/cgroups/stats/v1/metrics.proto", fileDescriptor_a17b2d87c332bfaa) } var fileDescriptor_a17b2d87c332bfaa = []byte{ diff --git a/stats/v1/metrics.pb.txt b/stats/v1/metrics.pb.txt index e476cea6..7b9a1da8 100644 --- a/stats/v1/metrics.pb.txt +++ b/stats/v1/metrics.pb.txt @@ -1,5 +1,5 @@ file { - name: "github.com/containerd/cgroups/stats/v1/metrics.proto" + name: "github.com/KubrickLiu/cgroups/stats/v1/metrics.proto" package: "io.containerd.cgroups.v1" dependency: "gogoproto/gogo.proto" message_type { diff --git a/subsystem.go b/subsystem.go index b2f41854..c1e75e63 100644 --- a/subsystem.go +++ b/subsystem.go @@ -20,7 +20,7 @@ import ( "fmt" "os" - v1 "github.com/containerd/cgroups/stats/v1" + v1 "github.com/KubrickLiu/cgroups/stats/v1" specs "github.com/opencontainers/runtime-spec/specs-go" ) diff --git a/ticks.go b/ticks.go index 84dc38d0..58a44371 100644 --- a/ticks.go +++ b/ticks.go @@ -20,7 +20,7 @@ func getClockTicks() uint64 { // The value comes from `C.sysconf(C._SC_CLK_TCK)`, and // on Linux it's a constant which is safe to be hard coded, // so we can avoid using cgo here. - // See https://github.com/containerd/cgroups/pull/12 for + // See https://github.com/KubrickLiu/cgroups/pull/12 for // more details. return 100 } diff --git a/v2/manager.go b/v2/manager.go index a03b00e0..5691b1ce 100644 --- a/v2/manager.go +++ b/v2/manager.go @@ -30,7 +30,7 @@ import ( "syscall" "time" - "github.com/containerd/cgroups/v2/stats" + "github.com/KubrickLiu/cgroups/v2/stats" systemdDbus "github.com/coreos/go-systemd/v22/dbus" "github.com/godbus/dbus/v5" diff --git a/v2/stats/metrics.pb.go b/v2/stats/metrics.pb.go index 0bd49399..c8937383 100644 --- a/v2/stats/metrics.pb.go +++ b/v2/stats/metrics.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: github.com/containerd/cgroups/v2/stats/metrics.proto +// source: github.com/KubrickLiu/cgroups/v2/stats/metrics.proto package stats @@ -489,7 +489,7 @@ func init() { } func init() { - proto.RegisterFile("github.com/containerd/cgroups/v2/stats/metrics.proto", fileDescriptor_2fc6005842049e6b) + proto.RegisterFile("github.com/KubrickLiu/cgroups/v2/stats/metrics.proto", fileDescriptor_2fc6005842049e6b) } var fileDescriptor_2fc6005842049e6b = []byte{ diff --git a/v2/stats/metrics.pb.txt b/v2/stats/metrics.pb.txt index 59fe27cb..96fc6ba0 100755 --- a/v2/stats/metrics.pb.txt +++ b/v2/stats/metrics.pb.txt @@ -1,5 +1,5 @@ file { - name: "github.com/containerd/cgroups/v2/stats/metrics.proto" + name: "github.com/KubrickLiu/cgroups/v2/stats/metrics.proto" package: "io.containerd.cgroups.v2" dependency: "gogoproto/gogo.proto" message_type { diff --git a/v2/utils.go b/v2/utils.go index 240c9267..5db0a298 100644 --- a/v2/utils.go +++ b/v2/utils.go @@ -28,7 +28,7 @@ import ( "strings" "time" - "github.com/containerd/cgroups/v2/stats" + "github.com/KubrickLiu/cgroups/v2/stats" "github.com/godbus/dbus/v5" "github.com/opencontainers/runtime-spec/specs-go"