-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #139 from jsturtevant/windows
Windows support for the synchronous shim
- Loading branch information
Showing
18 changed files
with
987 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
name: CI-windows | ||
on: | ||
pull_request: | ||
push: | ||
schedule: | ||
- cron: '0 0 * * *' # Every day at midnight | ||
|
||
jobs: | ||
checks: | ||
name: Checks | ||
runs-on: ${{ matrix.os }} | ||
timeout-minutes: 20 | ||
|
||
strategy: | ||
matrix: | ||
os: [windows-latest] | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: arduino/setup-protoc@v1 | ||
with: | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
- run: cargo check --examples --tests -p containerd-shim -p containerd-shim-protos | ||
|
||
- run: rustup toolchain install nightly --component rustfmt | ||
- run: cargo +nightly fmt -p containerd-shim -p containerd-shim-protos -- --check --files-with-diff | ||
|
||
- run: cargo clippy -p containerd-shim -p containerd-shim-protos -- -D warnings | ||
- run: cargo doc --no-deps -p containerd-shim -p containerd-shim-protos | ||
env: | ||
RUSTDOCFLAGS: -Dwarnings | ||
|
||
tests: | ||
name: Tests | ||
runs-on: ${{ matrix.os }} | ||
timeout-minutes: 15 | ||
|
||
strategy: | ||
matrix: | ||
os: [windows-latest] | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: arduino/setup-protoc@v1 | ||
with: | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Tests | ||
run: | | ||
cargo test -p containerd-shim -p containerd-shim-protos | ||
integration: | ||
name: Integration | ||
runs-on: ${{ matrix.os }} | ||
timeout-minutes: 40 | ||
|
||
strategy: | ||
matrix: | ||
os: [windows-latest] | ||
containerd: [1.7.0] | ||
|
||
steps: | ||
- name: Checkout extensions | ||
uses: actions/checkout@v3 | ||
|
||
- name: Install containerd | ||
run: | | ||
$ErrorActionPreference = "Stop" | ||
# Install containerd https://github.com/containerd/containerd/blob/v1.7.0/docs/getting-started.md#installing-containerd-on-windows | ||
# Download and extract desired containerd Windows binaries | ||
curl.exe -L https://github.com/containerd/containerd/releases/download/v${{ matrix.containerd }}/containerd-${{ matrix.containerd }}-windows-amd64.tar.gz -o containerd-windows-amd64.tar.gz | ||
tar.exe xvf .\containerd-windows-amd64.tar.gz | ||
# Copy and configure | ||
mkdir "$Env:ProgramFiles\containerd" | ||
Copy-Item -Path ".\bin\*" -Destination "$Env:ProgramFiles\containerd" -Recurse -Force | ||
cd $Env:ProgramFiles\containerd\ | ||
.\containerd.exe config default | Out-File config.toml -Encoding ascii | ||
# Review the configuration. Depending on setup you may want to adjust: | ||
# - the sandbox_image (Kubernetes pause image) | ||
# - cni bin_dir and conf_dir locations | ||
Get-Content config.toml | ||
# Register and start service | ||
.\containerd.exe --register-service | ||
Start-Service containerd | ||
working-directory: ${{ runner.temp }} | ||
- name: Run integration test | ||
run: | | ||
$ErrorActionPreference = "Stop" | ||
get-service containerd | ||
$env:TTRPC_ADDRESS="\\.\pipe\containerd-containerd.ttrpc" | ||
# run the example | ||
cargo run --example skeleton -- -namespace default -id 1234 -address "\\.\pipe\containerd-containerd" -publish-binary ./bin/containerd start | ||
ps skeleton | ||
cargo run --example shim-proto-connect \\.\pipe\containerd-shim-17630016127144989388-pipe | ||
$skeleton = get-process skeleton -ErrorAction SilentlyContinue | ||
if ($skeleton) { exit 1 } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,5 @@ Cargo.lock | |
# These are backup files generated by rustfmt | ||
**/*.rs.bk | ||
log | ||
|
||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
Copyright The containerd Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
#[cfg(windows)] | ||
use std::error::Error; | ||
|
||
#[cfg(windows)] | ||
fn main() -> Result<(), Box<dyn Error>> { | ||
use std::{ | ||
env, | ||
fs::OpenOptions, | ||
os::windows::{ | ||
fs::OpenOptionsExt, | ||
io::{FromRawHandle, IntoRawHandle}, | ||
}, | ||
time::Duration, | ||
}; | ||
|
||
use mio::{windows::NamedPipe, Events, Interest, Poll, Token}; | ||
use windows_sys::Win32::Storage::FileSystem::FILE_FLAG_OVERLAPPED; | ||
|
||
let args: Vec<String> = env::args().collect(); | ||
|
||
let address = args | ||
.get(1) | ||
.ok_or("First argument must be shims address to read logs (\\\\.\\pipe\\containerd-shim-{ns}-{id}-log) ") | ||
.unwrap(); | ||
|
||
println!("Reading logs from: {}", &address); | ||
|
||
let mut opts = OpenOptions::new(); | ||
opts.read(true) | ||
.write(true) | ||
.custom_flags(FILE_FLAG_OVERLAPPED); | ||
let file = opts.open(address).unwrap(); | ||
let mut client = unsafe { NamedPipe::from_raw_handle(file.into_raw_handle()) }; | ||
|
||
let mut stdio = std::io::stdout(); | ||
let mut poll = Poll::new().unwrap(); | ||
poll.registry() | ||
.register(&mut client, Token(1), Interest::READABLE) | ||
.unwrap(); | ||
let mut events = Events::with_capacity(128); | ||
loop { | ||
poll.poll(&mut events, Some(Duration::from_millis(10))) | ||
.unwrap(); | ||
match std::io::copy(&mut client, &mut stdio) { | ||
Ok(_) => break, | ||
Err(_) => continue, | ||
} | ||
} | ||
|
||
Ok(()) | ||
} | ||
|
||
#[cfg(unix)] | ||
fn main() { | ||
println!("This example is only for Windows"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.