Commit Graph

14175 Commits

Author SHA1 Message Date
Dan Mihai
a37f10fc87 genpolicy: validate each exec command line arg
Generate policy that validates each exec command line argument, instead
of joining those args and validating the resulting string. Joining the
args ignored the fact that some of the args might include space
characters.

The older format from genpolicy-settings.json was similar to:

    "ExecProcessRequest": {
      "commands": [
                "sh -c cat /proc/self/status"
        ],
      "regex": []
    },

That format will not be supported anymore. genpolicy will detect if its
users are trying to use the older "commands" field and will exit with
a relevant error message in that case.

The new settings format is:

    "ExecProcessRequest": {
      "allowed_commands": [
        [
          "sh",
          "-c",
          "cat /proc/self/status"
        ]
      ],
      "regex": []
    },

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
2024-07-25 16:57:17 +00:00
Dan Mihai
0f11384ede tests: k8s-policy-pod: exec_command clean-up
Use "${exec_command[@]}" for calling both:
- add_exec_to_policy_settings
- kubectl exec

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
2024-07-25 16:55:03 +00:00
Dan Mihai
95b78ecaa9 tests: k8s-exec: reuse sh_command variable
Reuse sh_command variable instead of repeading "sh".

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
2024-07-25 16:50:34 +00:00
Dan Mihai
c3adeda3cc
Merge pull request #10051 from microsoft/danmihai1/exec-variable-reuse
tests: k8s: reuse policy exec variable
2024-07-24 14:58:40 -07:00
Aurélien Bombo
f08b594733
Merge pull request #9576 from microsoft/saulparedes/support_env_from
genpolicy: Add support for envFrom
2024-07-24 13:39:54 -07:00
GabyCT
79edf2ca7d
Merge pull request #10054 from GabyCT/topic/docnydus
docs: Update url links in kata nydus document
2024-07-24 14:08:44 -06:00
Dan Mihai
fecb70b85e tests: k8s: reuse policy exec variable
Share a single test script variable for both:
- Allowing a command to be executed using Policy settings.
- Executing that command using "kubectl exec".

Fixes: #10014

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
2024-07-24 17:42:04 +00:00
Fabiano Fidêncio
162a6b44f6
Merge pull request #10063 from ChengyuZhu6/fix-ci-timeout
gha: Increase timeout to run CoCo tests
2024-07-24 15:14:35 +02:00
Pavel Mores
dd1e09bd9d runtime-rs: add experimental support for memory hotunplugging to qemu-rs
Hotunplugging memory is not guaranteed or even likely to work.
Nevertheless I'd really like to have this code in for tests and
observation.  It shouldn't hurt, from experience so far.

Signed-off-by: Pavel Mores <pmores@redhat.com>
2024-07-24 13:22:41 +02:00
Pavel Mores
3095b65ac3 runtime-rs: support hotplugging memory in QemuInner
The bulk of this implementation are simple though tedious sanity checks,
alignment computations and logging.

Note that before any hotplugging, we query qemu directly for the current
size of hotplugged memory.  This ensures that any request to resize memory
will be properly compared to the actual already available amount and only
necessary amount will be added.

Note also that we borrow checked_next_multiple_of() from CH implementation.
While this might look uncleanly it's just a rather temporary solution since
an equivalent function will apparently be part of std soon, likely the
upcoming 1.75.

Signed-off-by: Pavel Mores <pmores@redhat.com>
2024-07-24 13:22:41 +02:00
Pavel Mores
4a1c828bf8 runtime-rs: support hotplugging memory in Qmp
The algorithm is rather simple - we query qemu for existing memory devices
to figure out the index of the one we're about to add.  Then we add a
backend object and a corresponding frontend device.

Signed-off-by: Pavel Mores <pmores@redhat.com>
2024-07-24 13:22:41 +02:00
Pavel Mores
0e0b146b87 runtime-rs: support storage & retrieval of guest memblock size in qemu-rs
This will be used for ensuring that hotplugged memory block sizes are
properly aligned.

