Commit Graph

16038 Commits

Author SHA1 Message Date
Wainer dos Santos Moschetta
8c4637d629 tests/k8s: print tests report
Added 'report-tests' command to gha-run.sh to print to stdout a report
of the tests executed.

For example:
```
SUMMARY (2025-02-17-14:43:53):
 Pass:  0
 Fail:  1

STATUSES:
 not_ok foo.bats

OUTPUTS:
::group::foo.bats
1..3
not ok 1 test 1
not ok 2 test 2
ok 3 test 3
1..2
not ok 1 test 1
not ok 2 test 2
::endgroup::
```

Signed-off-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
2025-05-20 14:43:38 -03:00
Wainer dos Santos Moschetta
5e3b8a019a tests/k8s: split and save bats outputs in files
Currently run_kubernetes_tests.sh sends all the bats outputs to stdout
which can be very difficult to browse to find a problem, mainly on
CI. With this change, each bats execution have its output sent to
'reports/yyy-mm-dd-hh:mm:ss/<status>-<bats file>.log' where <status>
is either 'ok' (tests passed) or 'not_ok' (some tests failed).

Signed-off-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
2025-05-20 14:43:38 -03:00
Steve Horsman
f8c5aa6df6
Merge pull request #11259 from fitzthum/bump-gc-0140
Update Trustee and Guest Components for CoCo v0.14.0
2025-05-20 18:05:17 +01:00
Lukáš Doktor
c203d7eba6
ci.ocp: Set peer-pods-azure license
We forgot to add the license header when introducing this test.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
2025-05-20 17:03:48 +02:00
Steve Horsman
b4aa1e3fbd
Merge pull request #11279 from skazi0/repo-components
osbuilder: ubuntu: Add REPO_COMPONENTS setting
2025-05-20 16:03:48 +01:00
Lukáš Doktor
b97b20295b
ci.ocp: Make peer-pods setup executable
set permissions of the peer-pods-azure.sh script to executable

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
2025-05-20 17:03:48 +02:00
Sumedh Alok Sharma
9a4432d197
Merge pull request #11233 from Ankita13-code/ankitapareek/execprocess-additional-input-validation
genpolicy: validate input process fields for ExecProcessRequest
2025-05-20 20:11:41 +05:30
Jacek Tomasiak
91fb4353f6
osbuilder: ubuntu: Add REPO_COMPONENTS setting
Added variable REPO_COMPONENTS (default: "main") which sets components
used by mmdebstrap for rootfs building.
This is useful for custom image builders who want to include EXTRA_PKGS
from components other than the default "main" (e.g. "universe").

Fixes: #11278
Signed-off-by: Jacek Tomasiak <jtomasiak@arista.com>
Signed-off-by: Jacek Tomasiak <jacek.tomasiak@gmail.com>
2025-05-20 14:01:48 +02:00
Fabiano Fidêncio
29099d139b
Merge pull request #11280 from kata-containers/dependabot/cargo/src/tools/kata-ctl/ring-0.17.14
build(deps): bump ring from 0.17.5 to 0.17.14 in /src/tools/kata-ctl
2025-05-20 13:47:22 +02:00
Fabiano Fidêncio
0bc0623037
Merge pull request #11277 from skazi0/repo-url
osbuilder: ubuntu: Expose REPO_URL variables
2025-05-20 13:46:01 +02:00
Ankita Pareek
ad75595dc8 genpolicy: Add tests for various input validations for ExecProcessRequest
These additional tests cover edge cases specific to-
- Terminal validation
- Capabilities validation
- Working directory (Cwd) validation
- NoNewPrivileges validation
- User validation
- Environment variables validation

Signed-off-by: Ankita Pareek <ankitapareek@microsoft.com>
2025-05-20 11:19:55 +00:00
Saul Paredes
1e466bf39c genpolicy: fix validation of env variables sourced from metadata.namespace
Use $(sandbox-namespace) wildcard in case none is specified in yaml. If wildcard is present, compare
input against annotation value.

Fixes regression introduced in https://github.com/microsoft/kata-containers/pull/273
where samples that use metadata.namespace env var were no longer working.

