From 1bd2d46cdb82a8ca27ed1bc56cd6aa4778983d2d Mon Sep 17 00:00:00 2001 From: Prasanna Kumar Kalever Date: Tue, 24 Aug 2021 14:00:24 +0530 Subject: [PATCH] e2e: add util to get kernel version from specified container Currently, we get the kernel version where the e2e (client) executable runs, not the kernel version that is used by the csi-rbdplugin pod. Add a function that run `uname -r` command from the specified container and returns the kernel version. Signed-off-by: Prasanna Kumar Kalever Suggested-by: Niels de Vos --- e2e/pod.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/e2e/pod.go b/e2e/pod.go index 940bdc261..5307781ed 100644 --- a/e2e/pod.go +++ b/e2e/pod.go @@ -406,3 +406,22 @@ func calculateSHA512sum(f *framework.Framework, app *v1.Pod, filePath string, op return checkSum, nil } + +// getKernelVersionFromDaemonset gets the kernel version from the specified container. +func getKernelVersionFromDaemonset(f *framework.Framework, ns, dsn, cn string) (string, error) { + selector, err := getDaemonSetLabelSelector(f, ns, dsn) + if err != nil { + return "", err + } + + opt := metav1.ListOptions{ + LabelSelector: selector, + } + + kernelRelease, stdErr, err := execCommandInContainer(f, "uname -r", ns, cn, &opt) + if err != nil || stdErr != "" { + return "", err + } + + return kernelRelease, nil +}