From 1c3d449eb7e3fb73a039be1464a5129c599bfe55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Han?= Date: Tue, 4 Feb 2020 15:15:14 +0100 Subject: [PATCH] ceph: fail if no devices found MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This will likely happen when re-running an orchestration and bootstrapping a new cluster with unclean drives. The prepare pod won't prepare nor list existing disks, thus the code will later fail on reading disks properties. Closes: https://github.com/rook/rook/issues/4810 Signed-off-by: Sébastien Han --- pkg/daemon/ceph/osd/daemon.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkg/daemon/ceph/osd/daemon.go b/pkg/daemon/ceph/osd/daemon.go index 77f689720..345ca6894 100644 --- a/pkg/daemon/ceph/osd/daemon.go +++ b/pkg/daemon/ceph/osd/daemon.go @@ -214,6 +214,15 @@ func Provision(context *clusterd.Context, agent *OsdAgent, crushLocation string) return errors.Wrap(err, "failed to configure devices") } + // Let's fail if no OSDs were configured + // This likely means the filter for available devices passed (in PVC case) + // but the resulting device was already configured for another cluster (disk not wiped and leftover) + // So we need to make sure the list is filled up, otherwise fail + if len(deviceOSDs) == 0 { + logger.Warningf("skipping OSD configuration as no devices matched the storage settings for this node %q", agent.nodeName) + return nil + } + logger.Infof("devices = %+v", deviceOSDs) // Populate CRUSH location for each OSD on the host