Skip to content

Fix kubectl debug for JSON Enricher #2896

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

ngopalak-redhat
Copy link
Contributor

@ngopalak-redhat ngopalak-redhat commented Jun 24, 2025

What type of PR is this?

/kind bug

What this PR does / why we need it:

This PR fixes an issue where the kubectl debug command's audit logs were missing the requestUID from the JSON Log Enricher.

Previously, while kubectl exec successfully captured the requestUID by setting it as an environment variable, kubectl debug (which creates a new ephemeral container) failed to do so. This fix ensures the requestUID environment variable is correctly injected into these new containers.

Additionally, this PR includes a fix for kubectl exec's handling of the SPO_EXEC_REQUEST_UID environment variable. Instead of attempting to remove an existing variable with the same name (a rare occurrence), the code now correctly replaces its value with the appropriate requestUID.

Finally, the unit tests for the webhook have been enhanced with range-based testing to improve coverage.

Which issue(s) this PR fixes:

Does this PR have test?

Yes, Added e2e and unit test

Special notes for your reviewer:

e2e-apparmor-profile requires a rerun - The failure is not related to the PR

Does this PR introduce a user-facing change?

NONE

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jun 24, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @ngopalak-redhat. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jun 24, 2025
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jun 24, 2025
@codecov-commenter
Copy link

codecov-commenter commented Jun 24, 2025

Codecov Report

Attention: Patch coverage is 83.50515% with 16 lines in your changes missing coverage. Please review.

Project coverage is 25.07%. Comparing base (11d77f4) to head (a655aab).
Report is 886 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #2896       +/-   ##
===========================================
- Coverage   45.50%   25.07%   -20.43%     
===========================================
  Files          79      120       +41     
  Lines        7782    20845    +13063     
===========================================
+ Hits         3541     5227     +1686     
- Misses       4099    15361    +11262     
- Partials      142      257      +115     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Jun 24, 2025
@ngopalak-redhat
Copy link
Contributor Author

/test e2e-apparmor-profile

@k8s-ci-robot
Copy link
Contributor

@ngopalak-redhat: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/test e2e-apparmor-profile

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@ngopalak-redhat ngopalak-redhat marked this pull request as ready for review June 24, 2025 16:21
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 24, 2025
@ngopalak-redhat
Copy link
Contributor Author

cc @haircommander @saschagrunert

@saschagrunert
Copy link
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jun 25, 2025
@ngopalak-redhat
Copy link
Contributor Author

@saschagrunert / @haircommander Can you please review?

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 1, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ngopalak-redhat, saschagrunert

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

The pull request process is described here

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 1, 2025
@k8s-ci-robot k8s-ci-robot merged commit c6c44c2 into kubernetes-sigs:main Jul 1, 2025
42 of 43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants