@@ -11,11 +11,11 @@ import (
1111 "strconv"
1212 "time"
1313
14+ configv1 "github.com/openshift/api/config/v1"
1415 "github.com/openshift/osdctl/pkg/k8s"
1516 "github.com/spf13/cobra"
1617 appsv1 "k8s.io/api/apps/v1"
1718 corev1 "k8s.io/api/core/v1"
18- apierrors "k8s.io/apimachinery/pkg/api/errors"
1919 k8serr "k8s.io/apimachinery/pkg/api/errors"
2020 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2121 "k8s.io/apimachinery/pkg/labels"
@@ -302,7 +302,7 @@ func copyFilesFromPod(o *packetCaptureOptions, pod *corev1.Pod) error {
302302 return err
303303 }
304304 fileName := fmt .Sprintf ("%s-%s.pcap" , pod .Spec .NodeName , o .startTime .UTC ().Format ("20060102T150405" ))
305- cmd := exec .Command ("oc" , "cp" , pod .Namespace + "/" + pod .Name + ":/tmp/capture-output/capture.pcap" , outputDir + "/" + fileName ) //#nosec G204 -- Subprocess launched with a potential tainted input or cmd arguments
305+ cmd := exec .Command ("oc" , "cp" , pod .Namespace + "/" + pod .Name + ":/tmp/capture-output/capture.pcap" , outputDir + "/" + fileName , "--as" , "backplane-cluster-admin" ) //#nosec G204 -- Subprocess launched with a potential tainted input or cmd arguments
306306 var stdBuffer bytes.Buffer
307307 mw := io .MultiWriter (os .Stdout , & stdBuffer )
308308
@@ -517,15 +517,19 @@ func waitForPacketCapturePod(o *packetCaptureOptions, capturePod *corev1.Pod) er
517517}
518518
519519func setCaptureInterface (o * packetCaptureOptions ) error {
520- ds := & appsv1. DaemonSet {}
521- if err := o .kubeCli .Get (context .TODO (), types. NamespacedName { Namespace : "openshift-ovn-kubernetes" , Name : "ovnkube-master " }, ds ); err != nil && ! apierrors . IsNotFound ( err ) {
520+ networkConfig := & configv1. Network {}
521+ if err := o .kubeCli .Get (context .Background (), client. ObjectKey { Name : "cluster " }, networkConfig ); err != nil {
522522 return fmt .Errorf ("failed to determine the network type: %s" , err )
523523 }
524524
525- if ds .Status .DesiredNumberScheduled > 0 {
525+ switch networkConfig .Spec .NetworkType {
526+ case "OVNKubernetes" :
526527 o .captureInterface = "genev_sys_6081"
527528 return nil
529+ case "OpenShiftSDN" :
530+ o .captureInterface = "vxlan_sys_4789"
531+ return nil
532+ default :
533+ return fmt .Errorf ("failed to determine network type. Network type %s unknown" , networkConfig .Spec .NetworkType )
528534 }
529- o .captureInterface = "vxlan_sys_4789"
530- return nil
531535}
0 commit comments