Skip to content

Commit

Permalink
Merge branch 'main' into dev
Browse files Browse the repository at this point in the history
Signed-off-by: zzzzzzzzzy <[email protected]>
  • Loading branch information
zzzzzzzzzy9 committed Jan 16, 2024
2 parents 588398c + a003dac commit 16cbe55
Show file tree
Hide file tree
Showing 70 changed files with 1,153 additions and 674 deletions.
8 changes: 2 additions & 6 deletions .github/workflows/ci-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ jobs:

steps:
- uses: actions/checkout@v4
- uses: arduino/setup-protoc@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- run: ./scripts/install-protobuf.sh
- run: cargo check --examples --tests -p containerd-shim -p containerd-shim-protos

- run: rustup toolchain install nightly --component rustfmt
Expand All @@ -41,9 +39,7 @@ jobs:

steps:
- uses: actions/checkout@v4
- uses: arduino/setup-protoc@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- run: ./scripts/install-protobuf.sh
- name: Tests
run: |
cargo test -p containerd-shim -p containerd-shim-protos
Expand Down
68 changes: 24 additions & 44 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ jobs:

steps:
- uses: actions/checkout@v4
- uses: arduino/setup-protoc@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

- run: ./scripts/install-protobuf.sh

- run: cargo check --examples --tests --all-targets
- run: cargo check --examples --tests --all-targets --all-features

Expand All @@ -30,7 +30,7 @@ jobs:
- run: cargo clippy --all-targets -- -D warnings
- run: cargo clippy --all-targets --all-features -- -D warnings

- run: cargo doc --no-deps
- run: cargo doc --no-deps --features docs
env:
RUSTDOCFLAGS: -Dwarnings

Expand All @@ -45,16 +45,13 @@ jobs:

steps:
- uses: actions/checkout@v4
- uses: arduino/setup-protoc@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- run: ./scripts/install-protobuf.sh
- env:
# runc::tests::test_exec needs $XDG_RUNTIME_DIR to be set
XDG_RUNTIME_DIR: /tmp/dummy-xdr
run: |
# runc-shim::cgroup::test_add_cgroup needs root permission to set cgroup
mkdir -p /tmp/dummy-xdr
export PROTOC=$(which protoc)
sudo -E $(command -v cargo) test
sudo -E $(command -v cargo) test --all-features
Expand All @@ -67,13 +64,11 @@ jobs:

steps:
- uses: actions/checkout@v4
- uses: arduino/setup-protoc@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- run: ./scripts/install-protobuf.sh
- run: cargo build --all-features --timings
- uses: actions/upload-artifact@v3
with:
name: cargo-timing
name: timings
path: target/cargo-timings/cargo-timing.html
if-no-files-found: error

Expand All @@ -94,44 +89,34 @@ jobs:
strategy:
matrix:
os: [ubuntu-20.04, ubuntu-22.04]
containerd: [v1.6.21, v1.7.1]
containerd: [v1.6.24, v1.7.6]

steps:
- name: Checkout extensions
uses: actions/checkout@v4

- name: Download containerd archive
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release download ${{ matrix.containerd }} \
--repo containerd/containerd \
--pattern 'containerd-1.*-linux-amd64.tar.gz' \
--output containerd.tar.gz
- name: Extract containerd binaries to $HOME/.local/bin
run: |
mkdir -p $HOME/.local/bin
echo "$HOME/.local/bin" >> $GITHUB_PATH
tar -xf containerd.tar.gz -C $HOME/.local
- name: Checkout containerd
uses: actions/checkout@v4
with:
repository: containerd/containerd
path: src/github.com/containerd/containerd
ref: ${{ matrix.containerd }}

- name: Get Go Version
run: |
go_version=$(awk -F': ' '/GO_VERSION/ {gsub(/["'\'']/, "", $2); print $2; exit}' .github/workflows/release.yml)
echo "GO_VERSION=$go_version" >> $GITHUB_ENV
working-directory: src/github.com/containerd/containerd

- uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}

- name: Install containerd
env:
GOFLAGS: -modcacherw
CGO_ENABLED: 1
run: |
# Install containerd dependencies first
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}')
# Install containerd
sudo -E PATH=$PATH make bin/containerd GO_BUILD_FLAGS="-mod=vendor" BUILDTAGS="no_btrfs no_devmapper"
sudo -E PATH=$PATH install bin/containerd /usr/local/bin/
working-directory: src/github.com/containerd/containerd