Signed-off-by: Saul Paredes <saulparedes@microsoft.com>
2025-05-20 11:19:46 +00:00
Dan Mihai
a113b9eefd genpolicy: validate probe process fields
Validate more process fields for k8s probe commands - e.g.,
livenessProbe, readinessProbe, etc.

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
2025-05-20 11:15:30 +00:00
Dan Mihai
c0b8c6ed5e genpolicy: validate process for commands from settings
Validate more process fields for commands enabled using the
ExecProcessRequest "commands" and/or "regex" fields from the
settings file.
Add function to get the container from state based on container_id
matching instead of matching it against every policy container data

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
Signed-off-by: Ankita Pareek <ankitapareek@microsoft.com>
2025-05-20 11:15:30 +00:00
Dan Mihai
6f78aaa411 genpolicy: use process inputs for allow_process()
Using process data inputs for allow_process() is easier to
read/understand compared with the older OCI data inputs.

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
2025-05-20 11:15:30 +00:00
Steve Horsman
2871c31162
Merge pull request #11273 from mythi/tdx-qemu-params
config: update QEMU TDX configuration
2025-05-20 10:22:59 +01:00
Steve Horsman
4b317dddfa
Merge pull request #11271 from stevenhorsman/gatekeeper-truncate-names
ci: gatekeeper: Require names update
2025-05-20 10:20:05 +01:00
alex.lyn
4b27ca9233 runtime-rs: Implement volume copy allowlist check
For security reasons, we have restricted directory copying.

Introduces the `is_allowlisted_copy_volume` function to verify
if a given volume path is present in an allowed copy directory.
This enhances security by ensuring only permitted volumes are
copied

Currently, only directories under the path
`/var/lib/kubelet/pods/<uid>/volumes/{kubernetes.io~configmap,
kubernetes.io~secret, kubernetes.io~downward-api,
kubernetes.io~projected}` are allowed to be copied into the
guest. Copying of other directories will be prohibited.

Fixes #11237

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2025-05-20 16:57:10 +08:00
alex.lyn
8910bddce8 kata-types: Introduce k8s special volumes for projected and downward-api
Fixes #11237

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2025-05-20 16:55:49 +08:00
alex.lyn
6fa409df1a kata-agent: Improve file sync handling and address symlink issues
When synchronizing file changes on the host, a "symlink AlreadyExists"
issue occurs, primarily due to improper handling of symbolic links
(symlinks). Additionally, there are other related problems.

This patch will try to address these problems.
(1) Handle symlink target existence (files, dirs, symlinks) during host file
    sync. Use appropriate removal methods (unlink, remove_file, remove_dir_all).
(2) Enhance temporary file handling for safer operations and implement truncate
    only at offset 0 for resume support.
(3) Set permissions and ownership for parent directories.
(4) Check and clean target path for regular files before rename.

Fixes #11237

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2025-05-20 16:55:49 +08:00
alex.lyn
654e6db91f runtime-rs: Add inotify-based real-time directory synchronization
Introduce event-driven file sync mechanism between host and guest when
sharedfs is disabled, which will help monitor the host path in time and
do sync files changes:

1. Introduce FsWatcher to monitor directory changes via inotify;
2. Support recursive watching with configurable filters;
3. Add debounce logic (default 500ms cooldown) to handle burst events;
4. Trigger `copy_dir_recursively` on stable state;
5. Handle CREATE/MODIFY/DELETE/MOVED/CLOSE_WRITE events;

Fixes #11237

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2025-05-20 16:55:49 +08:00
alex.lyn
79b832b2f5 runtime-rs: Propagate k8s configs correctly when sharedfs is disabled
In Kubernetes (k8s), while Kata Pods often use virtiofs for injecting
Service Accounts, Secrets, and ConfigMaps, security-sensitive
environments like CoCo disable host-guest sharing. Consequently, when
SharedFs is disabled, we propagate these configurations into the guest
via file copy and bind mount for correct container access.

Fixes #11237

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2025-05-20 16:55:49 +08:00
alex.lyn
8da7cd1611 runtime-rs: Impl recursive directory copy with metadata preservation
Add async directory traversal using BFS algorithm:
(1) Support file type handling:
Regular files (S_IFREG) with content streaming;
Directories (S_IFDIR) with mode preservation;
Symbolic links (S_IFLNK) with target recreation;
(2) Maintain POSIX metadata:
UID/GID preservation,File mode bits, and Directory permissions
(3) Implement async I/O operations for:
Directory enumeration, file reading, symlink target resolution

Fixes #11237

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2025-05-20 16:55:49 +08:00
alex.lyn
378d04bdf0 runtime-rs: Add hotplug block device type with QMP
There's several cases that block device plays very import roles:

1. Direct Volume:
In Kata cases, to achieve high-performance I/O, raw files on the host
are typically passed directly to the Guest via virtio-blk, and then
bond/mounted within the Guest for container usage.

2. Trusted Storage
In CoCo scenarios, particularly in Guest image pull mode, images are
typically pulled directly from the registry within the Guest. However,
due to constrained memory resources (prioritized for containers), CoCo
leverages externally attached encrypted storage to store images,
requiring hot-plug capability for block devices.

