diff --git a/.github/workflows/build-test-images.yml b/.github/workflows/build-test-images.yml index a7cbbc4fa..37f742507 100644 --- a/.github/workflows/build-test-images.yml +++ b/.github/workflows/build-test-images.yml @@ -39,7 +39,7 @@ jobs: steps: - uses: actions/setup-go@v2 with: - go-version: '1.18.5' + go-version: '1.19' - uses: actions/checkout@v2 with: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d3f41c68b..97ebd8968 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ on: env: # Go version we currently use to build containerd across all CI. # Note: don't forget to update `Binaries` step, as it contains the matrix of all supported Go versions. - GO_VERSION: '1.18.5' + GO_VERSION: '1.19' jobs: # @@ -35,7 +35,7 @@ jobs: - uses: actions/checkout@v2 - uses: golangci/golangci-lint-action@v3 with: - version: v1.46.2 + version: v1.48.0 skip-cache: true args: --timeout=5m @@ -219,7 +219,7 @@ jobs: strategy: matrix: os: [ubuntu-18.04, macos-12, windows-2019, windows-2022] - go-version: ['1.17.13', '1.18.5'] + go-version: ['1.19', '1.18.5'] steps: - uses: actions/setup-go@v2 with: @@ -415,13 +415,13 @@ jobs: - name: Install containerd dependencies env: RUNC_FLAVOR: ${{ matrix.runc }} - GOFLAGS: -modcacherw run: | sudo apt-get install -y gperf - sudo -E PATH=$PATH script/setup/install-seccomp - sudo -E PATH=$PATH script/setup/install-runc - sudo -E PATH=$PATH script/setup/install-cni $(grep containernetworking/plugins go.mod | awk '{print $2}') - sudo -E PATH=$PATH script/setup/install-critools + script/setup/install-seccomp + script/setup/install-runc + script/setup/install-cni $(grep containernetworking/plugins go.mod | awk '{print $2}') + script/setup/install-critools + script/setup/install-failpoint-binaries - name: Install criu run: | @@ -429,10 +429,6 @@ jobs: sudo apt-get update sudo apt-get install -y criu - - name: Install failpoint binaries - run: | - script/setup/install-failpoint-binaries - - name: Install containerd env: CGO_ENABLED: 1 @@ -440,7 +436,7 @@ jobs: make binaries GO_BUILD_FLAGS="-mod=vendor" sudo -E PATH=$PATH make install - - run: sudo -E PATH=$PATH script/setup/install-gotestsum + - run: script/setup/install-gotestsum - name: Tests env: GOPROXY: direct @@ -540,7 +536,7 @@ jobs: with: go-version: ${{ env.GO_VERSION }} - uses: actions/checkout@v2 - - run: sudo -E PATH=$PATH script/setup/install-gotestsum + - run: script/setup/install-gotestsum - name: Tests env: GOPROXY: direct diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 53fb2e814..9281ebbb3 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -26,7 +26,7 @@ jobs: - uses: actions/setup-go@v2 with: - go-version: 1.18.5 + go-version: 1.19 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL diff --git a/.github/workflows/images.yml b/.github/workflows/images.yml index 819ae0343..74281f65c 100644 --- a/.github/workflows/images.yml +++ b/.github/workflows/images.yml @@ -24,7 +24,7 @@ jobs: steps: - uses: actions/setup-go@v2 with: - go-version: '1.18.5' + go-version: '1.19' - uses: actions/checkout@v2 with: diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index bbb74dcd9..b838e3a2b 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -7,7 +7,7 @@ on: - '.github/workflows/nightly.yml' env: - GO_VERSION: '1.18.5' + GO_VERSION: '1.19' jobs: linux: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4b535414a..cd273cf8a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,7 +6,7 @@ on: name: Containerd Release env: - GO_VERSION: '1.18.5' + GO_VERSION: '1.19' jobs: check: diff --git a/.zuul/playbooks/containerd-build/integration-test.yaml b/.zuul/playbooks/containerd-build/integration-test.yaml index 8d78f0998..09f40a4f8 100644 --- a/.zuul/playbooks/containerd-build/integration-test.yaml +++ b/.zuul/playbooks/containerd-build/integration-test.yaml @@ -2,7 +2,7 @@ become: yes roles: - role: config-golang - go_version: '1.18.5' + go_version: '1.19' arch: arm64 tasks: - name: Install pre-requisites diff --git a/.zuul/playbooks/containerd-build/run.yaml b/.zuul/playbooks/containerd-build/run.yaml index 4f1cb669d..656def855 100644 --- a/.zuul/playbooks/containerd-build/run.yaml +++ b/.zuul/playbooks/containerd-build/run.yaml @@ -2,7 +2,7 @@ become: yes roles: - role: config-golang - go_version: '1.18.5' + go_version: '1.19' arch: arm64 tasks: - name: Build containerd diff --git a/.zuul/playbooks/containerd-build/unit-test.yaml b/.zuul/playbooks/containerd-build/unit-test.yaml index 904f5ad7f..0d5068af1 100644 --- a/.zuul/playbooks/containerd-build/unit-test.yaml +++ b/.zuul/playbooks/containerd-build/unit-test.yaml @@ -2,7 +2,7 @@ become: yes roles: - role: config-golang - go_version: '1.18.5' + go_version: '1.19' arch: arm64 tasks: - name: Build and test containerd diff --git a/Vagrantfile b/Vagrantfile index 5dffee4b4..ca12c87ed 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -97,7 +97,7 @@ EOF config.vm.provision "install-golang", type: "shell", run: "once" do |sh| sh.upload_path = "/tmp/vagrant-install-golang" sh.env = { - 'GO_VERSION': ENV['GO_VERSION'] || "1.18.5", + 'GO_VERSION': ENV['GO_VERSION'] || "1.19", } sh.inline = <<~SHELL #!/usr/bin/env bash diff --git a/api/services/containers/v1/containers.pb.go b/api/services/containers/v1/containers.pb.go index fb989f045..aab9e45b1 100644 --- a/api/services/containers/v1/containers.pb.go +++ b/api/services/containers/v1/containers.pb.go @@ -310,7 +310,7 @@ type ListContainersRequest struct { // filters. Expanded, containers that match the following will be // returned: // - // filters[0] or filters[1] or ... or filters[n-1] or filters[n] + // filters[0] or filters[1] or ... or filters[n-1] or filters[n] // // If filters is zero-length or nil, all items will be returned. Filters []string `protobuf:"bytes,1,rep,name=filters,proto3" json:"filters,omitempty"` diff --git a/api/services/containers/v1/containers.proto b/api/services/containers/v1/containers.proto index b0d6c5af5..3de07ffbd 100644 --- a/api/services/containers/v1/containers.proto +++ b/api/services/containers/v1/containers.proto @@ -134,7 +134,7 @@ message ListContainersRequest { // filters. Expanded, containers that match the following will be // returned: // - // filters[0] or filters[1] or ... or filters[n-1] or filters[n] + // filters[0] or filters[1] or ... or filters[n-1] or filters[n] // // If filters is zero-length or nil, all items will be returned. repeated string filters = 1; diff --git a/api/services/content/v1/content.pb.go b/api/services/content/v1/content.pb.go index 7c028f678..283664662 100644 --- a/api/services/content/v1/content.pb.go +++ b/api/services/content/v1/content.pb.go @@ -403,7 +403,7 @@ type ListContentRequest struct { // filters. Expanded, containers that match the following will be // returned: // - // filters[0] or filters[1] or ... or filters[n-1] or filters[n] + // filters[0] or filters[1] or ... or filters[n-1] or filters[n] // // If filters is zero-length or nil, all items will be returned. Filters []string `protobuf:"bytes,1,rep,name=filters,proto3" json:"filters,omitempty"` diff --git a/api/services/content/v1/content.proto b/api/services/content/v1/content.proto index 6f455c059..8aea0636b 100644 --- a/api/services/content/v1/content.proto +++ b/api/services/content/v1/content.proto @@ -140,7 +140,7 @@ message ListContentRequest { // filters. Expanded, containers that match the following will be // returned: // - // filters[0] or filters[1] or ... or filters[n-1] or filters[n] + // filters[0] or filters[1] or ... or filters[n-1] or filters[n] // // If filters is zero-length or nil, all items will be returned. repeated string filters = 1; diff --git a/api/services/images/v1/images.pb.go b/api/services/images/v1/images.pb.go index ebbd3f842..bb354bc64 100644 --- a/api/services/images/v1/images.pb.go +++ b/api/services/images/v1/images.pb.go @@ -436,7 +436,7 @@ type ListImagesRequest struct { // filters. Expanded, images that match the following will be // returned: // - // filters[0] or filters[1] or ... or filters[n-1] or filters[n] + // filters[0] or filters[1] or ... or filters[n-1] or filters[n] // // If filters is zero-length or nil, all items will be returned. Filters []string `protobuf:"bytes,1,rep,name=filters,proto3" json:"filters,omitempty"` diff --git a/api/services/images/v1/images.proto b/api/services/images/v1/images.proto index 1a1b0146f..3902223ea 100644 --- a/api/services/images/v1/images.proto +++ b/api/services/images/v1/images.proto @@ -118,7 +118,7 @@ message ListImagesRequest { // filters. Expanded, images that match the following will be // returned: // - // filters[0] or filters[1] or ... or filters[n-1] or filters[n] + // filters[0] or filters[1] or ... or filters[n-1] or filters[n] // // If filters is zero-length or nil, all items will be returned. repeated string filters = 1; diff --git a/api/services/introspection/v1/introspection.pb.go b/api/services/introspection/v1/introspection.pb.go index a2b1811c4..e852f7bdd 100644 --- a/api/services/introspection/v1/introspection.pb.go +++ b/api/services/introspection/v1/introspection.pb.go @@ -175,7 +175,7 @@ type PluginsRequest struct { // filters. Expanded, plugins that match the following will be // returned: // - // filters[0] or filters[1] or ... or filters[n-1] or filters[n] + // filters[0] or filters[1] or ... or filters[n-1] or filters[n] // // If filters is zero-length or nil, all items will be returned. Filters []string `protobuf:"bytes,1,rep,name=filters,proto3" json:"filters,omitempty"` diff --git a/api/services/introspection/v1/introspection.proto b/api/services/introspection/v1/introspection.proto index 2a053cc63..31add144f 100644 --- a/api/services/introspection/v1/introspection.proto +++ b/api/services/introspection/v1/introspection.proto @@ -88,7 +88,7 @@ message PluginsRequest { // filters. Expanded, plugins that match the following will be // returned: // - // filters[0] or filters[1] or ... or filters[n-1] or filters[n] + // filters[0] or filters[1] or ... or filters[n-1] or filters[n] // // If filters is zero-length or nil, all items will be returned. repeated string filters = 1; diff --git a/api/services/snapshots/v1/snapshots.pb.go b/api/services/snapshots/v1/snapshots.pb.go index 48cfc5055..b7cec8048 100644 --- a/api/services/snapshots/v1/snapshots.pb.go +++ b/api/services/snapshots/v1/snapshots.pb.go @@ -887,7 +887,7 @@ type ListSnapshotsRequest struct { // filters. Expanded, images that match the following will be // returned: // - // filters[0] or filters[1] or ... or filters[n-1] or filters[n] + // filters[0] or filters[1] or ... or filters[n-1] or filters[n] // // If filters is zero-length or nil, all items will be returned. Filters []string `protobuf:"bytes,2,rep,name=filters,proto3" json:"filters,omitempty"` diff --git a/api/services/snapshots/v1/snapshots.proto b/api/services/snapshots/v1/snapshots.proto index 283765d88..170ff473e 100644 --- a/api/services/snapshots/v1/snapshots.proto +++ b/api/services/snapshots/v1/snapshots.proto @@ -154,7 +154,7 @@ message ListSnapshotsRequest{ // filters. Expanded, images that match the following will be // returned: // - // filters[0] or filters[1] or ... or filters[n-1] or filters[n] + // filters[0] or filters[1] or ... or filters[n-1] or filters[n] // // If filters is zero-length or nil, all items will be returned. repeated string filters = 2; diff --git a/cmd/ctr/commands/cni.go b/cmd/ctr/commands/cni.go index c7e20b3bc..b2ef39c98 100644 --- a/cmd/ctr/commands/cni.go +++ b/cmd/ctr/commands/cni.go @@ -36,7 +36,7 @@ const ( CtrCniMetadataExtension = "ctr.cni-containerd.metadata" ) -//ctr pass cni network metadata to containerd if ctr run use option of --cni +// ctr pass cni network metadata to containerd if ctr run use option of --cni type NetworkMetaData struct { EnableCni bool } diff --git a/content/local/store.go b/content/local/store.go index 457bbcd0e..e5206ac7a 100644 --- a/content/local/store.go +++ b/content/local/store.go @@ -34,7 +34,7 @@ import ( "github.com/containerd/containerd/log" "github.com/sirupsen/logrus" - digest "github.com/opencontainers/go-digest" + "github.com/opencontainers/go-digest" ocispec "github.com/opencontainers/image-spec/specs-go/v1" ) @@ -643,7 +643,6 @@ func (s *store) ingestRoot(ref string) string { // - root: entire ingest directory // - ref: name of the starting ref, must be unique // - data: file where data is written -// func (s *store) ingestPaths(ref string) (string, string, string) { var ( fp = s.ingestRoot(ref) diff --git a/contrib/Dockerfile.test b/contrib/Dockerfile.test index efddcd0b3..333681137 100644 --- a/contrib/Dockerfile.test +++ b/contrib/Dockerfile.test @@ -10,7 +10,7 @@ # # docker build -t containerd-test --build-arg RUNC_VERSION=v1.0.0-rc94 -f Dockerfile.test ../ -ARG GOLANG_VERSION=1.18.5 +ARG GOLANG_VERSION=1.19 ARG GOLANG_IMAGE=golang FROM ${GOLANG_IMAGE}:${GOLANG_VERSION} AS golang diff --git a/contrib/fuzz/daemon.go b/contrib/fuzz/daemon.go index 5df2ac8fc..309ec65ba 100644 --- a/contrib/fuzz/daemon.go +++ b/contrib/fuzz/daemon.go @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ + package fuzz import ( diff --git a/contrib/fuzz/oss_fuzz_build.sh b/contrib/fuzz/oss_fuzz_build.sh index 9a1426772..499bcddde 100755 --- a/contrib/fuzz/oss_fuzz_build.sh +++ b/contrib/fuzz/oss_fuzz_build.sh @@ -40,11 +40,11 @@ compile_fuzzers() { apt-get update && apt-get install -y wget cd $SRC -wget --quiet https://go.dev/dl/go1.18.5.linux-amd64.tar.gz +wget --quiet https://go.dev/dl/go1.19.linux-amd64.tar.gz mkdir temp-go rm -rf /root/.go/* -tar -C temp-go/ -xzf go1.18.5.linux-amd64.tar.gz +tar -C temp-go/ -xzf go1.19.linux-amd64.tar.gz mv temp-go/go/* /root/.go/ cd $SRC/containerd diff --git a/filters/filter.go b/filters/filter.go index cf09d8d9e..e13f2625c 100644 --- a/filters/filter.go +++ b/filters/filter.go @@ -65,7 +65,6 @@ // ``` // name==foo,labels.bar // ``` -// package filters import ( diff --git a/filters/parser.go b/filters/parser.go index 49182d7b7..32767909b 100644 --- a/filters/parser.go +++ b/filters/parser.go @@ -45,7 +45,6 @@ field := quoted | [A-Za-z] [A-Za-z0-9_]+ operator := "==" | "!=" | "~=" value := quoted | [^\s,]+ quoted := - */ func Parse(s string) (Filter, error) { // special case empty to match all diff --git a/filters/quote.go b/filters/quote.go index b76aab9b4..5c800ef84 100644 --- a/filters/quote.go +++ b/filters/quote.go @@ -31,10 +31,10 @@ var errQuoteSyntax = errors.New("quote syntax error") // or character literal represented by the string s. // It returns four values: // -// 1) value, the decoded Unicode code point or byte value; -// 2) multibyte, a boolean indicating whether the decoded character requires a multibyte UTF-8 representation; -// 3) tail, the remainder of the string after the character; and -// 4) an error that will be nil if the character is syntactically valid. +// 1. value, the decoded Unicode code point or byte value; +// 2. multibyte, a boolean indicating whether the decoded character requires a multibyte UTF-8 representation; +// 3. tail, the remainder of the string after the character; and +// 4. an error that will be nil if the character is syntactically valid. // // The second argument, quote, specifies the type of literal being parsed // and therefore which escaped quote character is permitted. diff --git a/images/archive/importer.go b/images/archive/importer.go index c53104950..cd6604597 100644 --- a/images/archive/importer.go +++ b/images/archive/importer.go @@ -55,12 +55,12 @@ func WithImportCompression() ImportOpt { } // ImportIndex imports an index from a tar archive image bundle -// - implements Docker v1.1, v1.2 and OCI v1. -// - prefers OCI v1 when provided -// - creates OCI index for Docker formats -// - normalizes Docker references and adds as OCI ref name -// e.g. alpine:latest -> docker.io/library/alpine:latest -// - existing OCI reference names are untouched +// - implements Docker v1.1, v1.2 and OCI v1. +// - prefers OCI v1 when provided +// - creates OCI index for Docker formats +// - normalizes Docker references and adds as OCI ref name +// e.g. alpine:latest -> docker.io/library/alpine:latest +// - existing OCI reference names are untouched func ImportIndex(ctx context.Context, store content.Store, reader io.Reader, opts ...ImportOpt) (ocispec.Descriptor, error) { var ( tr = tar.NewReader(reader) diff --git a/integration/failpoint/cmd/cni-bridge-fp/main_linux.go b/integration/failpoint/cmd/cni-bridge-fp/main_linux.go index 125c8cf1e..50c4b203b 100644 --- a/integration/failpoint/cmd/cni-bridge-fp/main_linux.go +++ b/integration/failpoint/cmd/cni-bridge-fp/main_linux.go @@ -20,7 +20,7 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" + "io" "os" "path/filepath" "syscall" @@ -168,7 +168,7 @@ func (c *failpointControl) updateTx(updateFn func(conf *failpointConf) error) er } defer unflock(f.Fd()) - data, err := ioutil.ReadAll(f) + data, err := io.ReadAll(f) if err != nil { return fmt.Errorf("failed to read failpoint setting %s: %w", c.confPath, err) } diff --git a/integration/image_pull_timeout_test.go b/integration/image_pull_timeout_test.go index c2566ff07..0b25f90dc 100644 --- a/integration/image_pull_timeout_test.go +++ b/integration/image_pull_timeout_test.go @@ -64,7 +64,7 @@ func TestCRIImagePullTimeout(t *testing.T) { // testCRIImagePullTimeoutByHoldingContentOpenWriter tests that // -// It should not cancel if there is no active http requests. +// It should not cancel if there is no active http requests. // // When there are several pulling requests for the same blob content, there // will only one active http request. It is singleflight. For the waiting pulling @@ -197,7 +197,7 @@ func testCRIImagePullTimeoutByHoldingContentOpenWriter(t *testing.T) { // testCRIImagePullTimeoutByNoDataTransferred tests that // -// It should fail because there is no data transferred in open http request. +// It should fail because there is no data transferred in open http request. // // The case uses the local mirror registry to forward request with circuit // breaker. If the local registry has transferred a certain amount of data in diff --git a/metadata/buckets.go b/metadata/buckets.go index 19e0f91ea..8dcf10f47 100644 --- a/metadata/buckets.go +++ b/metadata/buckets.go @@ -26,7 +26,7 @@ // // Generically, we try to do the following: // -// /// -> +// /// -> // // version: Currently, this is "v1". Additions can be made to v1 in a backwards // compatible way. If the layout changes, a new version must be made, along @@ -46,77 +46,80 @@ // the structure is changed in addition to adding a migration and incrementing // the database version. // Notes: -// * `╘══*...*` refers to maps with arbitrary keys -// * `version` is a key to a numeric value identifying the minor revisions -// of schema version -// * a namespace in a schema bucket cannot be named "version" // -// └──v1 - Schema version bucket +// - `╘══*...*` refers to maps with arbitrary keys +// +// - `version` is a key to a numeric value identifying the minor revisions +// of schema version +// +// - a namespace in a schema bucket cannot be named "version" +// +// └──v1 - Schema version bucket // ├──version : - Latest version, see migrations // ╘══*namespace* -// ├──labels -// │  ╘══*key* : - Label value -// ├──image -// │  ╘══*image name* -// │   ├──createdat : - Created at -// │   ├──updatedat : - Updated at -// │   ├──target -// │   │  ├──digest : - Descriptor digest -// │   │  ├──mediatype : - Descriptor media type -// │   │  └──size : - Descriptor size -// │   └──labels -// │   ╘══*key* : - Label value -// ├──containers -// │  ╘══*container id* -// │   ├──createdat : - Created at -// │   ├──updatedat : - Updated at -// │   ├──spec : - Proto marshaled spec -// │   ├──image : - Image name -// │   ├──snapshotter : - Snapshotter name -// │   ├──snapshotKey : - Snapshot key -// │   ├──runtime -// │   │  ├──name : - Runtime name -// │   │  ├──extensions -// │   │  │  ╘══*name* : - Proto marshaled extension -// │   │  └──options : - Proto marshaled options -// │   └──labels -// │   ╘══*key* : - Label value -// ├──snapshots -// │  ╘══*snapshotter* -// │   ╘══*snapshot key* -// │    ├──name : - Snapshot name in backend -// │   ├──createdat : - Created at -// │   ├──updatedat : - Updated at -// │    ├──parent : - Parent snapshot name -// │   ├──children -// │   │  ╘══*snapshot key* : - Child snapshot reference -// │   └──labels -// │   ╘══*key* : - Label value -// ├──content -// │  ├──blob -// │  │ ╘══*blob digest* -// │  │ ├──createdat : - Created at -// │  │ ├──updatedat : - Updated at -// │  │   ├──size : - Blob size -// │  │ └──labels -// │  │ ╘══*key* : - Label value -// │  └──ingests -// │   ╘══*ingest reference* -// │    ├──ref : - Ingest reference in backend -// │   ├──expireat : - Time to expire ingest -// │   └──expected : - Expected commit digest -// └──leases -// ╘══*lease id* -//   ├──createdat : - Created at -// ├──labels -// │ ╘══*key* : - Label value -//   ├──snapshots -// │  ╘══*snapshotter* -// │   ╘══*snapshot key* : - Snapshot reference -//   ├──content -// │  ╘══*blob digest* : - Content blob reference -// └──ingests -//   ╘══*ingest reference* : - Content ingest reference +// ├──labels +// │  ╘══*key* : - Label value +// ├──image +// │  ╘══*image name* +// │   ├──createdat : - Created at +// │   ├──updatedat : - Updated at +// │   ├──target +// │   │  ├──digest : - Descriptor digest +// │   │  ├──mediatype : - Descriptor media type +// │   │  └──size : - Descriptor size +// │   └──labels +// │   ╘══*key* : - Label value +// ├──containers +// │  ╘══*container id* +// │   ├──createdat : - Created at +// │   ├──updatedat : - Updated at +// │   ├──spec : - Proto marshaled spec +// │   ├──image : - Image name +// │   ├──snapshotter : - Snapshotter name +// │   ├──snapshotKey : - Snapshot key +// │   ├──runtime +// │   │  ├──name : - Runtime name +// │   │  ├──extensions +// │   │  │  ╘══*name* : - Proto marshaled extension +// │   │  └──options : - Proto marshaled options +// │   └──labels +// │   ╘══*key* : - Label value +// ├──snapshots +// │  ╘══*snapshotter* +// │   ╘══*snapshot key* +// │    ├──name : - Snapshot name in backend +// │   ├──createdat : - Created at +// │   ├──updatedat : - Updated at +// │    ├──parent : - Parent snapshot name +// │   ├──children +// │   │  ╘══*snapshot key* : - Child snapshot reference +// │   └──labels +// │   ╘══*key* : - Label value +// ├──content +// │  ├──blob +// │  │ ╘══*blob digest* +// │  │ ├──createdat : - Created at +// │  │ ├──updatedat : - Updated at +// │  │   ├──size : - Blob size +// │  │ └──labels +// │  │ ╘══*key* : - Label value +// │  └──ingests +// │   ╘══*ingest reference* +// │    ├──ref : - Ingest reference in backend +// │   ├──expireat : - Time to expire ingest +// │   └──expected : - Expected commit digest +// └──leases +// ╘══*lease id* +// ├──createdat : - Created at +// ├──labels +// │ ╘══*key* : - Label value +// ├──snapshots +// │  ╘══*snapshotter* +// │   ╘══*snapshot key* : - Snapshot reference +// ├──content +// │  ╘══*blob digest* : - Content blob reference +// └──ingests +// ╘══*ingest reference* : - Content ingest reference package metadata import ( diff --git a/metadata/db.go b/metadata/db.go index 911ca556f..52b98bc45 100644 --- a/metadata/db.go +++ b/metadata/db.go @@ -274,11 +274,11 @@ func (m *DB) RegisterMutationCallback(fn func(bool)) { // to be tracked by go away after reboot or process restart. // // A few limitations to consider: -// - Collectible Resources cannot reference other resources. -// - A failure to complete collection will not fail the garbage collection, -// however, the resources can be collected in a later run. -// - Collectible Resources must track whether the resource is active and/or -// lease membership. +// - Collectible Resources cannot reference other resources. +// - A failure to complete collection will not fail the garbage collection, +// however, the resources can be collected in a later run. +// - Collectible Resources must track whether the resource is active and/or +// lease membership. func (m *DB) RegisterCollectibleResource(t gc.ResourceType, c Collector) { if t < resourceEnd { panic("cannot re-register metadata resource") diff --git a/namespaces/store.go b/namespaces/store.go index 5936772cb..a1b2571bb 100644 --- a/namespaces/store.go +++ b/namespaces/store.go @@ -24,8 +24,6 @@ import "context" // oriented. A namespace is really just a name and a set of labels. Objects // that belong to a namespace are returned when the namespace is assigned to a // given context. -// -// type Store interface { Create(ctx context.Context, namespace string, labels map[string]string) error Labels(ctx context.Context, namespace string) (map[string]string, error) diff --git a/oci/spec_opts.go b/oci/spec_opts.go index cf239cef7..f42bf781d 100644 --- a/oci/spec_opts.go +++ b/oci/spec_opts.go @@ -591,7 +591,8 @@ func WithNamespacedCgroup() SpecOpts { // WithUser sets the user to be used within the container. // It accepts a valid user string in OCI Image Spec v1.0.0: -// user, uid, user:group, uid:gid, uid:group, user:gid +// +// user, uid, user:group, uid:gid, uid:group, user:gid func WithUser(userstr string) SpecOpts { return func(ctx context.Context, client Client, c *containers.Container, s *Spec) error { setProcess(s) diff --git a/oci/spec_opts_nonlinux.go b/oci/spec_opts_nonlinux.go index 6a7667a09..fe9ed6d5d 100644 --- a/oci/spec_opts_nonlinux.go +++ b/oci/spec_opts_nonlinux.go @@ -28,19 +28,19 @@ import ( // WithAllCurrentCapabilities propagates the effective capabilities of the caller process to the container process. // The capability set may differ from WithAllKnownCapabilities when running in a container. -//nolint: deadcode, unused +// nolint: deadcode, unused var WithAllCurrentCapabilities = func(ctx context.Context, client Client, c *containers.Container, s *Spec) error { return WithCapabilities(nil)(ctx, client, c, s) } // WithAllKnownCapabilities sets all the the known linux capabilities for the container process -//nolint: deadcode, unused +// nolint: deadcode, unused var WithAllKnownCapabilities = func(ctx context.Context, client Client, c *containers.Container, s *Spec) error { return WithCapabilities(nil)(ctx, client, c, s) } // WithBlockIO sets the container's blkio parameters -//nolint: deadcode, unused +// nolint: deadcode, unused func WithBlockIO(blockio interface{}) SpecOpts { return func(ctx context.Context, _ Client, c *containers.Container, s *Spec) error { return errors.New("blkio not supported") @@ -48,7 +48,7 @@ func WithBlockIO(blockio interface{}) SpecOpts { } // WithCPUShares sets the container's cpu shares -//nolint: deadcode, unused +// nolint: deadcode, unused func WithCPUShares(shares uint64) SpecOpts { return func(ctx context.Context, _ Client, c *containers.Container, s *Spec) error { return nil diff --git a/pkg/apparmor/apparmor.go b/pkg/apparmor/apparmor.go index dd4d860c0..ef64e5af6 100644 --- a/pkg/apparmor/apparmor.go +++ b/pkg/apparmor/apparmor.go @@ -18,10 +18,11 @@ package apparmor // HostSupports returns true if apparmor is enabled for the host, // On non-Linux returns false // On Linux returns true if apparmor_parser is enabled, and if we -// are not running docker-in-docker. // -// It is a modified version of libcontainer/apparmor.IsEnabled(), which does not -// check for apparmor_parser to be present, or if we're running docker-in-docker. +// are not running docker-in-docker. +// +// It is a modified version of libcontainer/apparmor.IsEnabled(), which does not +// check for apparmor_parser to be present, or if we're running docker-in-docker. func HostSupports() bool { return hostSupports() } diff --git a/pkg/cri/opts/spec.go b/pkg/cri/opts/spec.go index 00419cb9a..4ad1f1c14 100644 --- a/pkg/cri/opts/spec.go +++ b/pkg/cri/opts/spec.go @@ -77,7 +77,8 @@ func WithProcessArgs(config *runtime.ContainerConfig, image *imagespec.ImageConf // mounts defines how to sort runtime.Mount. // This is the same with the Docker implementation: -// https://github.com/moby/moby/blob/17.05.x/daemon/volumes.go#L26 +// +// https://github.com/moby/moby/blob/17.05.x/daemon/volumes.go#L26 type orderedMounts []*runtime.Mount // Len returns the number of mounts. Used in sorting. diff --git a/pkg/cri/sbserver/events.go b/pkg/cri/sbserver/events.go index 38c1794a9..f0782df3c 100644 --- a/pkg/cri/sbserver/events.go +++ b/pkg/cri/sbserver/events.go @@ -234,11 +234,11 @@ func convertEvent(e typeurl.Any) (string, interface{}, error) { // event monitor. // // NOTE: -// 1. start must be called after subscribe. -// 2. The task exit event has been handled in individual startSandboxExitMonitor -// or startContainerExitMonitor goroutine at the first. If the goroutine fails, -// it puts the event into backoff retry queue and event monitor will handle -// it later. +// 1. start must be called after subscribe. +// 2. The task exit event has been handled in individual startSandboxExitMonitor +// or startContainerExitMonitor goroutine at the first. If the goroutine fails, +// it puts the event into backoff retry queue and event monitor will handle +// it later. func (em *eventMonitor) start() <-chan error { errCh := make(chan error) if em.ch == nil || em.errCh == nil { diff --git a/pkg/cri/server/events.go b/pkg/cri/server/events.go index d941278af..85e985d81 100644 --- a/pkg/cri/server/events.go +++ b/pkg/cri/server/events.go @@ -234,11 +234,11 @@ func convertEvent(e typeurl.Any) (string, interface{}, error) { // event monitor. // // NOTE: -// 1. start must be called after subscribe. -// 2. The task exit event has been handled in individual startSandboxExitMonitor -// or startContainerExitMonitor goroutine at the first. If the goroutine fails, -// it puts the event into backoff retry queue and event monitor will handle -// it later. +// 1. start must be called after subscribe. +// 2. The task exit event has been handled in individual startSandboxExitMonitor +// or startContainerExitMonitor goroutine at the first. If the goroutine fails, +// it puts the event into backoff retry queue and event monitor will handle +// it later. func (em *eventMonitor) start() <-chan error { errCh := make(chan error) if em.ch == nil || em.errCh == nil { diff --git a/pkg/cri/streaming/server.go b/pkg/cri/streaming/server.go index c82e1cf71..346dfb2c7 100644 --- a/pkg/cri/streaming/server.go +++ b/pkg/cri/streaming/server.go @@ -45,7 +45,7 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - restful "github.com/emicklei/go-restful/v3" + "github.com/emicklei/go-restful/v3" "k8s.io/apimachinery/pkg/types" remotecommandconsts "k8s.io/apimachinery/pkg/util/remotecommand" @@ -162,9 +162,10 @@ func NewServer(config Config, runtime Runtime) (Server, error) { handler.Add(ws) s.handler = handler s.server = &http.Server{ - Addr: s.config.Addr, - Handler: s.handler, - TLSConfig: s.config.TLSConfig, + Addr: s.config.Addr, + Handler: s.handler, + TLSConfig: s.config.TLSConfig, + ReadHeaderTimeout: 3 * time.Second, // Fix linter G112: Potential Slowloris Attack because ReadHeaderTimeout is not configured in the http.Server } return s, nil diff --git a/pkg/failpoint/fail.go b/pkg/failpoint/fail.go index d48d65ba8..d616ec97e 100644 --- a/pkg/failpoint/fail.go +++ b/pkg/failpoint/fail.go @@ -68,7 +68,7 @@ func (t Type) String() string { // user. The user controlled variable will be parsed for how the error injected // code should fire. There is the way to set the rule for failpoint. // -// *[(arg)][->] +// *[(arg)][->] // // The argument specifies which action to take; it can be one of: // diff --git a/pkg/ioutil/write_closer.go b/pkg/ioutil/write_closer.go index c816c514a..97e13167d 100644 --- a/pkg/ioutil/write_closer.go +++ b/pkg/ioutil/write_closer.go @@ -73,10 +73,10 @@ func (n *nopWriteCloser) Close() error { // serialWriteCloser wraps a write closer and makes sure all writes // are done in serial. // Parallel write won't intersect with each other. Use case: -// 1) Pipe: Write content longer than PIPE_BUF. -// See http://man7.org/linux/man-pages/man7/pipe.7.html -// 2) <3.14 Linux Kernel: write is not atomic -// See http://man7.org/linux/man-pages/man2/write.2.html +// 1. Pipe: Write content longer than PIPE_BUF. +// See http://man7.org/linux/man-pages/man7/pipe.7.html +// 2. <3.14 Linux Kernel: write is not atomic +// See http://man7.org/linux/man-pages/man2/write.2.html type serialWriteCloser struct { mu sync.Mutex wc io.WriteCloser diff --git a/pkg/os/os_windows.go b/pkg/os/os_windows.go index f177a38cd..6047e2f59 100644 --- a/pkg/os/os_windows.go +++ b/pkg/os/os_windows.go @@ -29,9 +29,10 @@ import ( // It works for both file and directory paths. // // We are not able to use builtin Go functionality for opening a directory path: -// - os.Open on a directory returns a os.File where Fd() is a search handle from FindFirstFile. -// - syscall.Open does not provide a way to specify FILE_FLAG_BACKUP_SEMANTICS, which is needed to -// open a directory. +// - os.Open on a directory returns a os.File where Fd() is a search handle from FindFirstFile. +// - syscall.Open does not provide a way to specify FILE_FLAG_BACKUP_SEMANTICS, which is needed to +// open a directory. +// // We could use os.Open if the path is a file, but it's easier to just use the same code for both. // Therefore, we call windows.CreateFile directly. func openPath(path string) (windows.Handle, error) { @@ -58,6 +59,7 @@ func openPath(path string) (windows.Handle, error) { } // GetFinalPathNameByHandle flags. +// //nolint:revive // SNAKE_CASE is not idiomatic in Go, but aligned with Win32 API. const ( cFILE_NAME_OPENED = 0x8 diff --git a/platforms/platforms.go b/platforms/platforms.go index ba149ce0a..3421be665 100644 --- a/platforms/platforms.go +++ b/platforms/platforms.go @@ -27,40 +27,40 @@ // The vast majority of use cases should simply use the match function with // user input. The first step is to parse a specifier into a matcher: // -// m, err := Parse("linux") -// if err != nil { ... } +// m, err := Parse("linux") +// if err != nil { ... } // // Once you have a matcher, use it to match against the platform declared by a // component, typically from an image or runtime. Since extracting an images // platform is a little more involved, we'll use an example against the // platform default: // -// if ok := m.Match(Default()); !ok { /* doesn't match */ } +// if ok := m.Match(Default()); !ok { /* doesn't match */ } // // This can be composed in loops for resolving runtimes or used as a filter for // fetch and select images. // // More details of the specifier syntax and platform spec follow. // -// Declaring Platform Support +// # Declaring Platform Support // // Components that have strict platform requirements should use the OCI // platform specification to declare their support. Typically, this will be // images and runtimes that should make these declaring which platform they // support specifically. This looks roughly as follows: // -// type Platform struct { -// Architecture string -// OS string -// Variant string -// } +// type Platform struct { +// Architecture string +// OS string +// Variant string +// } // // Most images and runtimes should at least set Architecture and OS, according // to their GOARCH and GOOS values, respectively (follow the OCI image // specification when in doubt). ARM should set variant under certain // discussions, which are outlined below. // -// Platform Specifiers +// # Platform Specifiers // // While the OCI platform specifications provide a tool for components to // specify structured information, user input typically doesn't need the full @@ -77,7 +77,7 @@ // where the architecture may be known but a runtime may support images from // different operating systems. // -// Normalization +// # Normalization // // Because not all users are familiar with the way the Go runtime represents // platforms, several normalizations have been provided to make this package @@ -85,17 +85,17 @@ // // The following are performed for architectures: // -// Value Normalized -// aarch64 arm64 -// armhf arm -// armel arm/v6 -// i386 386 -// x86_64 amd64 -// x86-64 amd64 +// Value Normalized +// aarch64 arm64 +// armhf arm +// armel arm/v6 +// i386 386 +// x86_64 amd64 +// x86-64 amd64 // // We also normalize the operating system `macos` to `darwin`. // -// ARM Support +// # ARM Support // // To qualify ARM architecture, the Variant field is used to qualify the arm // version. The most common arm version, v7, is represented without the variant diff --git a/process.go b/process.go index 49dc0744e..73d8f8662 100644 --- a/process.go +++ b/process.go @@ -72,8 +72,10 @@ type ExitStatus struct { // Result returns the exit code and time of the exit status. // An error may be returned here to which indicates there was an error -// at some point while waiting for the exit status. It does not signify -// an error with the process itself. +// +// at some point while waiting for the exit status. It does not signify +// an error with the process itself. +// // If an error is returned, the process may still be running. func (s ExitStatus) Result() (uint32, time.Time, error) { return s.code, s.exitedAt, s.err diff --git a/reference/docker/reference.go b/reference/docker/reference.go index 6fa97dfdc..25436b645 100644 --- a/reference/docker/reference.go +++ b/reference/docker/reference.go @@ -19,13 +19,13 @@ // // Grammar // -// reference := name [ ":" tag ] [ "@" digest ] +// reference := name [ ":" tag ] [ "@" digest ] // name := [domain '/'] path-component ['/' path-component]* // domain := domain-component ['.' domain-component]* [':' port-number] // domain-component := /([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])/ // port-number := /[0-9]+/ // path-component := alpha-numeric [separator alpha-numeric]* -// alpha-numeric := /[a-z0-9]+/ +// alpha-numeric := /[a-z0-9]+/ // separator := /[_.]|__|[-]*/ // // tag := /[\w][\w.-]{0,127}/ diff --git a/remotes/docker/config/hosts.go b/remotes/docker/config/hosts.go index daccb1efb..500d1b390 100644 --- a/remotes/docker/config/hosts.go +++ b/remotes/docker/config/hosts.go @@ -530,13 +530,13 @@ func makeAbsPath(p string, base string) string { // loadCertsDir loads certs from certsDir like "/etc/docker/certs.d" . // Compatible with Docker file layout -// - files ending with ".crt" are treated as CA certificate files -// - files ending with ".cert" are treated as client certificates, and -// files with the same name but ending with ".key" are treated as the -// corresponding private key. -// NOTE: If a ".key" file is missing, this function will just return -// the ".cert", which may contain the private key. If the ".cert" file -// does not contain the private key, the caller should detect and error. +// - files ending with ".crt" are treated as CA certificate files +// - files ending with ".cert" are treated as client certificates, and +// files with the same name but ending with ".key" are treated as the +// corresponding private key. +// NOTE: If a ".key" file is missing, this function will just return +// the ".cert", which may contain the private key. If the ".cert" file +// does not contain the private key, the caller should detect and error. func loadCertFiles(ctx context.Context, certsDir string) ([]hostConfig, error) { fs, err := os.ReadDir(certsDir) if err != nil && !os.IsNotExist(err) { diff --git a/remotes/handlers.go b/remotes/handlers.go index 8bcafb22a..4d91ed2e5 100644 --- a/remotes/handlers.go +++ b/remotes/handlers.go @@ -257,8 +257,8 @@ func PushContent(ctx context.Context, pusher Pusher, desc ocispec.Descriptor, st // An example of this kind of content would be a Windows base layer, which is not supposed to be redistributed. // // This is based on the media type of the content: -// - application/vnd.oci.image.layer.nondistributable -// - application/vnd.docker.image.rootfs.foreign +// - application/vnd.oci.image.layer.nondistributable +// - application/vnd.docker.image.rootfs.foreign func SkipNonDistributableBlobs(f images.HandlerFunc) images.HandlerFunc { return func(ctx context.Context, desc ocispec.Descriptor) ([]ocispec.Descriptor, error) { if images.IsNonDistributable(desc.MediaType) { diff --git a/script/setup/install-cni b/script/setup/install-cni index ebbfd248f..321373ccb 100755 --- a/script/setup/install-cni +++ b/script/setup/install-cni @@ -25,6 +25,12 @@ CNI_COMMIT=${1:-$(grep containernetworking/plugins "$GOPATH"/src/github.com/cont CNI_DIR=${DESTDIR:=''}/opt/cni CNI_CONFIG_DIR=${DESTDIR}/etc/cni/net.d +# e2e and Cirrus will fail with "sudo: command not found" +SUDO='' +if (( $EUID != 0 )); then + SUDO='sudo' +fi + TMPROOT=$(mktemp -d) git clone https://github.com/containernetworking/plugins.git "${TMPROOT}"/plugins pushd "${TMPROOT}"/plugins @@ -32,8 +38,8 @@ git checkout "$CNI_COMMIT" ./build_linux.sh mkdir -p $CNI_DIR cp -r ./bin $CNI_DIR -mkdir -p $CNI_CONFIG_DIR -cat << EOF | tee $CNI_CONFIG_DIR/10-containerd-net.conflist +$SUDO mkdir -p $CNI_CONFIG_DIR +$SUDO cat << EOF | $SUDO tee $CNI_CONFIG_DIR/10-containerd-net.conflist { "cniVersion": "1.0.0", "name": "containerd-net", diff --git a/script/setup/install-critools b/script/setup/install-critools index 251a83e0b..3a8374c44 100755 --- a/script/setup/install-critools +++ b/script/setup/install-critools @@ -22,6 +22,12 @@ set -eu -o pipefail script_dir="$(cd -- "$(dirname -- "$0")" > /dev/null 2>&1; pwd -P)" +# e2e will fail with "sudo: command not found" +SUDO='' +if (( $EUID != 0 )); then + SUDO='sudo' +fi + cd "$(go env GOPATH)" go install github.com/onsi/ginkgo/v2/ginkgo@v2.1.4 @@ -33,10 +39,10 @@ git clone https://github.com/kubernetes-sigs/cri-tools.git "${TMPROOT}/cri-tools pushd "${TMPROOT}"/cri-tools git checkout "$CRITEST_COMMIT" make -make install -e DESTDIR="${DESTDIR}" BINDIR=/usr/local/bin +$SUDO make install -e DESTDIR="${DESTDIR}" BINDIR=/usr/local/bin mkdir -p "${DESTDIR}/etc/" -cat << EOF | tee "${DESTDIR}/etc/crictl.yaml" +$SUDO cat << EOF | $SUDO tee "${DESTDIR}/etc/crictl.yaml" runtime-endpoint: unix:///run/containerd/containerd.sock EOF diff --git a/script/setup/install-dev-tools b/script/setup/install-dev-tools index eaa387d3c..078974571 100755 --- a/script/setup/install-dev-tools +++ b/script/setup/install-dev-tools @@ -24,7 +24,7 @@ set -eu -o pipefail go install github.com/containerd/protobuild@v0.2.0 go install github.com/containerd/protobuild/cmd/go-fix-acronym@v0.2.0 go install github.com/cpuguy83/go-md2man/v2@v2.0.1 -go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.46.2 +go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.48.0 go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28 go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2 go install github.com/containerd/ttrpc/cmd/protoc-gen-go-ttrpc@944ef4a40df3446714a823207972b7d9858ffac5 diff --git a/script/setup/install-runc b/script/setup/install-runc index aa9f7bdbb..5b85b9b19 100755 --- a/script/setup/install-runc +++ b/script/setup/install-runc @@ -22,6 +22,12 @@ set -eu -o pipefail script_dir="$(cd -- "$(dirname -- "$0")" > /dev/null 2>&1; pwd -P)" +# e2e and Cirrus will fail with "sudo: command not found" +SUDO='' +if (( $EUID != 0 )); then + SUDO='sudo' +fi + function install_runc() { # When updating runc-version, consider updating the runc module in go.mod as well : "${RUNC_VERSION:=$(cat "${script_dir}/runc-version")}" @@ -31,15 +37,15 @@ function install_runc() { pushd "${TMPROOT}"/runc git checkout "${RUNC_VERSION}" make BUILDTAGS='seccomp' runc - make install + $SUDO make install popd rm -fR "${TMPROOT}" } function install_crun() { : "${CRUN_VERSION:=$(cat "${script_dir}/crun-version")}" - curl -S -o /usr/local/sbin/runc -L https://github.com/containers/crun/releases/download/"${CRUN_VERSION}"/crun-"${CRUN_VERSION}"-linux-"$(go env GOARCH)" - chmod +x /usr/local/sbin/runc + $SUDO curl -S -o /usr/local/sbin/runc -L https://github.com/containers/crun/releases/download/"${CRUN_VERSION}"/crun-"${CRUN_VERSION}"-linux-"$(go env GOARCH)" + $SUDO chmod +x /usr/local/sbin/runc } : "${RUNC_FLAVOR:=runc}" diff --git a/script/setup/install-seccomp b/script/setup/install-seccomp index a9681562b..8a9dfb462 100755 --- a/script/setup/install-seccomp +++ b/script/setup/install-seccomp @@ -30,8 +30,8 @@ curl -fsSL "https://github.com/seccomp/libseccomp/releases/download/v${SECCOMP_V cd "$SECCOMP_PATH" ./configure --prefix=/usr/local make - make install - ldconfig + sudo make install + sudo ldconfig ) rm -rf "$SECCOMP_PATH" diff --git a/script/setup/prepare_env_windows.ps1 b/script/setup/prepare_env_windows.ps1 index 3e61fad5e..1782e23f1 100644 --- a/script/setup/prepare_env_windows.ps1 +++ b/script/setup/prepare_env_windows.ps1 @@ -5,7 +5,7 @@ # lived test environment. Set-MpPreference -DisableRealtimeMonitoring:$true -$PACKAGES= @{ mingw = "10.2.0"; git = ""; golang = "1.18.5"; make = ""; nssm = "" } +$PACKAGES= @{ mingw = "10.2.0"; git = ""; golang = "1.19"; make = ""; nssm = "" } Write-Host "Downloading chocolatey package" curl.exe -L "https://packages.chocolatey.org/chocolatey.0.10.15.nupkg" -o 'c:\choco.zip' diff --git a/snapshots/devmapper/dmsetup/dmsetup.go b/snapshots/devmapper/dmsetup/dmsetup.go index 739178313..b190efa09 100644 --- a/snapshots/devmapper/dmsetup/dmsetup.go +++ b/snapshots/devmapper/dmsetup/dmsetup.go @@ -353,7 +353,8 @@ func BlockDeviceSize(path string) (int64, error) { } // DiscardBlocks discards all blocks for the given thin device -// ported from https://github.com/moby/moby/blob/7b9275c0da707b030e62c96b679a976f31f929d3/pkg/devicemapper/devmapper.go#L416 +// +// ported from https://github.com/moby/moby/blob/7b9275c0da707b030e62c96b679a976f31f929d3/pkg/devicemapper/devmapper.go#L416 func DiscardBlocks(deviceName string) error { inUse, err := isInUse(deviceName) if err != nil { @@ -402,8 +403,10 @@ func tryGetUnixError(output string) (unix.Errno, bool) { } // dmsetup returns error messages in format: -// device-mapper: message ioctl on failed: File exists\n -// Command failed\n +// +// device-mapper: message ioctl on failed: File exists\n +// Command failed\n +// // parseDmsetupError extracts text between "failed: " and "\n" func parseDmsetupError(output string) string { lines := strings.SplitN(output, "\n", 2) diff --git a/snapshots/devmapper/pool_device.go b/snapshots/devmapper/pool_device.go index 3af80d338..1bf742944 100644 --- a/snapshots/devmapper/pool_device.go +++ b/snapshots/devmapper/pool_device.go @@ -484,7 +484,9 @@ func (p *PoolDevice) IsLoaded(deviceName string) bool { // GetUsage reports total size in bytes consumed by a thin-device. // It relies on the number of used blocks reported by 'dmsetup status'. // The output looks like: -// device2: 0 204800 thin 17280 204799 +// +// device2: 0 204800 thin 17280 204799 +// // Where 17280 is the number of used sectors func (p *PoolDevice) GetUsage(deviceName string) (int64, error) { status, err := dmsetup.Status(deviceName) diff --git a/snapshots/snapshotter.go b/snapshots/snapshotter.go index c4e2b16be..9da28583b 100644 --- a/snapshots/snapshotter.go +++ b/snapshots/snapshotter.go @@ -153,10 +153,10 @@ type WalkFunc func(context.Context, Info) error // For consistency, we define the following terms to be used throughout this // interface for snapshotter implementations: // -// `ctx` - refers to a context.Context -// `key` - refers to an active snapshot -// `name` - refers to a committed snapshot -// `parent` - refers to the parent in relation +// `ctx` - refers to a context.Context +// `key` - refers to an active snapshot +// `name` - refers to a committed snapshot +// `parent` - refers to the parent in relation // // Most methods take various combinations of these identifiers. Typically, // `name` and `parent` will be used in cases where a method *only* takes @@ -167,7 +167,7 @@ type WalkFunc func(context.Context, Info) error // // We cover several examples below to demonstrate the utility of the snapshotter. // -// Importing a Layer +// # Importing a Layer // // To import a layer, we simply have the snapshotter provide a list of // mounts to be applied such that our dst will capture a changeset. We start @@ -184,7 +184,7 @@ type WalkFunc func(context.Context, Info) error // "containerd.io/gc.root": time.Now().UTC().Format(time.RFC3339), // }) // mounts, err := snapshotter.Prepare(ctx, key, "", noGcOpt) -// if err != nil { ... } +// if err != nil { ... } // // We get back a list of mounts from snapshotter.Prepare(), with the key identifying // the active snapshot. Mount this to the temporary location with the @@ -201,8 +201,8 @@ type WalkFunc func(context.Context, Info) error // // layer, err := os.Open(layerPath) // if err != nil { ... } -// digest, err := unpackLayer(tmpLocation, layer) // unpack into layer location -// if err != nil { ... } +// digest, err := unpackLayer(tmpLocation, layer) // unpack into layer location +// if err != nil { ... } // // When the above completes, we should have a filesystem that represents the // contents of the layer. Careful implementations should verify that digest @@ -220,30 +220,30 @@ type WalkFunc func(context.Context, Info) error // Now, we have a layer in the snapshotter that can be accessed with the digest // provided during commit. // -// Importing the Next Layer +// # Importing the Next Layer // // Making a layer depend on the above is identical to the process described // above except that the parent is provided as parent when calling // snapshotter.Prepare(), assuming a clean, unique key identifier: // -// mounts, err := snapshotter.Prepare(ctx, key, parentDigest, noGcOpt) +// mounts, err := snapshotter.Prepare(ctx, key, parentDigest, noGcOpt) // // We then mount, apply and commit, as we did above. The new snapshot will be // based on the content of the previous one. // -// Running a Container +// # Running a Container // // To run a container, we simply provide snapshotter.Prepare() the committed image // snapshot as the parent. After mounting, the prepared path can // be used directly as the container's filesystem: // -// mounts, err := snapshotter.Prepare(ctx, containerKey, imageRootFSChainID) +// mounts, err := snapshotter.Prepare(ctx, containerKey, imageRootFSChainID) // // The returned mounts can then be passed directly to the container runtime. If // one would like to create a new image from the filesystem, snapshotter.Commit() is // called: // -// if err := snapshotter.Commit(ctx, newImageSnapshot, containerKey); err != nil { ... } +// if err := snapshotter.Commit(ctx, newImageSnapshot, containerKey); err != nil { ... } // // Alternatively, for most container runs, snapshotter.Remove() will be called to // signal the snapshotter to abandon the changes. diff --git a/snapshots/testsuite/testsuite.go b/snapshots/testsuite/testsuite.go index 46776a92a..d62c41496 100644 --- a/snapshots/testsuite/testsuite.go +++ b/snapshots/testsuite/testsuite.go @@ -505,7 +505,7 @@ func checkDeletedFilesInChildSnapshot(ctx context.Context, t *testing.T, snapsho } -//Create three layers. Deleting intermediate layer must fail. +// Create three layers. Deleting intermediate layer must fail. func checkRemoveIntermediateSnapshot(ctx context.Context, t *testing.T, snapshotter snapshots.Snapshotter, work string) { base, err := snapshotterPrepareMount(ctx, snapshotter, "base", "", work) @@ -559,12 +559,13 @@ func checkRemoveIntermediateSnapshot(ctx context.Context, t *testing.T, snapshot // baseTestSnapshots creates a base set of snapshots for tests, each snapshot is empty // Tests snapshots: -// c1 - committed snapshot, no parent -// c2 - committed snapshot, c1 is parent -// a1 - active snapshot, c2 is parent -// a1 - active snapshot, no parent -// v1 - view snapshot, v1 is parent -// v2 - view snapshot, no parent +// +// c1 - committed snapshot, no parent +// c2 - committed snapshot, c1 is parent +// a1 - active snapshot, c2 is parent +// a1 - active snapshot, no parent +// v1 - view snapshot, v1 is parent +// v2 - view snapshot, no parent func baseTestSnapshots(ctx context.Context, snapshotter snapshots.Snapshotter) error { if _, err := snapshotter.Prepare(ctx, "c1-a", "", opt); err != nil { return err