fix(k8smeta): accept purely numeric Kubernetes node names - #1489
Open
sooraj-sky wants to merge 1 commit into
Open
fix(k8smeta): accept purely numeric Kubernetes node names#1489sooraj-sky wants to merge 1 commit into
sooraj-sky wants to merge 1 commit into
Conversation
Falco's downward API env var substitution infers a JSON integer type for a purely numeric value (e.g. a node named "123456"), but the k8smeta plugin's init-config schema required nodeName to be a string. Schema validation rejected the numeric value outright, so the plugin crash-looped on any node with a numeric hostname even though the config was otherwise valid. Relax the schema to accept both string and integer for nodeName, and convert an integer value back to a string in parse_init_config before it is used, since the rest of the plugin expects a string node name. Fixes falcosecurity#1372 Signed-off-by: Sooraj Macbook <ops@skywalks.in>
Contributor
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: sooraj-sky The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Contributor
|
Welcome @sooraj-sky! It looks like this is your first PR to falcosecurity/plugins 🎉 |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
123456), but thek8smetaplugin's init-config JSON schema requirednodeNameto be astring. Schema validation rejected the numeric value outright, so the plugin crash-looped on any node with a numeric hostname (Value type not permitted by 'type' constraint), even though the CRDs/config were otherwise valid.nodeNameaccepts["string", "integer"].parse_init_config, an integer value is now converted back to a string (std::to_string) before being used, since the rest of the plugin (env-var substitution pattern matching,m_node_name) expects a string.Fixes #1372
Test plan
plugin_k8s_with_numeric_node_nametotest/src/init_config.cpp, following the existing test pattern in that file (plugin_owner->init(...)through the real schema validator andparse_init_config).libk8smeta.so) and theunit-test-libsinsptest binary per this repo's CI recipe (cmake+make k8smeta+make build-tests), in anubuntu:22.04container matching.github/workflows/k8smeta-ci.yaml.init_config.cpptest group directly against the built binary — all 7 pass, including the new numeric-node-name case:plugin_k8s_basic_API-style tests in the same binary need the Go-based mock collector server fromk8s-metacollector, which wasn't built in this pass since this fix is entirely config-parsing; they're untouched by this change.)clang-format-14 --dry-run --Werroron both changed files — clean, matches this repo'sformatting-checkCI job.nlohmann::jsonconversion logic (numeric, string, and env-var-pattern node names all convert correctly).