Skip to content

Commit

Permalink
Merge pull request #2975 from bergwolf/2.2.3-branch-bump
Browse files Browse the repository at this point in the history
# Kata Containers 2.2.3
  • Loading branch information
amshinde authored Nov 5, 2021
2 parents 63ecbcf + b7493fd commit 3a1804c
Show file tree
Hide file tree
Showing 18 changed files with 72 additions and 21 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.2.2
2.2.3
2 changes: 1 addition & 1 deletion docs/how-to/how-to-use-kata-containers-with-acrn.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ This document requires the presence of the ACRN hypervisor and Kata Containers o

- ACRN supported [Hardware](https://projectacrn.github.io/latest/hardware.html#supported-hardware).
> **Note:** Please make sure to have a minimum of 4 logical processors (HT) or cores.
- ACRN [software](https://projectacrn.github.io/latest/tutorials/kbl-nuc-sdc.html#use-the-script-to-set-up-acrn-automatically) setup.
- ACRN [software](https://projectacrn.github.io/latest/tutorials/run_kata_containers.html) setup.
- For networking, ACRN supports either MACVTAP or TAP. If MACVTAP is not enabled in the Service OS, please follow the below steps to update the kernel:

```sh
Expand Down
1 change: 1 addition & 0 deletions src/agent/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/agent/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ scan_fmt = "0.2.3"
scopeguard = "1.0.0"
thiserror = "1.0.26"
regex = "1"
serial_test = "0.5.1"

# Async helpers
async-trait = "0.1.42"
Expand Down
1 change: 1 addition & 0 deletions src/agent/src/linux_abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ pub const SYSTEM_DEV_PATH: &str = "/dev";
// Linux UEvent related consts.
pub const U_EVENT_ACTION: &str = "ACTION";
pub const U_EVENT_ACTION_ADD: &str = "add";
pub const U_EVENT_ACTION_REMOVE: &str = "remove";
pub const U_EVENT_DEV_PATH: &str = "DEVPATH";
pub const U_EVENT_SUB_SYSTEM: &str = "SUBSYSTEM";
pub const U_EVENT_SEQ_NUM: &str = "SEQNUM";
Expand Down
12 changes: 12 additions & 0 deletions src/agent/src/sandbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,10 @@ mod tests {
baremount.mount()
}

use serial_test::serial;

#[tokio::test]
#[serial]
async fn set_sandbox_storage() {
let logger = slog::Logger::root(slog::Discard, o!());
let mut s = Sandbox::new(&logger).unwrap();
Expand Down Expand Up @@ -500,6 +503,7 @@ mod tests {
}

#[tokio::test]
#[serial]
async fn remove_sandbox_storage() {
skip_if_not_root!();

Expand Down Expand Up @@ -556,6 +560,7 @@ mod tests {
}

#[tokio::test]
#[serial]
async fn unset_and_remove_sandbox_storage() {
skip_if_not_root!();

Expand Down Expand Up @@ -607,6 +612,7 @@ mod tests {
}

#[tokio::test]
#[serial]
async fn unset_sandbox_storage() {
let logger = slog::Logger::root(slog::Discard, o!());
let mut s = Sandbox::new(&logger).unwrap();
Expand Down Expand Up @@ -690,6 +696,7 @@ mod tests {
}

#[tokio::test]
#[serial]
async fn get_container_entry_exist() {
skip_if_not_root!();
let logger = slog::Logger::root(slog::Discard, o!());
Expand All @@ -703,6 +710,7 @@ mod tests {
}

#[tokio::test]
#[serial]
async fn get_container_no_entry() {
let logger = slog::Logger::root(slog::Discard, o!());
let mut s = Sandbox::new(&logger).unwrap();
Expand All @@ -712,6 +720,7 @@ mod tests {
}

#[tokio::test]
#[serial]
async fn add_and_get_container() {
skip_if_not_root!();
let logger = slog::Logger::root(slog::Discard, o!());
Expand All @@ -723,6 +732,7 @@ mod tests {
}

#[tokio::test]
#[serial]
async fn update_shared_pidns() {
skip_if_not_root!();
let logger = slog::Logger::root(slog::Discard, o!());
Expand All @@ -741,6 +751,7 @@ mod tests {
}

#[tokio::test]
#[serial]
async fn add_guest_hooks() {
let logger = slog::Logger::root(slog::Discard, o!());
let mut s = Sandbox::new(&logger).unwrap();
Expand All @@ -764,6 +775,7 @@ mod tests {
}

#[tokio::test]
#[serial]
async fn test_sandbox_set_destroy() {
let logger = slog::Logger::root(slog::Discard, o!());
let mut s = Sandbox::new(&logger).unwrap();
Expand Down
8 changes: 8 additions & 0 deletions src/agent/src/uevent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,18 @@ impl Uevent {
})
}

#[instrument]
async fn process_remove(&self, logger: &Logger, sandbox: &Arc<Mutex<Sandbox>>) {
let mut sb = sandbox.lock().await;
sb.uevent_map.remove(&self.devpath);
}

#[instrument]
async fn process(&self, logger: &Logger, sandbox: &Arc<Mutex<Sandbox>>) {
if self.action == U_EVENT_ACTION_ADD {
return self.process_add(logger, sandbox).await;
} else if self.action == U_EVENT_ACTION_REMOVE {
return self.process_remove(logger, sandbox).await;
}
debug!(*logger, "ignoring event"; "uevent" => format!("{:?}", self));
}
Expand Down
5 changes: 5 additions & 0 deletions src/agent/src/watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,10 @@ mod tests {
);
}

use serial_test::serial;

#[tokio::test]
#[serial]
async fn create_tmpfs() {
skip_if_not_root!();

Expand All @@ -997,6 +1000,7 @@ mod tests {
}

#[tokio::test]
#[serial]
async fn spawn_thread() {
skip_if_not_root!();

Expand Down Expand Up @@ -1026,6 +1030,7 @@ mod tests {
}

#[tokio::test]
#[serial]
async fn verify_container_cleanup_watching() {
skip_if_not_root!();

Expand Down
9 changes: 8 additions & 1 deletion src/runtime/pkg/katatestutils/constraints.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,15 @@ func getDistroDetails() (name, version string, err error) {
// centos: 3.10.0-957.12.1.el7.x86_64
// fedora: 5.0.9-200.fc29.x86_64
//
// For some self compiled kernel, the kernel version will be with "+" as its suffix
// For example:
// 5.12.0-rc4+
// These kernel version can't be parsed by the current lib and lead to panic
// therefore the '+' should be removed.
//
func fixKernelVersion(version string) string {
return strings.Replace(version, "_", "-", -1)
version = strings.Replace(version, "_", "-", -1)
return strings.Replace(version, "+", "", -1)
}

// handleDistroName checks that the current distro is compatible with
Expand Down
17 changes: 15 additions & 2 deletions src/runtime/pkg/katautils/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,11 +307,24 @@ func (h hypervisor) GetEntropySource() string {
return h.EntropySource
}

// Current cpu number should not larger than defaultMaxVCPUs()
func getCurrentCpuNum() uint32 {
var cpu uint32
h := hypervisor{}

cpu = uint32(goruntime.NumCPU())
if cpu > h.defaultMaxVCPUs() {
cpu = h.defaultMaxVCPUs()
}

return cpu
}

func (h hypervisor) defaultVCPUs() uint32 {
numCPUs := goruntime.NumCPU()
numCPUs := getCurrentCpuNum()

if h.NumVCPUs < 0 || h.NumVCPUs > int32(numCPUs) {
return uint32(numCPUs)
return numCPUs
}
if h.NumVCPUs == 0 { // or unspecified
return defaultVCPUCount
Expand Down
17 changes: 8 additions & 9 deletions src/runtime/pkg/katautils/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"path"
"path/filepath"
"reflect"
goruntime "runtime"
"strings"
"syscall"
"testing"
Expand Down Expand Up @@ -156,7 +155,7 @@ func createAllRuntimeConfigFiles(dir, hypervisor string) (config testRuntimeConf
KernelParams: vc.DeserializeParams(strings.Fields(kernelParams)),
HypervisorMachineType: machineType,
NumVCPUs: defaultVCPUCount,
DefaultMaxVCPUs: uint32(goruntime.NumCPU()),
DefaultMaxVCPUs: getCurrentCpuNum(),
MemorySize: defaultMemSize,
DisableBlockDeviceUse: disableBlockDevice,
BlockDeviceDriver: defaultBlockDeviceDriver,
Expand Down Expand Up @@ -919,13 +918,13 @@ func TestNewClhHypervisorConfig(t *testing.T) {
func TestHypervisorDefaults(t *testing.T) {
assert := assert.New(t)

numCPUs := goruntime.NumCPU()
numCPUs := getCurrentCpuNum()

h := hypervisor{}

assert.Equal(h.machineType(), defaultMachineType, "default hypervisor machine type wrong")
assert.Equal(h.defaultVCPUs(), defaultVCPUCount, "default vCPU number is wrong")
assert.Equal(h.defaultMaxVCPUs(), uint32(numCPUs), "default max vCPU number is wrong")
assert.Equal(h.defaultMaxVCPUs(), numCPUs, "default max vCPU number is wrong")
assert.Equal(h.defaultMemSz(), defaultMemSize, "default memory size is wrong")

machineType := "foo"
Expand All @@ -934,23 +933,23 @@ func TestHypervisorDefaults(t *testing.T) {

// auto inferring
h.NumVCPUs = -1
assert.Equal(h.defaultVCPUs(), uint32(numCPUs), "default vCPU number is wrong")
assert.Equal(h.defaultVCPUs(), numCPUs, "default vCPU number is wrong")

h.NumVCPUs = 2
assert.Equal(h.defaultVCPUs(), uint32(2), "default vCPU number is wrong")

h.NumVCPUs = int32(numCPUs) + 1
assert.Equal(h.defaultVCPUs(), uint32(numCPUs), "default vCPU number is wrong")
assert.Equal(h.defaultVCPUs(), numCPUs, "default vCPU number is wrong")

h.DefaultMaxVCPUs = 2
assert.Equal(h.defaultMaxVCPUs(), uint32(2), "default max vCPU number is wrong")

h.DefaultMaxVCPUs = uint32(numCPUs) + 1
assert.Equal(h.defaultMaxVCPUs(), uint32(numCPUs), "default max vCPU number is wrong")
h.DefaultMaxVCPUs = numCPUs + 1
assert.Equal(h.defaultMaxVCPUs(), numCPUs, "default max vCPU number is wrong")

maxvcpus := vc.MaxQemuVCPUs()
h.DefaultMaxVCPUs = maxvcpus + 1
assert.Equal(h.defaultMaxVCPUs(), uint32(numCPUs), "default max vCPU number is wrong")
assert.Equal(h.defaultMaxVCPUs(), numCPUs, "default max vCPU number is wrong")

h.MemorySize = 1024
assert.Equal(h.defaultMemSz(), uint32(1024), "default memory size is wrong")
Expand Down
4 changes: 3 additions & 1 deletion src/runtime/virtcontainers/factory/template/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"context"
"fmt"
"os"
"runtime"
"testing"
"time"

Expand All @@ -22,7 +23,8 @@ import (
const testDisabledAsNonRoot = "Test disabled as requires root privileges"

func TestTemplateFactory(t *testing.T) {
if os.Geteuid() != 0 {
// template is broken on arm64, so, temporarily disable it on arm64
if runtime.GOARCH == "arm64" || os.Geteuid() != 0 {
t.Skip(testDisabledAsNonRoot)
}

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/virtcontainers/hypervisor.go
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ func (conf *HypervisorConfig) valid() error {
conf.BlockDeviceDriver = config.VirtioBlockCCW
}

if conf.DefaultMaxVCPUs == 0 {
if conf.DefaultMaxVCPUs == 0 || conf.DefaultMaxVCPUs > defaultMaxQemuVCPUs {
conf.DefaultMaxVCPUs = defaultMaxQemuVCPUs
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ spec:
katacontainers.io/kata-runtime: cleanup
containers:
- name: kube-kata-cleanup
image: quay.io/kata-containers/kata-deploy:2.2.2
image: quay.io/kata-containers/kata-deploy:2.2.3
imagePullPolicy: Always
command: [ "bash", "-c", "/opt/kata-artifacts/scripts/kata-deploy.sh reset" ]
env:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ spec:
serviceAccountName: kata-label-node
containers:
- name: kube-kata
image: quay.io/kata-containers/kata-deploy:2.2.2
image: quay.io/kata-containers/kata-deploy:2.2.3
imagePullPolicy: Always
lifecycle:
preStop:
Expand Down
4 changes: 3 additions & 1 deletion tools/packaging/static-build/kernel/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ RUN apt install -y \
flex \
git \
iptables \
libelf-dev \
libelf-dev

RUN [ "$(uname -m)" = "s390x" ] && apt-get install -y libssl-dev || true
1 change: 0 additions & 1 deletion tools/packaging/static-build/qemu.blacklist
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ qemu_black_list=(
*/share/*/efi-rtl8139.rom
*/share/*/efi-vmxnet3.rom
*/share/*/icons
*/share/*/*.img
*/share/*/keymaps
*/share/*/multiboot.bin
*/share/*/npcm7xx_bootrom.bin
Expand Down
3 changes: 2 additions & 1 deletion tools/packaging/static-build/qemu/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ RUN apt-get --no-install-recommends install -y \
libltdl-dev \
libmount-dev \
libpixman-1-dev \
libpmem-dev \
libselinux1-dev \
libtool \
make \
Expand All @@ -49,6 +48,8 @@ RUN apt-get --no-install-recommends install -y \
rsync \
zlib1g-dev

RUN [ "$(uname -m)" != "s390x" ] && apt-get install -y libpmem-dev || true

ARG QEMU_REPO

RUN cd .. && git clone "${QEMU_REPO}" qemu
Expand Down

0 comments on commit 3a1804c

Please sign in to comment.