Signed-off-by: Pavel Mores <pmores@redhat.com>
2024-07-24 13:22:41 +02:00
Zvonko Kaiser
a388d2b8d4
Merge pull request #9919 from zvonkok/ubuntu-dockerfile
gpu: rootfs ubuntu build expansion
2024-07-24 08:05:54 +02:00
ChengyuZhu6
2b44e9427c gha: Increase timeout to run CoCo tests
This PR increases the timeout for running the CoCo tests to avoid random failures.
These failures occur when the action `Run tests` times out after 30 minutes, causing the CI to fail.

Fixes: #10062

Signed-off-by: ChengyuZhu6 <chengyu.zhu@intel.com>
2024-07-24 12:31:38 +08:00
GabyCT
b408cc1694
Merge pull request #10060 from GabyCT/topic/fgreptest
metrics: Update launch times to use grep -F
2024-07-23 17:23:14 -06:00
Gabriela Cervantes
0e5489797d docs: Update url links in kata nydus document
This PR updates the url links in the kata nydus document.

Signed-off-by: Gabriela Cervantes <gabriela.cervantes.tellez@intel.com>
2024-07-23 17:49:12 +00:00
Gabriela Cervantes
3d17a7038a metrics: Update launch times to use grep -F
This PR updates the metrics launch times to use grep -F instead of
fgrep as this command has been deprecated.

Signed-off-by: Gabriela Cervantes <gabriela.cervantes.tellez@intel.com>
2024-07-23 17:13:52 +00:00
Zvonko Kaiser
941577ab3b gpu: rootfs ubuntu build expansion
For the GPU build we need go/rust and some other helpers
to build the rootfs.

Always use versions.yaml for the correct and working Rust and golang
version

Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
2024-07-23 14:31:35 +00:00
Steve Horsman
d69950e5c6
Merge pull request #10053 from stevenhorsman/release-env-var
ci: cache: Pass through RELEASE env
2024-07-22 21:53:20 +01:00
Dan Mihai
f26d595e5d
Merge pull request #9910 from microsoft/saulparedes/set_policy_rego_via_env
tools: Allow setting policy rego file via
2024-07-22 11:00:30 -07:00
stevenhorsman
66f6ec2919 ci: cache: Pass through RELEASE env
In kata-deploy-binaries.sh we want to understand if we are running
as part of a release, so we need to pass through the RELEASE env
from the workflow, which I missed in
https://github.com/kata-containers/kata-containers/pull/9550

Fixes: #9921
Signed-off-by: stevenhorsman <steven@uk.ibm.com>
2024-07-22 16:39:35 +01:00
Zvonko Kaiser
5765b6e062
Merge pull request #9920 from zvonkok/initrd-builer
gpu: rootfs/initrd build init
2024-07-22 15:06:49 +02:00
Zvonko Kaiser
73bcb09232
Merge pull request #9968 from zvonkok/kernel-gpu-dragonball-6.1.x
dragonball: kernel gpu dragonball 6.1.x
2024-07-22 13:03:14 +02:00
Zvonko Kaiser
3029e6e849 gpu: rootfs/initrd build init
Initramfs expects /init, create symlink only if ${ROOTFS}/init does not exist
Init may be provided by other packages, e.g. systemd or GPU initrd/rootfs

Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
2024-07-22 10:19:05 +00:00
Saul Paredes
b7a184a0d8 rootfs: Allow AGENT_POLICY_FILE te be an absolute
path

Don't set AGENT_POLICY_FILE as $script_dir may change

Signed-off-by: Saul Paredes <saulparedes@microsoft.com>
2024-07-21 14:57:41 -07:00
Hyounggyu Choi
c774cd6bb0
Merge pull request #10031 from ChengyuZhu6/fix-log-contain-tdx
tests: Fix missing log on TDX
2024-07-20 07:26:08 +02:00
ChengyuZhu6
6ea6e85f77 tests: Re-enable authenticated image tests on tdx
Try to re-enable authenticated image tests on tdx.