- name: Install shim
run: |
cargo build --release --bin containerd-shim-runc-v2-rs
Expand All @@ -147,13 +132,8 @@ jobs:
GOPROXY: direct
TEST_RUNTIME: "io.containerd.runc.v2-rs"
TESTFLAGS_PARALLEL: 1
EXTRA_TESTFLAGS: "-no-criu -test.skip='(TestContainerPTY|TestContainerExecLargeOutputWithTTY)'"
EXTRA_TESTFLAGS: "-no-criu -test.skip='(TestContainerPTY|TestContainerExecLargeOutputWithTTY|TestTaskUpdate|TestTaskResize|TestContainerAttach|TestContainerAttachProcess)'"
TESTFLAGS_RACE: "-race"
run: |
# https://github.com/containerd/rust-extensions/issues/147#issuecomment-1684553369
cd integration/client
sudo -E PATH=$PATH go mod edit -dropreplace github.com/AdaLogics/go-fuzz-headers
sudo -E PATH=$PATH go get -u github.com/AdaLogics/go-fuzz-headers
cd ../..
sudo -E PATH=$PATH make integration
working-directory: src/github.com/containerd/containerd
70 changes: 70 additions & 0 deletions .github/workflows/cover.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Coverage
on:
pull_request_target:

jobs:
coverage:
name: Collect
runs-on: ubuntu-latest
timeout-minutes: 15

permissions:
statuses: write

steps:
- uses: actions/checkout@v4

- run: |
sudo apt-get install protobuf-compiler
- name: Install grcov
run: |
cargo install grcov
grcov --version
- name: Tests
env:
RUSTFLAGS: "-Cinstrument-coverage"
LLVM_PROFILE_FILE: "target/coverage/%p-%m.profraw"
run: |
sudo -E $(command -v cargo) test --all-features
# Fix permissions after sudo.
sudo chown -R $(whoami) target/coverage/
- name: Collect coverage data
run: |
grcov . \
--source-dir . \
--binary-path ./target/debug/ \
--branch --ignore-not-existing \
--output-types html,markdown \
--keep-only 'crates/*' \
--output-path ./target/coverage/
- uses: actions/upload-artifact@v3
with:
name: coverage
path: target/coverage/html/
if-no-files-found: error

- name: Publish job summary
run: |
echo "# Coverage" >> $GITHUB_STEP_SUMMARY
cat target/coverage/markdown.md >> $GITHUB_STEP_SUMMARY
- run: echo "coverage=$(cat target/coverage/markdown.md | grep 'Total coverage')" >> $GITHUB_OUTPUT
id: coverage

- name: Create commit status
uses: actions/github-script@v6
if: success()
with:
script: |
github.rest.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
sha: context.sha,
state: 'success',
description: '${{ steps.coverage.outputs.coverage }}',
})
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
- name: Publish on crates.io
run: cargo publish $DRYRUN --manifest-path $CARGO_FILE
env:
DRYRUN: ${{ inputs.dryrun && '--dry-run' }}
DRYRUN: ${{ inputs.dryrun && '--dry-run' || '' }}
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

- name: Push version tag
Expand Down
37 changes: 22 additions & 15 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[workspace]
members = [
"crates/client",
"crates/logging",
"crates/shim-protos",
"crates/shim",
"crates/snapshots",
"crates/runc",
"crates/runc-shim",
"crates/client",
"crates/logging",
"crates/runc",
"crates/runc-shim",
"crates/shim",
"crates/shim-protos",
"crates/snapshots",
]

[profile.release]
Expand All @@ -24,14 +24,21 @@ edition = "2021"

# Common dependencies for all crates
[workspace.dependencies]
async-trait = "0.1.52"
futures = "0.3.19"
libc = "0.2.112"
log = {version = "0.4.2", features=["kv_unstable"]}
nix = "0.27"
oci-spec = "0.6"
os_pipe = "1.1"
prost = "0.12"
prost-types = "0.12"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
thiserror = "1.0"
time = { version = "0.3.29", features = ["serde", "std", "formatting"] }
tokio = "1.26"
tower = "0.4"

