rthooks: add --fail-allow-namespaces-patterns flag#4812
rthooks: add --fail-allow-namespaces-patterns flag#4812PhilipSchmid wants to merge 4 commits intocilium:mainfrom
Conversation
✅ Deploy Preview for tetragon ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
f1ed32a to
ab54f6f
Compare
kkourt
left a comment
There was a problem hiding this comment.
Thanks!
Can you split the PR into different commits so that it can be easily reviewed?
It feels to me that the PR was generated by an LLM. Please document the influence level (see: https://danielmiessler.com/blog/ai-influence-level-ail) of the PR.
Fix double word "the them" -> "them" in the failure check section. Signed-off-by: Philip Schmid <phisch@cisco.com>
ab54f6f to
044b086
Compare
PhilipSchmid
left a comment
There was a problem hiding this comment.
Thanks for the feedback and input!
Can you split the PR into different commits so that it can be easily reviewed?
Absolutely, I just did that and force-pushed 4 granular commits.
It feels to me that the PR was generated by an LLM. Please document the influence level (see: https://danielmiessler.com/blog/ai-influence-level-ail) of the PR.
💯, I used an LLM create that. I'd say it's an AIL 3-4. IMO, it's probably obvious that close to no human would have added so many unit tests 😅. Still, stuff like this was all implemented because I gave pretty detailed instructions to the LLM to do so, and I also reviewed them all and they make sense to me (according to me limited golang experience). Is there a specific way you want this AIL being mentioned in the PR and/or git commits? Maybe it's also worth to add a brief section about that in https://tetragon.io/docs/contribution-guide/ as I assume I'm not the first and won't for sure be the last one doing that?
Add a new --fail-allow-namespaces-patterns flag to tetragon-oci-hook that accepts glob patterns with a single '*' wildcard. Supported forms: 'kube-*' (prefix), '*-system' (suffix), 'foo-*-bar' (contains), or '*' alone to match any namespace. A container is allowed to start if its namespace matches any of the provided patterns. The flag can be combined with the existing --fail-allow-namespaces exact-match list; either a match on an exact name or a glob pattern is sufficient to allow the container. Patterns with more than one '*' are rejected at startup. The --fail-cel-expr flag continues to take precedence over both namespace options. Both --fail-allow-namespaces and --fail-allow-namespaces-patterns are evaluated through a single CEL program. A custom namespace_matches_glob function is registered into the CEL environment to perform glob matching in Go, keeping all fail-check logic within the CEL evaluation path. Fix a false-match bug in namespaceMatchesGlob for contains patterns where the prefix and suffix overlap on short namespace strings. Expand the unit tests to table-driven style covering: exact namespaces, glob patterns (prefix, suffix, contains, bare wildcard, exact without wildcard, empty string), combined usage, missing annotation keys, multiple invalid glob forms, and annotation key priority. Signed-off-by: Philip Schmid <phisch@cisco.com>
Add rthooks.failAllowNamespacesPatterns as a list value and pass each
entry as a repeated --fail-allow-namespaces-patterns flag to the
tetragon-oci-hook container. Document all supported wildcard forms in
the values comment: prefix ('kube-*'), suffix ('*-system'), contains
('foo-*-bar'), and bare '*' to match any namespace. Regenerate
README.md and helm-chart.md.
Signed-off-by: Philip Schmid <phisch@cisco.com>
Extend the failure check section to cover the new
failAllowNamespacesPatterns option: add exact-match and pattern-match
sub-sections with YAML examples, a combined-usage example, and a note
on precedence when fail-cel-expr is set.
Patterns use glob syntax with a single '*' wildcard. Document all
supported wildcard forms: prefix ('kube-*'), suffix ('*-system'),
contains ('foo-*-bar'), and bare '*' to match any namespace.
Signed-off-by: Philip Schmid <phisch@cisco.com>
044b086 to
df027fb
Compare
Description
Add
--fail-allow-namespaces-patternstotetragon-oci-hook, accepting glob patterns for namespaces that should not cause the hook to fail when Tetragon is unreachable.Patterns support a single
*wildcard:kube-*— prefix match*-system— suffix matchfoo-*-bar— contains match*— matches any namespaceThe flag can be used standalone or combined with the existing
--fail-allow-namespacesexact-match list. A container is allowed if its namespace matches either an exact entry or any pattern.--fail-cel-exprtakes precedence over both flags.Patterns with more than one
*are rejected at startup. If the namespace annotation key is absent from the container annotations the hook always fails (safe default).Both flags are evaluated through a single CEL program. A custom
namespace_matches_globfunction is registered into the CEL environment, keeping all fail-check logic within the CEL evaluation path.Changes
cel.go: addnamespaceMatchesGloband register it as a CEL function; implementcelAllowNamespacesWithPatternsas a single CEL program covering both exact names and glob patternsmain.go: addFailAllowNamespacesPatternstocliConf; simplifyfailTestProgto return*celProgdirectlycel_test.go: table-driven tests covering exact namespaces, all glob wildcard forms (prefix, suffix, contains, bare*, exact without wildcard, empty string, overlapping patterns), combined usage, missing annotation keys, multiple invalid glob forms, and annotation key priorityvalues.yaml+_container_rthooks.tpl: addrthooks.failAllowNamespacesPatternsHelm value; pass each entry as a repeated flag to the hook binaryruntime-hooks.md: document the new option, all wildcard forms, usage examples, and precedence rulesMotivation
Previously, the only way to exclude a group of namespaces from hook failures was
--fail-cel-expr, which requires users to write a raw CEL expression. While powerful, this is error-prone for common cases like allowing all namespaces with a given prefix. The new flag covers these patterns without requiring any CEL knowledge:Release Note