Signed-off-by: ChengyuZhu6 <chengyu.zhu@intel.com>
2024-07-20 12:10:02 +08:00
ChengyuZhu6
3476fb481e tests: Fix missing log on TDX
Currently, we have found that `assert_logs_contain` does not work on TDX.
We manually located the specific log, but it fails to get the log using `kubectl debug`. The error found in CI is:
```
warning: couldn't attach to pod/node-debugger-984fee00bd70.jf.intel.com-pdgsj,
falling back to streaming logs: error stream protocol error: unknown error
```

Upon debugging the TDX CI machine, we found an error in containerd:
```
Attach container from runtime service failed" err="rpc error: code = InvalidArgument desc = tty and stderr cannot both be true"
containerID="abc8c7a546c5fede4aae53a6ff2f4382ff35da331bfc5fd3843b0c8b231728bf"
```

We believe this is the root cause of the test failures in TDX CI.
Therefore, we need to ensure that tty and stderr are not set to true at same time.

Fixes: #10011

Signed-off-by: ChengyuZhu6 <chengyu.zhu@intel.com>
Signed-off-by: Wang, Arron <arron.wang@intel.com>
2024-07-20 12:10:01 +08:00
Steve Horsman
7dd560f07f
Merge pull request #9620 from l8huang/kernel
Add kernel config for NVIDIA DPU/ConnectX adapter
2024-07-19 23:16:51 +01:00
Dan Mihai
3127dbb3df
Merge pull request #10035 from microsoft/danmihai1/k8s-credentials-secrets
tests: k8s-credentials-secrets: policy for second pod
2024-07-19 12:44:21 -07:00
Saul Paredes
2681fc7eb0 genpolicy: Add support for envFrom
This change adds support for the `envFrom` field in the `Pod` resource

Signed-off-by: Saul Paredes <saulparedes@microsoft.com>
2024-07-19 09:53:58 -07:00
GabyCT
be2d4719c2
Merge pull request #10040 from kata-containers/fix_blogbench_midvalues
metrics: update avg reference values for blogbench.
2024-07-19 09:51:29 -06:00
Zvonko Kaiser
8eaa2f0dc8 dragonball: Add GPU support
Build a GPU flavoured dragonball kernel

Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
2024-07-19 14:48:05 +00:00
Dan Mihai
44e443678d
Merge pull request #9835 from microsoft/saulparedes/test_policy_on_sev
gha: enable autogenerated policy testing on SEV and SEV-SNP
2024-07-19 07:46:01 -07:00
Greg Kurz
dc97f3f540
Merge pull request #10045 from lifupan/cleanup_container
runtime-rs: container: fix the issue of missing cleanup container
2024-07-19 16:36:04 +02:00
Alex Lyn
d0dc67bb96
Merge pull request #8597 from amshinde/vfio-hotplug-support
Implement hotplug support for physical endpoints
2024-07-19 13:41:11 +08:00
Lei Huang
20f6979d8f build: add kernel config for Nvidia DPU/ConnectX adapter
With Nvidia DPU or ConnectX network adapter, VF can do VFIO passthrough
to guest VM in `guest-kernel` mode. In the guest kernel, the adapter's
driver is required to claim the VFIO device and create network interface.

Signed-off-by: Lei Huang <leih@nvidia.com>
2024-07-18 22:29:16 -07:00
Fupan Li
8a2f7b7a8c container: fix the issue of missing cleanup container
When create container failed, it should cleanup the container
thus there's no device/resource left.

Fixes: #10044

Signed-off-by: Fupan Li <fupan.lfp@antgroup.com>
2024-07-19 11:02:55 +08:00
ms-mahuber
ddff762782 tools: Allow setting policy rego file via
environment variable

* Set policy file via env var

* Add restrictive policy file to kata-opa folder

* Change restrictive policy file name

* Change relative default path location

* Add license headers