and as other vmms, like dragonball and cloud-hypervisor in runtime-rs or
qemu in kata-runtime have already supported such capabilities, we need
support block device with hot-plug method (QMP) in qemu-rs. Let's do it.

Fixes #11143

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2025-05-20 16:46:54 +08:00
alex.lyn
2405301e2e runtime-rs: Support hotplugging block device via QMP
This commit introduces block device hotplugging capability using
QMP commands.
The implementation enables attaching raw block devices to a running
VM through the following steps:

1.Block Device Configuration
Uses `blockdev-add` QMP command to define a raw block backend with
(1) Direct I/O mode
(2) Configurable read-only flag
(3) Host file/block device path (`/path/to/block`)

2.PCI Device Attachment, Attaches the block device via `device_add`
QMP command as a `virtio-blk-pci` device:
(1) Dynamically allocates PCI slots using `find_free_slot()`
(2) Binds to user-specified PCIe bus (e.g., `pcie.1`)
(3) Returns PCI path for further management

Fixes #11143

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2025-05-20 16:46:54 +08:00
alex.lyn
80bd71bfcc runtime-rs: Iterates through PCI devices to find a match with qdev_id
The get_pci_path_by_qdev_id function is designed to search for a PCI
device within a given list of devices based on a specified qdev_id.
It tracks the device's path in the PCI topology by recording the slot
values of the devices traversed during the search. If the device is
located behind a PCI bridge, the function recursively explores the
bridge's device list to find the target device. The function returns
the matching device along with its updated path if found, otherwise,
it returns None.

