Skip to content

fix(k8smeta): accept purely numeric Kubernetes node names - #1489

Open
sooraj-sky wants to merge 1 commit into
falcosecurity:mainfrom
sooraj-sky:fix/k8smeta-numeric-node-name
Open

fix(k8smeta): accept purely numeric Kubernetes node names#1489
sooraj-sky wants to merge 1 commit into
falcosecurity:mainfrom
sooraj-sky:fix/k8smeta-numeric-node-name

Conversation

@sooraj-sky

Copy link
Copy Markdown

Summary

  • Falco's downward API env var substitution infers a JSON integer type for a purely numeric value (e.g. a Kubernetes node named 123456), but the k8smeta plugin's init-config JSON 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 (Value type not permitted by 'type' constraint), even though the CRDs/config were otherwise valid.
  • Relaxed the schema so nodeName accepts ["string", "integer"].
  • In 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

  • Added plugin_k8s_with_numeric_node_name to test/src/init_config.cpp, following the existing test pattern in that file (plugin_owner->init(...) through the real schema validator and parse_init_config).
  • Built the full plugin (libk8smeta.so) and the unit-test-libsinsp test binary per this repo's CI recipe (cmake + make k8smeta + make build-tests), in an ubuntu:22.04 container matching .github/workflows/k8smeta-ci.yaml.
  • Ran the init_config.cpp test group directly against the built binary — all 7 pass, including the new numeric-node-name case:
    [ RUN      ] sinsp_with_test_input.plugin_k8s_with_numeric_node_name
    [       OK ] sinsp_with_test_input.plugin_k8s_with_numeric_node_name (0 ms)
    [  PASSED  ] 7 tests.
    
    (The gRPC-server-dependent plugin_k8s_basic_API-style tests in the same binary need the Go-based mock collector server from k8s-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 --Werror on both changed files — clean, matches this repo's formatting-check CI job.
  • Independently validated both halves of the fix in isolation before touching the real code: the draft-04 JSON Schema change against a real validator (accepts int/string, rejects float), and the exact nlohmann::json conversion logic (numeric, string, and env-var-pattern node names all convert correctly).

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>
@poiana

poiana commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: sooraj-sky
Once this PR has been reviewed and has the lgtm label, please assign ekoops for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@poiana

poiana commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Welcome @sooraj-sky! It looks like this is your first PR to falcosecurity/plugins 🎉

@poiana poiana added the size/M label Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[k8smeta] Plugin fails to initialize on numeric Kubernetes nodes due to strict String constraint vs Core Type Inference

2 participants