Signed-off-by: Saul Paredes <saulparedes@microsoft.com>
2024-07-18 15:05:45 -07:00
David Esparza
60f52a4b93
metrics: update avg reference values for blogbench.
This PR updates the Blogbench reference values for
read and write operations used in the CI check metrics
job.

This is due to the update to version 1.2 of blobench.

Fixes: #10039

Signed-off-by: David Esparza <david.esparza.borquez@intel.com>
2024-07-18 15:47:14 -06:00
Greg Kurz
fc4357f642
Merge pull request #10034 from BbolroC/hide-repack_secure_image-from-test
tests: Call repack_secure_image() in set_metadata_annotation()
2024-07-18 23:03:41 +02:00
Aurélien Bombo
ab6f37aa52
Merge pull request #10022 from microsoft/danmihai1/probes-and-lifecycle
genpolicy: container.exec_commands args validation
2024-07-18 12:21:31 -07:00
Steve Horsman
256ab50f1a
Merge pull request #9959 from sprt/fix-ci-cleanup
ci: cleanup: Ignore nonexisting resources
2024-07-18 19:23:48 +01:00
David Esparza
1fdc5c1183
Merge pull request #10028 from amshinde/upgrade-blogbench-1.2
metric: Upgrade blogbench to 1.2
2024-07-18 11:30:17 -06:00
Hyounggyu Choi
a7e4d3b738 tests: Call repack_secure_image() in set_metadata_annotation()
It is not good practice to call repack_secure_image() from a bats file
because the test code might not consider cases where `qemu-se` is used
as `KATA_HYPERVISOR`.

This commit moves the function call to set_metadata_annotation() if a key
includes `kernel_params` and `KATA_HYPERVISOR` is set to `qemu-se`, allowing
developers to focus on the test scenario itself.

Signed-off-by: Hyounggyu Choi <Hyounggyu.Choi@ibm.com>
2024-07-18 18:09:45 +02:00
Dan Mihai
035a42baa4 tests: k8s-credentials-secrets: policy for second pod
Add policy to pod-secret-env.yaml from k8s-credentials-secrets.bats.

Policy was already auto-generated for the other pod used by the same
test (pod-secret.yaml). pod-secret-env.yaml was inconsistent,
because it was taking advantage of the "allow all" policy built into
the Guest image. Sooner or later, CI Guests for CoCo will not get the
"allow all" policy built in anymore and pod-secret-env.yaml would
have stopped working then.

Note that pod-secret-env.yaml continues to use an "allow all" policy
after these changes. #10033 must be solved before a more restrictive
policy will be generated for pod-secret-env.yaml.

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
2024-07-18 15:03:57 +00:00
Hyounggyu Choi
d2ac01c862
Merge pull request #10032 from BbolroC/fix-image-authenticated-for-s390x
tests: Rebuild secure boot image for guest-pull-image-authenticated for IBM SE
2024-07-18 17:00:18 +02:00
Hyounggyu Choi
6e7ee4bdab tests: Rebuild secure image for guest-pull-image-authenticated on SE
Since #9904 was merged, newly introduced tests for `k8s-guest-pull-image-authenticated.bats`
have been failing on IBM SE (s390x). The agent fails to start because a kernel parameter
cannot pass to the guest VM via annotation. To fix this, the boot image must be rebuilt with
updated parameters.

This commit adds the rebuilding step in create_pod_yaml_with_private_image() for `qemu-se`.

Signed-off-by: Hyounggyu Choi <Hyounggyu.Choi@ibm.com>
2024-07-18 14:56:12 +02:00
Archana Shinde
1636c201f4 network: Implement network hotunplug for physical endpoints
Similar to HotAttach, the HotDetach method signature for network
endoints needs to be changed as well to allow for the method to make
use of device manager to manage the hot unplug of physical network
devices.

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
2024-07-17 16:42:41 -07:00
Archana Shinde
c6390f2a2a vfio: Introduce function to get vfio dev path
This function will be later used to get the vfio dev path.

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
2024-07-17 16:42:41 -07:00