e2e: introduce getClusterID() helper

There are many locations where the cluster-id (`ceph fsid`) is obtained
from the Rook Toolbox. Instead of duplicating the code everywhere, use a
new helper function getClusterID().

Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
Niels de Vos
2022-04-08 13:08:32 +02:00
committed by mergify[bot]
parent b20e3fa784
commit e30364cb4d
6 changed files with 34 additions and 51 deletions

View File

@ -92,14 +92,12 @@ func createCephfsStorageClass(
// fetch and set fsID from the cluster if not set in params
if _, found := params["clusterID"]; !found {
fsID, stdErr, failErr := execCommandInToolBoxPod(f, "ceph fsid", rookNamespace)
if failErr != nil {
return failErr
var fsID string
fsID, err = getClusterID(f)
if err != nil {
return fmt.Errorf("failed to get clusterID: %w", err)
}
if stdErr != "" {
return fmt.Errorf("error getting fsid %v", stdErr)
}
sc.Parameters["clusterID"] = strings.Trim(fsID, "\n")
sc.Parameters["clusterID"] = fsID
}
sc.Namespace = cephCSINamespace