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

Fix the pod name for comDetails #11

Closed
wants to merge 1 commit into from

Conversation

liornoy
Copy link
Contributor

@liornoy liornoy commented Jun 20, 2024

Modifies the function for creating comDetails,
so the pod name will be more accurate.

@@ -200,6 +201,24 @@ func getContainerName(portNum int, pods []corev1.Pod) (string, error) {
return res, nil
}

func getPodName(pod *corev1.Pod) string {
var res string
name := pod.OwnerReferences[0].Name
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not all pods have OwnerReferences

Copy link
Contributor Author

Choose a reason for hiding this comment

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

would you agree that we will return empty string in that case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

after a second look, it looks like the case where pods don't have OwnerReferences, they append the node name, so I'll do the same treatment like with Kind=Node

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added this use case plus more others, verifying it against unit tests. please re-review :)

@liornoy liornoy force-pushed the fix-com-detail-name branch 2 times, most recently from 32d5cc4 to 3f3af57 Compare June 26, 2024 14:56
Modifies the function for creating comDetails,
so the pod name will be more accurate.

We fetch the name from the OwnerReference, and modify the
name if needed.

Added unit tests for the function.

Signed-off-by: Lior Noy <[email protected]>
@liornoy liornoy force-pushed the fix-com-detail-name branch from 3f3af57 to 7b29f60 Compare June 26, 2024 15:29
@sabinaaledort
Copy link
Collaborator

Fixed in #13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants