Skip to content
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

Change logic in WorkLoad retrieval when OwnerReference of Pod is no Controller #3170

Merged
merged 7 commits into from
May 22, 2024

Conversation

waodim
Copy link
Contributor

@waodim waodim commented May 16, 2024

Description

Respective ticket: https://dt-rnd.atlassian.net/browse/K8S-9998

Because we normally assign the podName to the workload info in a certain corner case (when we have a ownerreference which is no controller) it can occur that the DT_WORKLOAD_KIND env var is set to empty.

This is fixed by simply using GenerateName instead of Name.

How can this be tested?

  • unit tests
  • I am not really sure how to properly test it otherwise at it seems to be a corner case which needs special set up

@waodim waodim added the bug Something isn't working label May 16, 2024
@waodim waodim requested a review from a team as a code owner May 16, 2024 13:33
@codecov-commenter
Copy link

codecov-commenter commented May 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 59.30%. Comparing base (7e7e54f) to head (19771da).

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3170      +/-   ##
==========================================
- Coverage   59.30%   59.30%   -0.01%     
==========================================
  Files         319      319              
  Lines       17477    17481       +4     
==========================================
+ Hits        10365    10367       +2     
- Misses       5947     5948       +1     
- Partials     1165     1166       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@0sewa0 0sewa0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<This was just a draft 😅 moved comment to the line>

pkg/webhook/mutation/pod/metadata/workload.go Outdated Show resolved Hide resolved
pkg/webhook/mutation/pod/metadata/workload.go Outdated Show resolved Hide resolved
@waodim waodim changed the title Use GenerateName instead of Name for WorkLoad Change logic in WorkLoad retrieval when OwnerReference of Pod is no Controller May 17, 2024
StefanHauth
StefanHauth previously approved these changes May 21, 2024
Copy link
Collaborator

@StefanHauth StefanHauth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@aorcholski aorcholski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line 93

t.Run("should be empty if owner is not well known", func(t *testing.T) {
                 vvvv
t.Run("should be unknown if owner is not well known", func(t *testing.T) {

0sewa0
0sewa0 previously approved these changes May 21, 2024
Co-authored-by: aorcholski <84514340+aorcholski@users.noreply.github.com>
@luhi-DT luhi-DT enabled auto-merge (squash) May 21, 2024 13:28
@luhi-DT luhi-DT closed this May 21, 2024
auto-merge was automatically disabled May 21, 2024 13:44

Pull request was closed

@luhi-DT luhi-DT reopened this May 21, 2024
@luhi-DT luhi-DT merged commit 306c05c into main May 22, 2024
37 checks passed
@luhi-DT luhi-DT deleted the bugfix/use-generatename-for-workload branch May 22, 2024 07:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants