Add wait logic to check fsid from toolbox

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
Madhu Rajanna 2019-08-30 10:36:36 +05:30 committed by mergify[bot]
parent a81a3bf96b
commit ae67534a44
4 changed files with 36 additions and 15 deletions

View File

@ -61,6 +61,7 @@ var _ = Describe("cephfs", func() {
BeforeEach(func() { BeforeEach(func() {
updateCephfsDirPath(f.ClientSet) updateCephfsDirPath(f.ClientSet)
createFileSystem(f.ClientSet) createFileSystem(f.ClientSet)
waitTillMonsAreUp(f)
createConfigMap(cephfsDirPath, f.ClientSet, f) createConfigMap(cephfsDirPath, f.ClientSet, f)
deployCephfsPlugin() deployCephfsPlugin()
createCephfsSecret(f.ClientSet, f) createCephfsSecret(f.ClientSet, f)

View File

@ -3,7 +3,6 @@ package e2e
import ( import (
"fmt" "fmt"
"strings" "strings"
"time"
. "github.com/onsi/gomega" // nolint . "github.com/onsi/gomega" // nolint
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@ -98,8 +97,6 @@ func deployToolBox(c kubernetes.Interface) {
name := getPodName(rookNS, c, opt) name := getPodName(rookNS, c, opt)
err := waitForPodInRunningState(name, rookNS, c, deployTimeout) err := waitForPodInRunningState(name, rookNS, c, deployTimeout)
Expect(err).Should(BeNil()) Expect(err).Should(BeNil())
// this is a workaround, as we are hitting "unable to get monitor info from DNS SRV with service name: ceph-mon"
time.Sleep(30 * time.Second)
} }
func deployRook() { func deployRook() {

View File

@ -63,6 +63,7 @@ var _ = Describe("RBD", func() {
BeforeEach(func() { BeforeEach(func() {
updaterbdDirPath(f.ClientSet) updaterbdDirPath(f.ClientSet)
createRBDPool() createRBDPool()
waitTillMonsAreUp(f)
createConfigMap(rbdDirPath, f.ClientSet, f) createConfigMap(rbdDirPath, f.ClientSet, f)
deployRBDPlugin() deployRBDPlugin()
createRBDStorageClass(f.ClientSet, f) createRBDStorageClass(f.ClientSet, f)

View File

@ -130,7 +130,7 @@ func waitForDeploymentComplete(name, ns string, c clientset.Interface, t int) er
return nil return nil
} }
func execCommandInPod(f *framework.Framework, c, ns string, opt *metav1.ListOptions) string { func execCommandInPod(f *framework.Framework, c, ns string, opt *metav1.ListOptions) (string, string) {
cmd := []string{"/bin/sh", "-c", c} cmd := []string{"/bin/sh", "-c", c}
podList, err := f.PodClientNS(ns).List(*opt) podList, err := f.PodClientNS(ns).List(*opt)
@ -149,9 +149,11 @@ func execCommandInPod(f *framework.Framework, c, ns string, opt *metav1.ListOpti
PreserveWhitespace: true, PreserveWhitespace: true,
} }
stdOut, stdErr, err := f.ExecWithOptions(podPot) stdOut, stdErr, err := f.ExecWithOptions(podPot)
if stdErr != "" {
e2elog.Logf("stdErr occurred ", stdErr)
}
Expect(err).Should(BeNil()) Expect(err).Should(BeNil())
Expect(stdErr).Should(BeEmpty()) return stdOut, stdErr
return stdOut
} }
func getMons(ns string, c kubernetes.Interface) []string { func getMons(ns string, c kubernetes.Interface) []string {
@ -191,6 +193,21 @@ func getStorageClass(path string) scv1.StorageClass {
// return sc // return sc
// } // }
// this is a workaround, as we are hitting "unable to get monitor info from DNS SRV with service name: ceph-mon"
func waitTillMonsAreUp(f *framework.Framework) {
opt := metav1.ListOptions{
LabelSelector: "app=rook-ceph-tools",
}
for i := 0; i < 10; i++ {
_, err := execCommandInPod(f, "ceph fsid", rookNS, &opt)
if err != "" {
time.Sleep(10 * time.Second)
continue
}
break
}
}
func createCephfsStorageClass(c kubernetes.Interface, f *framework.Framework, enablePool bool) { func createCephfsStorageClass(c kubernetes.Interface, f *framework.Framework, enablePool bool) {
scPath := fmt.Sprintf("%s/%s", cephfsExamplePath, "storageclass.yaml") scPath := fmt.Sprintf("%s/%s", cephfsExamplePath, "storageclass.yaml")
sc := getStorageClass(scPath) sc := getStorageClass(scPath)
@ -201,7 +218,8 @@ func createCephfsStorageClass(c kubernetes.Interface, f *framework.Framework, en
opt := metav1.ListOptions{ opt := metav1.ListOptions{
LabelSelector: "app=rook-ceph-tools", LabelSelector: "app=rook-ceph-tools",
} }
fsID := execCommandInPod(f, "ceph fsid", rookNS, &opt) fsID, stdErr := execCommandInPod(f, "ceph fsid", rookNS, &opt)
Expect(stdErr).Should(BeEmpty())
// remove new line present in fsID // remove new line present in fsID
fsID = strings.Trim(fsID, "\n") fsID = strings.Trim(fsID, "\n")
@ -217,7 +235,8 @@ func createRBDStorageClass(c kubernetes.Interface, f *framework.Framework) {
opt := metav1.ListOptions{ opt := metav1.ListOptions{
LabelSelector: "app=rook-ceph-tools", LabelSelector: "app=rook-ceph-tools",
} }
fsID := execCommandInPod(f, "ceph fsid", rookNS, &opt) fsID, stdErr := execCommandInPod(f, "ceph fsid", rookNS, &opt)
Expect(stdErr).Should(BeEmpty())
// remove new line present in fsID // remove new line present in fsID
fsID = strings.Trim(fsID, "\n") fsID = strings.Trim(fsID, "\n")
@ -270,7 +289,8 @@ func createConfigMap(pluginPath string, c kubernetes.Interface, f *framework.Fra
opt := metav1.ListOptions{ opt := metav1.ListOptions{
LabelSelector: "app=rook-ceph-tools", LabelSelector: "app=rook-ceph-tools",
} }
fsID := execCommandInPod(f, "ceph fsid", rookNS, &opt) fsID, stdErr := execCommandInPod(f, "ceph fsid", rookNS, &opt)
Expect(stdErr).Should(BeEmpty())
// remove new line present in fsID // remove new line present in fsID
fsID = strings.Trim(fsID, "\n") fsID = strings.Trim(fsID, "\n")
// get mon list // get mon list
@ -309,7 +329,8 @@ func createCephfsSecret(c kubernetes.Interface, f *framework.Framework) {
opt := metav1.ListOptions{ opt := metav1.ListOptions{
LabelSelector: "app=rook-ceph-tools", LabelSelector: "app=rook-ceph-tools",
} }
adminKey := execCommandInPod(f, "ceph auth get-key client.admin", rookNS, &opt) adminKey, stdErr := execCommandInPod(f, "ceph auth get-key client.admin", rookNS, &opt)
Expect(stdErr).Should(BeEmpty())
sc.StringData["adminID"] = "admin" sc.StringData["adminID"] = "admin"
sc.StringData["adminKey"] = adminKey sc.StringData["adminKey"] = adminKey
delete(sc.StringData, "userID") delete(sc.StringData, "userID")
@ -324,7 +345,8 @@ func createRBDSecret(c kubernetes.Interface, f *framework.Framework) {
opt := metav1.ListOptions{ opt := metav1.ListOptions{
LabelSelector: "app=rook-ceph-tools", LabelSelector: "app=rook-ceph-tools",
} }
adminKey := execCommandInPod(f, "ceph auth get-key client.admin", rookNS, &opt) adminKey, stdErr := execCommandInPod(f, "ceph auth get-key client.admin", rookNS, &opt)
Expect(stdErr).Should(BeEmpty())
sc.StringData["userID"] = "admin" sc.StringData["userID"] = "admin"
sc.StringData["userKey"] = adminKey sc.StringData["userKey"] = adminKey
_, err := c.CoreV1().Secrets("default").Create(&sc) _, err := c.CoreV1().Secrets("default").Create(&sc)
@ -750,8 +772,8 @@ func listRBDImages(f *framework.Framework) []string {
opt := metav1.ListOptions{ opt := metav1.ListOptions{
LabelSelector: "app=rook-ceph-tools", LabelSelector: "app=rook-ceph-tools",
} }
stdout := execCommandInPod(f, "rbd ls --pool=replicapool --format=json", rookNS, &opt) stdout, stdErr := execCommandInPod(f, "rbd ls --pool=replicapool --format=json", rookNS, &opt)
Expect(stdErr).Should(BeEmpty())
var imgInfos []string var imgInfos []string
err := json.Unmarshal([]byte(stdout), &imgInfos) err := json.Unmarshal([]byte(stdout), &imgInfos)
@ -813,8 +835,8 @@ func checkDataPersist(pvcPath, appPath string, f *framework.Framework) error {
if err != nil { if err != nil {
return err return err
} }
persistData := execCommandInPod(f, fmt.Sprintf("cat %s", filePath), app.Namespace, &opt) persistData, stdErr := execCommandInPod(f, fmt.Sprintf("cat %s", filePath), app.Namespace, &opt)
Expect(stdErr).Should(BeEmpty())
if !strings.Contains(persistData, data) { if !strings.Contains(persistData, data) {
return fmt.Errorf("data not persistent expected data %s received data %s ", data, persistData) return fmt.Errorf("data not persistent expected data %s received data %s ", data, persistData)
} }