Commit Graph

16793 Commits

Author SHA1 Message Date
Dan Mihai
524bf66cbc tests: k8s-credentials-secrets: retry on exec error
Retry after "kubectl exec" failure, instead of aborting the test
immediately.

Example of recent error:

https://github.com/kata-containers/kata-containers/actions/runs/17828061309/job/50693999052?pr=11822

not ok 1 Credentials using secrets
 (in test file k8s-credentials-secrets.bats, line 59)
  `kubectl exec $pod_name -- "${pod_exec_command[@]}" | grep -w "username"' failed

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
2025-09-19 17:45:05 +00:00
Dan Mihai
01c7949bfd tests: k8s-number-cpus: retry on kubectl exec error
Retry after "kubectl exec" failure, instead of aborting the test
immediately.

Example of recent error:

https://github.com/kata-containers/kata-containers/actions/runs/17813996758/job/50644372056

not ok 1 Check number of cpus
...
error: Internal error occurred: error sending request: Post
"https://10.224.0.4:10250/exec/kata-containers-k8s-tests/cpu-test/c1?command=sh&command=-c&command=
cat+%!F(MISSING)proc%!F(MISSING)cpuinfo+%!C(MISSING)grep+processor%!C(MISSING)wc+-l&error=1&output=1": EOF

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
2025-09-19 17:44:55 +00:00
Dan Mihai
91c3804959 tests: k8s: add container_exec_with_retries()
Add container_exec_with_retries(), useful for retrying if needed
commands similar to:

kubectl exec <pod_name> -c <container_name> -- <command>

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
2025-09-19 17:42:59 +00:00
Dan Mihai
eec6c8b0c4 tests: k8s: retry after kubectl exec error
Some of the k8s tests were already retrying if `kubectl exec` succeeded
but produced empty output. Perform the same retries on `kubectl exec`
error exit code too, instead of aborting the test immediately.

Example of recent exec error:

https://github.com/kata-containers/kata-containers/actions/runs/17813996758/job/50644372056

not ok 1 Check number of cpus
...
error: Internal error occurred: error sending request: Post
"https://10.224.0.4:10250/exec/kata-containers-k8s-tests/cpu-test/c1?command=sh&command=-c&command=
cat+%!F(MISSING)proc%!F(MISSING)cpuinfo+%!C(MISSING)grep+processor%!C(MISSING)wc+-l&error=1&output=1": EOF

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
2025-09-19 15:43:39 +00:00
Hyounggyu Choi
0fb40eda12 Merge pull request #11822 from BbolroC/runtime-no-hotplug-ibm-sel-s390x
runtime: Set maxmem to initialmem on s390x when memory hotplug is disabled
2025-09-18 17:31:01 +02:00
Hyounggyu Choi
d90e785901 runtime: Set maxmem to initialmem on s390x when memory hotplug is disabled
On s390x, QEMU fails if maxmem is set to 0:

```
invalid value of maxmem: maximum memory size (0x0) must be at least the initial memory size
```

This commit sets maxmem to the initial memory size for s390x when hotplug is disabled,
resolving the error while still ensuring that memory hotplug remains off.

Signed-off-by: Hyounggyu Choi <Hyounggyu.Choi@ibm.com>
2025-09-18 14:05:33 +02:00
Mikko Ylinen
49fbd6e7af runtime: qemu: disable memory hotplug for ConfidentialGuests
The setting '-m xM,slots=y,maxmem=zM' where maxmem is from
the host's memory capacity is failing with confidential VMs
on hosts having 1T+ of RAM.

slots/maxmem are necessary for setups where the container
memory is hotplugged to the VM during container creation based
on createContainer info.

This is not the case with CoCo since StaticResourceManagement
is enabled and memory hotplug flows have not been checked.

To avoid unexpeted errors with maxmem, disable slots/maxmem
in case ConfidentialGuest is requested.

Signed-off-by: Mikko Ylinen <mikko.ylinen@intel.com>
2025-09-17 23:43:36 +02:00
Dan Mihai
ca244c7265 Merge pull request #11753 from Apokleos/fix-anno
runtime-rs: Fix annotations within runtime-rs to pass the agent policy check
2025-09-16 16:42:26 -07:00
Dan Mihai
e2992b51ad tests: k8s-job debug information
Log the output of "kubectl logs", to hopefully help understand test
failures similar to:

https://github.com/kata-containers/kata-containers/actions/runs/17709473340/job/50326984605?pr=11753

not ok 1 Run a job to completion
 (in test file k8s-job.bats, line 37)
   `kubectl logs "$pod_name" | grep "$pi_number"' failed

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
2025-09-16 22:36:31 +02:00
Dan Mihai
8854e69e28 tests: k8s-empty-dirs debug information
Log the output of "kubectl logs", to hopefully help understand test
failures similar to:

https://github.com/kata-containers/kata-containers/actions/runs/17709473340/job/50326984613?pr=11753

not ok 2 Empty dir volume when FSGroup is specified with non-root container
 (from function `assert_equal' in file k8s-empty-dirs.bats, line 16,
 in test file k8s-empty-dirs.bats, line 65)
 `assert_equal "1001" "$uid"' failed

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
2025-09-16 22:36:31 +02:00
Alex Lyn
bc1170ba0c runtime-rs: Add bundle_path annotation within oci spec
Add the annotation of OCI bundle path to store its path.
As it'll be checked within agent policy, we need add them
to pass agent policy validations.

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2025-09-16 21:31:02 +02:00
Alex Lyn
71ddbac56d runtime-rs: Correctly set CONTAINER_TYPE_KEY within OCI Spec annotation
With the help of `update_ocispec_annotations`, we'll add the contaienr
type key with "io.katacontainers.pkg.oci.container_type" and its
corresponding type "pod_sandbox" when it's pause container and
"pod_container" when it's an other containers.

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2025-09-16 21:31:02 +02:00
Alex Lyn
a47c0cdf66 kata-types: Introduce a helper to update oci spec annotations
It'll updates OCI annotations by removing specified keys and adding
new ones. This function creates a new `HashMap` containing the updated
annotations, ensuring that the original map remains unchanged.

It is optimized for performance by pre-allocating the necessary capacity
and handling removals and additions efficiently.

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2025-09-16 21:31:02 +02:00
Alex Lyn
9992e1c416 kata-types: Export POD_CONTAINER and POD_SANDBOX constants as public
To enable access to the constants `POD_CONTAINER` and `POD_SANDBOX` from
other crates, their visibility has been updated to public. This change
addresses the previous limitation of restricted access and ensures these
values can be utilized across the codebase.

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2025-09-16 21:31:02 +02:00
Alex Lyn
95585d818f runtime-rs: Add sandbox annotation of nerdctl network namespace
Add the annotation of nerdctl network namespace to let nerdctl know which namespace
to use when calling the selected CNI plugin with "nerdctl/network-namespace".
As it'll be checked within agent policy, we need add them to pass agent policy validations.

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2025-09-16 21:31:00 +02:00
Dan Mihai
bc75f6a158 Merge pull request #11783 from billionairiam/agenttypo
kata-agent: Rename misleading variable in config parsing
2025-09-16 11:07:17 -07:00
Fabiano Fidêncio
e31a06d51d kata-manager: Handle zst unpacking
On 63f6dcdeb9 we added the support to
download either a .xz or a .zst tarball file. However, we missed adding
the code to properly unpack a .zst tarball file.

Signed-off-by: Fabiano Fidêncio <fabiano@fidencio.org>
2025-09-16 19:16:14 +02:00
Fabiano Fidêncio
4265beb081 tools: agent-ctl: Fix unresolved ch import
agent-ctl's make check has been failing with:
```
    Checking kata-agent-ctl v0.0.1 (/home/ubuntu/runner/_layout/_work/kata-containers/kata-containers/src/tools/agent-ctl)
error[E0432]: unresolved import `hypervisor::ch`
  --> src/vm/vm_ops.rs:10:5
   |
10 |     ch::CloudHypervisor,
   |     ^^ could not find `ch` in `hypervisor`
   |
note: found an item that was configured out
  --> /home/ubuntu/runner/_layout/_work/kata-containers/kata-containers/src/runtime-rs/crates/hypervisor/src/lib.rs:30:9
   |
30 | pub mod ch;
   |         ^^
note: the item is gated here
  --> /home/ubuntu/runner/_layout/_work/kata-containers/kata-containers/src/runtime-rs/crates/hypervisor/src/lib.rs:26:1
   |
26 | / #[cfg(all(
27 | |     feature = "cloud-hypervisor",
28 | |     any(target_arch = "x86_64", target_arch = "aarch64")
29 | | ))]
   | |___^
```

Let's just make sure that we include ch conditionally as well.

Signed-off-by: Fabiano Fidêncio <fabiano@fidencio.org>
2025-09-16 18:44:33 +02:00
Fupan Li
4a92fc1129 runtime-rs: add the sandbox's shm volume support
Docker containers support specifying the shm size using the --shm-size
option and support sandbox-level shm volumes, so we've added support for
shm volumes. Since Kubernetes doesn't support specifying the shm size,
it typically uses a memory-based emptydir as the container's shm, and
its size can be specified.

Signed-off-by: Fupan Li <fupan.lfp@antgroup.com>
2025-09-16 16:32:41 +02:00
Fupan Li
d48c542a52 runtime-rs: Support Firecracker disk rate limiter
This PR adds code that passes disk limiter parameters from KC
configuration to Firecracker.

Signed-off-by: Fupan Li <fupan.lfp@antgroup.com>
2025-09-16 16:27:58 +02:00
Fupan Li
e0caeb32fc runtime-rs: move the rate limiter to hypervisor config
Since the rate limiter would be shared by cloud-hypervisor
and firecracker etc, thus move it from clh's config to
hypervisor config crate which would be shared by other vmm.

Signed-off-by: Fupan Li <fupan.lfp@antgroup.com>
2025-09-16 16:27:58 +02:00
Fupan Li
73e31ea19a runtime-rs: add the block devices io limit support
Given that Rust-based VMMs like cloud-hypervisor, Firecracker, and
Dragonball naturally offer user-level block I/O rate limiting, I/O
throttling has been implemented to leverage this capability for these
VMMs. This PR specifically introduces support for cloud-hypervisor.

Signed-off-by: Fupan Li <fupan.lfp@antgroup.com>
2025-09-16 16:27:58 +02:00
Steve Horsman
ac74ef4505 Merge pull request #11801 from Apokleos/blk-sharerw
runtime-rs: Enable share-rw=true when hotplug block device within qemu
2025-09-16 14:55:57 +01:00
Alex Lyn
e9a5de35e8 runtime-rs: Enable share-rw=true when hotplug block device within qemu
Support for the share-rw=true parameter has been added. While this
parameter is essential for maintaining data consistency across multiple
QEMU instances sharing a backend disk image, its implementation also
serves to standardize parameters with the block device hotplug
functionality in kata-runtime/qemu.

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2025-09-16 10:55:29 +01:00
Fupan Li
df852b77b5 Merge pull request #11799 from Apokleos/fix-virtual-volume-type
runtime-rs: Bugfix for kata virtual volume overlay fstype
2025-09-16 09:38:07 +08:00
Dan Mihai
489b677927 Merge pull request #11732 from microsoft/saulparedes/init_data_policy_support
genpolicy: add init data support
2025-09-15 15:45:57 -07:00
Fabiano Fidêncio
8abfef358a tests: Only run docker tests with one VMM
Docker tests have been broken for a while and should be removed if we
cannot maintain those.

For now, though, let's limit it to run only with one hypervisor and
avoid wasting resources for no reason.

Signed-off-by: Fabiano Fidêncio <fabiano@fidencio.org>
2025-09-15 23:03:04 +02:00
Fabiano Fidêncio
dce6f13da8 tests: Only run devmapper tests with QEMU
devmapper tests have been failing for a while. It's been breaking on the
kata-deploy deployment, which is most likely related to Disk Pressure.

Removing files was not enough to get the tests to run, so we'll just run
those with QEMU as a way to test fixes.  Once we get the test working,
we can re-enable the other VMMs, but for now let's just not waste
resources for no reason.

Signed-off-by: Fabiano Fidêncio <fabiano@fidencio.org>
2025-09-15 23:02:33 +02:00
Saul Paredes
e3e406ff26 tests: remove add_allow_all_policy_to_yaml call from helper func
add_allow_all_policy_to_yaml now also sets the initdata annotation. So don't overwrite the
initdata annotation that was previously set by create_coco_pod_yaml_with_annotations.

Signed-off-by: Saul Paredes <saulparedes@microsoft.com>
2025-09-15 11:40:29 -07:00
Saul Paredes
cc73b14e26 docs: update policy docs
Update policy docs to use initdata annotation and encoding

Signed-off-by: Saul Paredes <saulparedes@microsoft.com>
2025-09-15 11:40:29 -07:00
Saul Paredes
b5352af1ee tests: update tests that manually set policy
Use new initdata annotation instead

Signed-off-by: Saul Paredes <saulparedes@microsoft.com>
2025-09-15 11:40:29 -07:00
Saul Paredes
2d8c3206c7 gha: allow cbl-mariner to test using initdata annotation
Allow "cc_init_data" hypervisor annotation.

Signed-off-by: Saul Paredes <saulparedes@microsoft.com>
2025-09-15 11:40:29 -07:00
Saul Paredes
5d124523f8 runtime: add initdata support in clh
Prepare the initdata image and mount it as a block device.

Signed-off-by: Saul Paredes <saulparedes@microsoft.com>
2025-09-15 11:40:21 -07:00
Saul Paredes
252d4486f1 runtime: delete initdata annotation
Delete annotation from OCI spec and sandbox config. This is done after the optional initdata annotation value has been read.

Signed-off-by: Saul Paredes <saulparedes@microsoft.com>
2025-09-15 11:34:26 -07:00
Saul Paredes
af41f5018f runtime: share initdata setup code
Move setup code such that it can be used by other hypervisors.

Signed-off-by: Saul Paredes <saulparedes@microsoft.com>
2025-09-15 11:34:26 -07:00
Saul Paredes
a427537914 genpolicy: add initdata support
Encode policy inside initdata and encode as annotation (base64(gzip(toml))).

Signed-off-by: Saul Paredes <saulparedes@microsoft.com>
2025-09-15 11:34:26 -07:00
Saul Paredes
10de56a749 kata-types: expose encode and decode initdata helper methods
These methods can be used by other components, such as genpolicy.

Signed-off-by: Saul Paredes <saulparedes@microsoft.com>
2025-09-15 11:34:26 -07:00
Mikko Ylinen
86fe419774 versions: update kernel-confidential to Linux v6.16.7
update to the latest available v6.16 stable series kernel for CoCo.

Signed-off-by: Mikko Ylinen <mikko.ylinen@intel.com>
2025-09-15 20:29:22 +02:00
Steve Horsman
fab828586b Merge pull request #11771 from stevenhorsman/attempt-crio-1.34.0-bump
runtime: Bump cri-o to latest
2025-09-15 17:31:13 +01:00
Alex Tibbles
fa6e4981a1 versions: bump ovmf edk2 version
Update ovmf to latest release. Includes CVE-2024-38805 fix.

EDK2 changelogs for releases since edk2-stable202411:
https://github.com/tianocore/edk2/releases/tag/edk2-stable202508
https://github.com/tianocore/edk2/releases/tag/edk2-stable202505
https://github.com/tianocore/edk2/releases/tag/edk2-stable202502

Signed-off-by: Alex Tibbles <alex@bleg.org>
2025-09-15 15:38:33 +02:00
stevenhorsman
dc64d256bf runtime: Bump cri-o to latest
Bump cri-o to 1.34.0 to try and remediate security advisories
CVE-2025-0750 and CVE-2025-4437.

Note: Running
```
go get github.com/cri-o/cri-o@v1.34.0
```
seems to bump a lot of other go modules, hence the size of the
vendor diff

Signed-off-by: stevenhorsman <steven@uk.ibm.com>
2025-09-15 14:29:06 +01:00
stevenhorsman
16dd1de0ab kata-monitor: Update deprecated use of grpc functions
In google.golang.org/grpc v1.72.0, `DialContext`, is deprecated, so
switch to use `NewClient` instead.
`grpc.WithBlock()` is deprecated and not recommend, so remove this

Signed-off-by: stevenhorsman <steven@uk.ibm.com>
2025-09-15 14:29:06 +01:00
stevenhorsman
b9ff5ffc21 kata-monitor: Replace use of deprecated expfmt.FmtText
In `github.com/prometheus/common v0.62.0` expfmt.FmtText
is deprecated, so replace with `expfmt.NewFormat(expfmt.TypeTextPlain)`.

Signed-off-by: stevenhorsman <steven@uk.ibm.com>
2025-09-15 14:29:06 +01:00
stevenhorsman
7f86b967d1 runtime: Replace use of deprecated expfmt.FmtText
In `github.com/prometheus/common v0.62.0` expfmt.FmtText
is deprecated, so replace with `expfmt.NewFormat(expfmt.TypeTextPlain)`.

Signed-off-by: stevenhorsman <steven@uk.ibm.com>
2025-09-15 14:29:06 +01:00
stevenhorsman
62ed86d1aa runtime: Update deprecated use of grpc.Dial
In google.golang.org/grpc v1.72.0, `Dial`, is deprecated, so
switch to use `NewClient` instead

Signed-off-by: stevenhorsman <steven@uk.ibm.com>
2025-09-15 14:29:06 +01:00
stevenhorsman
334340aa18 runtime: Update remove methods
In selinux v1.12.0, `label.SetProcessLabel`, was removed to be
replaced by `selinux.SetExecLabel`

Signed-off-by: stevenhorsman <steven@uk.ibm.com>
2025-09-15 14:29:06 +01:00
Fabiano Fidêncio
ad7e60030a tests: k8s: kata-deploy: Remove unnecessary dirs to free up space
This is following Steve's suggestion, based on what's been done on
cloud-api-adaptor.

The reason we're doing it here is because we've seen pods being evicted
due to disk pressure.

Signed-off-by: Fabiano Fidêncio <fabiano@fidencio.org>
2025-09-15 15:27:54 +02:00
Fabiano Fidêncio
60ba121a0d kata-deploy: nit: Fix test name
Just add a "is" there as it was missing.

Signed-off-by: Fabiano Fidêncio <fabiano@fidencio.org>
2025-09-15 15:27:54 +02:00
Fabiano Fidêncio
d741544fa6 kata-deploy: Don't fail if the runtimeclass is already deleted
I've hit this when using a machine with slow internet connection, which
took ages to download the kata-cleanup image, and then helm timed out in
the middle of the cleanup, leading to the cleanup job being restarted
and then bailing with an error as the runtimeclasses that kata-deploy
tries to delete were already deleted.

Signed-off-by: Fabiano Fidêncio <fabiano@fidencio.org>
2025-09-15 15:27:54 +02:00
Fupan Li
679cdeadc8 runtime: fix the issue clh resize vcpu failed
Since the cloud hypervisor's resize vCPU is an asynchronous operation,
it's possible that the previous resize operation hasn't completed when
the request is sent, causing the current call to return an error.
Therefore, several retries can be performed to avoid this error.

Signed-off-by: Fupan Li <fupan.lfp@antgroup.com>
2025-09-15 14:29:25 +02:00