wilfred-s commented on code in PR #584:
URL: https://github.com/apache/yunikorn-k8shim/pull/584#discussion_r1193286464


##########
pkg/appmgmt/general/general_test.go:
##########
@@ -167,6 +167,7 @@ func TestOriginatorPod(t *testing.T) {
        owner := apis.OwnerReference{
                APIVersion: "v1",
                UID:        "UID-POD-00002",
+               Kind:       "Pod",
        }
        refer := []apis.OwnerReference{
                owner,

Review Comment:
   use getOwnerReference to build this



##########
pkg/appmgmt/general/general.go:
##########
@@ -104,9 +104,15 @@ func isStateAwareDisabled(pod *v1.Pod) bool {
        return result
 }
 
-func getOwnerReferences(pod *v1.Pod) []metav1.OwnerReference {
+func getOwnerReference(pod *v1.Pod) []metav1.OwnerReference {
        if len(pod.OwnerReferences) > 0 {
-               return pod.OwnerReferences
+               // Filter the pod kind owner reference
+               // keep this because we need to find the original pod
+               for _, ref := range pod.OwnerReferences {
+                       if ref.Kind == reflect.TypeOf(v1.Pod{}).Name() {
+                               return []metav1.OwnerReference{ref}
+                       }
+               }

Review Comment:
   This is not needed, the call should only ever be made with the originator or 
owner pod.
   Just always build a new reference without doing anything else.
   
   NIT simplification:
   `v1.SchemeGroupVersion.String()` is always "v1" unless we change the 
signature. 
   `reflect.TypeOf(v1.Pod{}).Name()` is always "Pod" nothing else.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to