ci: execCommandInDaemonsetPod should not return unused stdout

Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
Niels de Vos 2022-04-25 10:29:18 +02:00 committed by mergify[bot]
parent 5c1584671e
commit 782f08e2f0
2 changed files with 12 additions and 7 deletions

View File

@ -154,7 +154,7 @@ func unmountCephFSVolume(f *framework.Framework, appName, pvcName string) error
"umount /var/lib/kubelet/pods/%s/volumes/kubernetes.io~csi/%s/mount",
pod.UID,
pvc.Spec.VolumeName)
_, stdErr, err := execCommandInDaemonsetPod(
stdErr, err := execCommandInDaemonsetPod(
f,
cmd,
cephFSDeamonSetName,

View File

@ -137,13 +137,16 @@ func getCommandInPodOpts(
}, nil
}
// execCommandInDaemonsetPod executes commands inside given container of a daemonset pod on a particular node.
// execCommandInDaemonsetPod executes commands inside given container of a
// daemonset pod on a particular node.
//
// stderr is returned as a string, and err will be set on a failure.
func execCommandInDaemonsetPod(
f *framework.Framework,
c, daemonsetName, nodeName, containerName, ns string) (string, string, error) {
c, daemonsetName, nodeName, containerName, ns string) (string, error) {
selector, err := getDaemonSetLabelSelector(f, ns, daemonsetName)
if err != nil {
return "", "", err
return "", err
}
opt := &metav1.ListOptions{
@ -151,7 +154,7 @@ func execCommandInDaemonsetPod(
}
pods, err := listPods(f, ns, opt)
if err != nil {
return "", "", err
return "", err
}
podName := ""
@ -161,7 +164,7 @@ func execCommandInDaemonsetPod(
}
}
if podName == "" {
return "", "", fmt.Errorf("%s daemonset pod on node %s in namespace %s not found", daemonsetName, nodeName, ns)
return "", fmt.Errorf("%s daemonset pod on node %s in namespace %s not found", daemonsetName, nodeName, ns)
}
cmd := []string{"/bin/sh", "-c", c}
@ -174,7 +177,9 @@ func execCommandInDaemonsetPod(
CaptureStderr: true,
}
return f.ExecWithOptions(podOpt)
_ /* stdout */, stderr, err := f.ExecWithOptions(podOpt)
return stderr, err
}
// listPods returns slice of pods matching given ListOptions and namespace.