ceph: return an error if PVC is not clean

With 5f57b6fd3a, we introduced a
regression in the validation code.
If the OSD PV comes from another cluster, GetCephVolumeRawOSDs must
return an error.
The prepare job will crash loop but at least with a useful and
comprehensive message.

Signed-off-by: Sébastien Han <seb@redhat.com>
This commit is contained in:
Sébastien Han
2021-02-09 11:28:08 +01:00
parent 5966f09376
commit 7c928f4196
2 changed files with 19 additions and 7 deletions
+13 -2
View File
@@ -31,6 +31,7 @@ import (
"github.com/pkg/errors"
"github.com/rook/rook/pkg/clusterd"
"github.com/rook/rook/pkg/daemon/ceph/client"
"github.com/rook/rook/pkg/operator/ceph/cluster/osd"
oposd "github.com/rook/rook/pkg/operator/ceph/cluster/osd"
cephver "github.com/rook/rook/pkg/operator/ceph/version"
"github.com/rook/rook/pkg/util/display"
@@ -56,6 +57,7 @@ var (
// The "ceph-volume raw" command is available since Ceph 14.2.8 as well as partition support in ceph-volume
cephVolumeRawModeMinCephVersion = cephver.CephVersion{Major: 14, Minor: 2, Extra: 8}
isEncrypted = os.Getenv(oposd.EncryptedDeviceEnvVarName) == "true"
isOnPVC = os.Getenv(osd.PVCBackedOSDVarName) == "true"
)
type osdInfoBlock struct {
@@ -810,13 +812,22 @@ func GetCephVolumeRawOSDs(context *clusterd.Context, clusterInfo *client.Cluster
osdID := osdInfo.OsdID
if osdInfo.CephFsid != cephfsid {
logger.Infof("skipping osd.%d: %s running on a different ceph cluster %q", osdID, osdInfo.OsdUUID, osdInfo.CephFsid)
message := fmt.Sprintf("osd.%d: %q belonging to a different ceph cluster %q", osdID, osdInfo.OsdUUID, osdInfo.CephFsid)
// We must return an error since the caller only checks the length of osds
if isOnPVC {
return nil, errors.Errorf("%s", message)
}
logger.Infof("skipping %s", message)
continue
}
osdFSID = osdInfo.OsdUUID
if len(osdFSID) == 0 {
logger.Infof("Skipping osd.%d as no instances are running on ceph cluster %q", osdID, cephfsid)
message := fmt.Sprintf("no instance of osd.%d is running on ceph cluster %q (incomplete prepare? consider wiping the disks)", osdID, cephfsid)
if isOnPVC {
return nil, errors.Errorf("%s", message)
}
logger.Infof("skipping since %s", message)
continue
}
+6 -5
View File
@@ -37,10 +37,11 @@ const (
PVCNameEnvVarName = "ROOK_PVC_NAME"
// CephVolumeEncryptedKeyEnvVarName is the env variable used by ceph-volume to encrypt the OSD (raw mode)
// Hardcoded in ceph-volume do NOT touch
CephVolumeEncryptedKeyEnvVarName = "CEPH_VOLUME_DMCRYPT_SECRET"
osdMetadataDeviceEnvVarName = "ROOK_METADATA_DEVICE"
osdWalDeviceEnvVarName = "ROOK_WAL_DEVICE"
pvcBackedOSDVarName = "ROOK_PVC_BACKED_OSD"
CephVolumeEncryptedKeyEnvVarName = "CEPH_VOLUME_DMCRYPT_SECRET"
osdMetadataDeviceEnvVarName = "ROOK_METADATA_DEVICE"
osdWalDeviceEnvVarName = "ROOK_WAL_DEVICE"
// PVCBackedOSDVarName indicates whether the OSD is on PVC ("true") or not ("false")
PVCBackedOSDVarName = "ROOK_PVC_BACKED_OSD"
blockPathVarName = "ROOK_BLOCK_PATH"
cvModeVarName = "ROOK_CV_MODE"
lvBackedPVVarName = "ROOK_LV_BACKED_PV"
@@ -143,7 +144,7 @@ func metadataDeviceEnvVar(metadataDevice string) v1.EnvVar {
}
func pvcBackedOSDEnvVar(pvcBacked string) v1.EnvVar {
return v1.EnvVar{Name: pvcBackedOSDVarName, Value: pvcBacked}
return v1.EnvVar{Name: PVCBackedOSDVarName, Value: pvcBacked}
}
func setDebugLogLevelEnvVar(debug bool) v1.EnvVar {