tonic = "0.10"
tonic-build = "0.10"

prost = "0.12"
prost-types = "0.12"

async-trait = "0.1.52"
futures = "0.3.19"
tower = "0.4"
uuid = { version = "1.0", features = ["v4"] }
18 changes: 15 additions & 3 deletions crates/client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
name = "containerd-client"
version = "0.4.0"
authors = [
"Maksym Pavlenko <[email protected]>",
"The containerd Authors",
"Maksym Pavlenko <[email protected]>",
"The containerd Authors",
]
description = "GRPC bindings to containerd APIs"
keywords = ["containerd", "client", "grpc", "containers"]
Expand All @@ -14,21 +14,33 @@ license.workspace = true
repository.workspace = true
homepage.workspace = true

[[example]]
name = "container"
path = "examples/container.rs"

[[example]]
name = "version"
path = "examples/version.rs"

[dependencies]
tonic.workspace = true
prost.workspace = true
prost-types.workspace = true
tokio = { workspace = true, optional = true }
tonic.workspace = true
tower = { workspace = true, optional = true }

[build-dependencies]
tonic-build.workspace = true

[features]
connect = ["tokio", "tower"]
docs = []

# Technically Tonic doesn't require Tokio and Tower dependencies here.
# However we need them to implement `connect` helper and it's highly unlikely
# that Tonic will be used with any other async runtime (see https://github.com/hyperium/tonic/issues/152)
# So we enable `connect` feature by default (use `--no-default-features` otherwise).
default = ["connect"]

[package.metadata.docs.rs]
features = ["docs"]
14 changes: 9 additions & 5 deletions crates/client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@ This crate implements a GRPC client to query containerd APIs.
## Example

```rust
// Launch containerd at /run/containerd/containerd.sock
let channel = connect("/run/containerd/containerd.sock").await?;
use containerd_client::{connect, services::v1::version_client::VersionClient};

let mut client = VersionClient::new(channel);
let resp = client.version(()).await?;
async fn query_version() {
// Launch containerd at /run/containerd/containerd.sock
let channel = connect("/run/containerd/containerd.sock").await.unwrap();

println!("Response: {:?}", resp.get_ref());
let mut client = VersionClient::new(channel);
let resp = client.version(()).await.unwrap();

println!("Response: {:?}", resp.get_ref());
}
```
9 changes: 8 additions & 1 deletion crates/client/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ const PROTO_FILES: &[&str] = &[
"vendor/github.com/containerd/containerd/api/types/platform.proto",
"vendor/github.com/containerd/containerd/api/types/sandbox.proto",
"vendor/github.com/containerd/containerd/api/types/task/task.proto",
"vendor/github.com/containerd/containerd/api/types/transfer/imagestore.proto",
"vendor/github.com/containerd/containerd/api/types/transfer/importexport.proto",
"vendor/github.com/containerd/containerd/api/types/transfer/progress.proto",
"vendor/github.com/containerd/containerd/api/types/transfer/registry.proto",
"vendor/github.com/containerd/containerd/api/types/transfer/streaming.proto",
// Services
"vendor/github.com/containerd/containerd/api/services/containers/v1/containers.proto",
"vendor/github.com/containerd/containerd/api/services/content/v1/content.proto",
Expand All @@ -35,8 +40,10 @@ const PROTO_FILES: &[&str] = &[
"vendor/github.com/containerd/containerd/api/services/namespaces/v1/namespace.proto",
"vendor/github.com/containerd/containerd/api/services/sandbox/v1/sandbox.proto",
"vendor/github.com/containerd/containerd/api/services/snapshots/v1/snapshots.proto",
"vendor/github.com/containerd/containerd/api/services/version/v1/version.proto",
"vendor/github.com/containerd/containerd/api/services/streaming/v1/streaming.proto",
"vendor/github.com/containerd/containerd/api/services/tasks/v1/tasks.proto",
"vendor/github.com/containerd/containerd/api/services/transfer/v1/transfer.proto",
"vendor/github.com/containerd/containerd/api/services/version/v1/version.proto",
// Events
"vendor/github.com/containerd/containerd/api/events/container.proto",
"vendor/github.com/containerd/containerd/api/events/content.proto",
Expand Down
Loading

0 comments on commit 16cbe55

Please sign in to comment.