-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
packages/kata-runtime: alow arbitrary CDI annotations
As discussed via Teams, there is no sense in checking CDI annotations if the agent doesn't care about them anyway. This allows arbitrary CDI annotations in the policy.
- Loading branch information
Showing
2 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
packages/by-name/kata/kata-runtime/0021-runtime-remove-CDI-annotations.patch
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,40 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: Moritz Sanft <[email protected]> | ||
Date: Fri, 7 Feb 2025 13:12:28 +0100 | ||
Subject: [PATCH] runtime: remove CDI annotations | ||
|
||
We want to remove CDI annotations before they get to the agent, as they should only influence VM creation. Passing them to the agent is likely to create problems in policy checking, as they are often dynamically injected. | ||
--- | ||
src/runtime/virtcontainers/kata_agent.go | 12 ++++++++++++ | ||
1 file changed, 12 insertions(+) | ||
|
||
diff --git a/src/runtime/virtcontainers/kata_agent.go b/src/runtime/virtcontainers/kata_agent.go | ||
index 9a794392b927fc8fa231a72ce35bc3fcb2773d85..5e3548774154585251e192743b78363c53a00019 100644 | ||
--- a/src/runtime/virtcontainers/kata_agent.go | ||
+++ b/src/runtime/virtcontainers/kata_agent.go | ||
@@ -14,6 +14,7 @@ import ( | ||
"os" | ||
"path" | ||
"path/filepath" | ||
+ "regexp" | ||
"strconv" | ||
"strings" | ||
"sync" | ||
@@ -1080,6 +1081,17 @@ func (k *kataAgent) constrainGRPCSpec(grpcSpec *grpc.Spec, passSeccomp bool, dis | ||
grpcSpec.Linux.Devices = linuxDevices | ||
} | ||
|
||
+ cdiRegexp, err := regexp.Compile(`$cdi\.k8s\.io\/.*^`) | ||
+ if err != nil { | ||
+ k.Logger().WithError(err).Error("compile CDI annotation regexp") | ||
+ } | ||
+ | ||
+ for key := range grpcSpec.Annotations { | ||
+ if cdiRegexp.MatchString(key) { | ||
+ delete(grpcSpec.Annotations, key) | ||
+ } | ||
+ } | ||
+ | ||
return nil | ||
} | ||
|
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