mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-22 14:20:19 +00:00
rbd: added rbd info to validateRBDImageCount func
Signed-off-by: Oded Viner <oviner@redhat.com>
This commit is contained in:
parent
a7959d4721
commit
b9cc8f00a5
19
e2e/rbd.go
19
e2e/rbd.go
@ -189,12 +189,27 @@ func validateRBDImageCount(f *framework.Framework, count int, pool string) {
|
|||||||
framework.Failf("failed to list rbd images: %v", err)
|
framework.Failf("failed to list rbd images: %v", err)
|
||||||
}
|
}
|
||||||
if len(imageList) != count {
|
if len(imageList) != count {
|
||||||
|
var imageDetails []string // To collect details for all images
|
||||||
|
for _, image := range imageList {
|
||||||
|
imgInfoStr, err := getImageInfo(f, image, pool)
|
||||||
|
if err != nil {
|
||||||
|
framework.Logf("Error getting image info: %v", err)
|
||||||
|
}
|
||||||
|
imgStatusOutput, err := getImageStatus(f, image, pool)
|
||||||
|
if err != nil {
|
||||||
|
framework.Logf("Error getting image status: %v", err)
|
||||||
|
}
|
||||||
|
// Collecting image details for printing
|
||||||
|
imageDetails = append(imageDetails, fmt.Sprintf(
|
||||||
|
"Pool: %s, Image: %s, Info: %s, Status: %s", pool, image, imgInfoStr, imgStatusOutput))
|
||||||
|
}
|
||||||
framework.Failf(
|
framework.Failf(
|
||||||
"backend images not matching kubernetes resource count,image count %d kubernetes resource count %d"+
|
"backend images not matching kubernetes resource count,image count %d kubernetes resource count %d"+
|
||||||
"\nbackend image Info:\n %v",
|
"\nbackend image Info:\n %v\n images information and status %v",
|
||||||
len(imageList),
|
len(imageList),
|
||||||
count,
|
count,
|
||||||
imageList)
|
imageList,
|
||||||
|
strings.Join(imageDetails, "\n"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1071,27 +1071,38 @@ type imageInfo struct {
|
|||||||
|
|
||||||
// getImageInfo queries rbd about the given image and returns its metadata, and returns
|
// getImageInfo queries rbd about the given image and returns its metadata, and returns
|
||||||
// error if provided image is not found.
|
// error if provided image is not found.
|
||||||
func getImageInfo(f *framework.Framework, imageName, poolName string) (imageInfo, error) {
|
func getImageInfo(f *framework.Framework, imageName, poolName string) (string, error) {
|
||||||
// rbd --format=json info [image-spec | snap-spec]
|
// rbd --format=json info [image-spec | snap-spec]
|
||||||
var imgInfo imageInfo
|
|
||||||
|
|
||||||
stdOut, stdErr, err := execCommandInToolBoxPod(
|
stdOut, stdErr, err := execCommandInToolBoxPod(
|
||||||
f,
|
f,
|
||||||
fmt.Sprintf("rbd info %s %s --format json", rbdOptions(poolName), imageName),
|
fmt.Sprintf("rbd info %s %s --format json", rbdOptions(poolName), imageName),
|
||||||
rookNamespace)
|
rookNamespace)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return imgInfo, fmt.Errorf("failed to get rbd info: %w", err)
|
return stdOut, fmt.Errorf("failed to get rbd info: %w", err)
|
||||||
}
|
}
|
||||||
if stdErr != "" {
|
if stdErr != "" {
|
||||||
return imgInfo, fmt.Errorf("failed to get rbd info: %v", stdErr)
|
return stdOut, fmt.Errorf("failed to get rbd info: %v", stdErr)
|
||||||
}
|
|
||||||
err = json.Unmarshal([]byte(stdOut), &imgInfo)
|
|
||||||
if err != nil {
|
|
||||||
return imgInfo, fmt.Errorf("unmarshal failed: %w. raw buffer response: %s",
|
|
||||||
err, stdOut)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return imgInfo, nil
|
return stdOut, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// getImageStatus queries rbd about the given image and returns its metadata, and returns
|
||||||
|
// error if provided image is not found.
|
||||||
|
func getImageStatus(f *framework.Framework, imageName, poolName string) (string, error) {
|
||||||
|
// rbd --format=json status [image-spec | snap-spec]
|
||||||
|
stdOut, stdErr, err := execCommandInToolBoxPod(
|
||||||
|
f,
|
||||||
|
fmt.Sprintf("rbd status %s %s --format json", rbdOptions(poolName), imageName),
|
||||||
|
rookNamespace)
|
||||||
|
if err != nil {
|
||||||
|
return stdOut, fmt.Errorf("error retrieving rbd status: %w", err)
|
||||||
|
}
|
||||||
|
if stdErr != "" {
|
||||||
|
return stdOut, fmt.Errorf("failed to get rbd info: %v", stdErr)
|
||||||
|
}
|
||||||
|
|
||||||
|
return stdOut, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// validateStripe validate the stripe count, stripe unit and object size of the
|
// validateStripe validate the stripe count, stripe unit and object size of the
|
||||||
@ -1102,16 +1113,23 @@ func validateStripe(f *framework.Framework,
|
|||||||
stripeCount,
|
stripeCount,
|
||||||
objectSize int,
|
objectSize int,
|
||||||
) error {
|
) error {
|
||||||
|
var imgInfo imageInfo
|
||||||
|
|
||||||
imageData, err := getImageInfoFromPVC(pvc.Namespace, pvc.Name, f)
|
imageData, err := getImageInfoFromPVC(pvc.Namespace, pvc.Name, f)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
imgInfo, err := getImageInfo(f, imageData.imageName, defaultRBDPool)
|
imgInfoStr, err := getImageInfo(f, imageData.imageName, defaultRBDPool)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = json.Unmarshal([]byte(imgInfoStr), &imgInfo)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("unmarshal failed: %w. raw buffer response: %s", err, imgInfoStr)
|
||||||
|
}
|
||||||
|
|
||||||
if imgInfo.ObjectSize != objectSize {
|
if imgInfo.ObjectSize != objectSize {
|
||||||
return fmt.Errorf("objectSize %d does not match expected %d", imgInfo.ObjectSize, objectSize)
|
return fmt.Errorf("objectSize %d does not match expected %d", imgInfo.ObjectSize, objectSize)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user