Fixes #11143

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2025-05-20 16:46:54 +08:00
Fupan Li
9a03815f18
Merge pull request #11095 from lifupan/ephemeral_volume
runtime-rs: add the ephemeral memory based volume support
2025-05-20 09:18:34 +08:00
RuoqingHe
5b5c71510e
Merge pull request #11093 from kimullaa/fix-err-when-containerd-conf-does-not-exist
kata-deploy: fix bug when config does not exist
2025-05-19 18:12:50 +02:00
Steve Horsman
cfdccaacb3
Merge pull request #11283 from Rtoax/p002-fix-typo
config: Fix typos
2025-05-19 14:59:37 +01:00
RuoqingHe
93b44f920c
Merge pull request #11287 from bpradipt/remote-hyp-logging
runtime: Fix logging for remote hypervisor
2025-05-19 15:49:15 +02:00
Shunsuke Kimura
9a8d64d6b1 kata-deploy: execute in the host environment
`containerd` command should be executed in the host environment.
(To generate the config that matches the host's containerd version.)

Fixes: #11092

Signed-off-by: Shunsuke Kimura <pbrehpuum@gmail.com>
2025-05-19 21:42:21 +09:00
Shunsuke Kimura
d3edc90d80 kata-deploy: Fix condition always true
if config.toml does not exist,
`[ -x $(command -v containerd) ]` will always True
(Because it is not enclosed in "").

```
// current code
$ [ -x $(command -v containerd_notfound) ]
$ echo $?
0

// maybe expected code
$ [ -x "$(command -v containerd_notfound)" ]
$ echo $?
1
```

Fixes: #11092

Signed-off-by: Shunsuke Kimura <pbrehpuum@gmail.com>
2025-05-19 21:42:21 +09:00
Hyounggyu Choi
2fd2cd4a9b runtime: Preserve hotplug devices for vfio-coldplug mode
Fixes: #11288

This commit appends hotplug devices (e.g., persistent volume)
to deviceInfos when `vfio_mod` is `vfio` and `cold_plug_vfio`
is set to one except `no-port`. For details, please visit the issue.

Signed-off-by: Hyounggyu Choi <Hyounggyu.Choi@ibm.com>
2025-05-19 13:46:49 +02:00
Pradipta Banerjee
9f9841492e runtime: Fix logging for remote hypervisor
Need to use hvLogger

Fixes: #11286

Signed-off-by: Pradipta Banerjee <pradipta.banerjee@gmail.com>
2025-05-19 07:01:59 -04:00
Jacek Tomasiak
da6860a632
osbuilder: ubuntu: Expose REPO_URL variables
This exposes REPO_URL and adds REPO_URL_X86_64 which can be set to use
custom Ubuntu repo for building rootfs.
If only one architecture is built, REPO_URL can be set. Otherwise,
REPO_URL_X86_64 is used for x86_64 arch and REPO_URL for others.

Fixes: #11276
Signed-off-by: Jacek Tomasiak <jtomasiak@arista.com>
Signed-off-by: Jacek Tomasiak <jacek.tomasiak@gmail.com>
2025-05-19 12:41:49 +02:00
Rong Tao
914730d948 config: Fix typos
devie should be device

Signed-off-by: Rong Tao <rongtao@cestc.cn>
2025-05-19 14:19:22 +08:00
Alex Lyn
305a5f5e41
Merge pull request #10578 from Apokleos/pcie-port-devices
runtime-rs: Introduce PCIe Port devices in runtime-rs for qemu-rs
2025-05-18 21:10:25 +08:00
Dan Mihai
b9651eadab
Merge pull request #11214 from microsoft/cameronbaird/address-gid-mismatch-additionalgids
genpolicy: Enable AdditionalGids checks in rules.rego
2025-05-16 10:15:53 -07:00
dependabot[bot]
a2c7e48e0e
build(deps): bump ring from 0.17.5 to 0.17.14 in /src/tools/kata-ctl
Bumps [ring](https://github.com/briansmith/ring) from 0.17.5 to 0.17.14.
- [Changelog](https://github.com/briansmith/ring/blob/main/RELEASES.md)
- [Commits](https://github.com/briansmith/ring/commits)

---
updated-dependencies:
- dependency-name: ring
  dependency-version: 0.17.14
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-16 14:51:20 +00:00
Fabiano Fidêncio
9e11b2e577
Merge pull request #11274 from fidencio/topic/arm-ci-k8s-enable-hotplug-tests
ci: k8s: arm: Enable skipped tests
2025-05-16 13:19:18 +02:00
Fabiano Fidêncio
219d6e8ea6
Merge pull request #11257 from mythi/coco-guest-hardening
confidential guest kernel hardening changes
2025-05-16 08:52:36 +02:00
Fabiano Fidêncio
86d2d96d4a ci: k8s: arm: Enable skipped tests
Now that memory hotplug should work, as we're using a firmware that
supports that, let's re-enable the tests that rely on hotplug.

Fixes: #10926, #10927

Signed-off-by: Fabiano Fidêncio <fidencio@northflank.com>
2025-05-16 03:02:32 +02:00
Fabiano Fidêncio
02ce395a69
Merge pull request #11272 from seungukshin/enable-edk2-for-arm64
Enable edk2 for arm64
2025-05-15 20:59:56 +02:00
Cameron Baird
7bba7374ec genpolicy: Add retries to policy generation
As the genpolicy from_files call makes network requests to container
registries, it has a chance to fail.

Harden us against flakes due to network by introducing a 6x retry loop
in genpolicy tests.

Signed-off-by: Cameron Baird <cameronbaird@microsoft.com>
2025-05-15 18:12:50 +00:00
Steve Horsman
d21d2a0657
Merge pull request #11265 from chathuryaadapa/bumpalo-crate-bump
Bump: libz-sys crate to address CVE
2025-05-15 16:18:00 +01:00
Mikko Ylinen
ff851202e6 config: update QEMU TDX configuration
Drop '-vmx-rdseed-exit' from '-cpu host' QEMU options. The history
of it is unknown but it's likely related to early TDX enablement.

TD pods start up fine without it (tested by manually editing the
configuration file) and it's also not used elsewhere.

Keep TDXCPUFEATURES for now in case a need for it shows up later.

Signed-off-by: Mikko Ylinen <mikko.ylinen@intel.com>
2025-05-15 15:43:24 +03:00
Fabiano Fidêncio
676e66ae49
Merge pull request #11246 from skazi0/mmdebstrap
osbuilder: ubuntu: Switch from multistrap to mmdebstrap
2025-05-15 14:15:37 +02:00
alex.lyn
07533522b8 runtime-rs: Handle PortDevice devices when invoke start_vm with Qemu
Extract PortDevice relevant information, and then invoke different
processing methods based on the device type.

Fixes #10361

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2025-05-15 20:10:49 +08:00
alex.lyn
c109328097 runtime-rs: Introduce pcie root port and switch port in qemu-rs cmdline.
Some data structures and methods are introduced to help handle vfio devices.
And mothods add_pcie_root_ports and add_pcie_switch_ports follow runtime's
related implementations of vfio devices.

Fixes #10361

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2025-05-15 20:10:49 +08:00
alex.lyn
47c7ba8672 runtime-rs: Prepare pcie port devices before start sandbox
Prepare pcie port devices before starting VM with the help of
device manager and PCIe Topology.

Fixes #10361

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2025-05-15 20:10:49 +08:00