From b623133fb66da28dfce7a82ca7fbfc38443ef5da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Han?= Date: Mon, 12 Oct 2020 14:10:17 +0200 Subject: [PATCH] ceph: add ceph-volume log to non-pvc scenario MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When deploying on non-PVC, we still need to gather c-v logs on failures. Now if the bootstrap fails, the c-v log will be printed. Signed-off-by: Sébastien Han --- pkg/daemon/ceph/osd/volume.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pkg/daemon/ceph/osd/volume.go b/pkg/daemon/ceph/osd/volume.go index dfa83a86e..31e3647cb 100644 --- a/pkg/daemon/ceph/osd/volume.go +++ b/pkg/daemon/ceph/osd/volume.go @@ -442,10 +442,15 @@ func UpdateLVMConfig(context *clusterd.Context, onPVC, lvBackedPV bool) error { func (a *OsdAgent) initializeDevices(context *clusterd.Context, devices *DeviceOsdMapping) error { storeFlag := "--bluestore" + logPath := "/tmp/ceph-log" + if err := os.MkdirAll(logPath, 0700); err != nil { + return errors.Wrapf(err, "failed to create dir %q", logPath) + } + // Use stdbuf to capture the python output buffer such that we can write to the pod log as the logging happens // instead of using the default buffering that will log everything after ceph-volume exits baseCommand := "stdbuf" - baseArgs := []string{"-oL", cephVolumeCmd, "lvm", "batch", "--prepare", storeFlag, "--yes"} + baseArgs := []string{"-oL", cephVolumeCmd, "--log-path", logPath, "lvm", "batch", "--prepare", storeFlag, "--yes"} if a.storeConfig.EncryptedDevice { baseArgs = append(baseArgs, encryptedFlag) } @@ -541,6 +546,11 @@ func (a *OsdAgent) initializeDevices(context *clusterd.Context, devices *DeviceO // execute ceph-volume immediately with the device-specific setting instead of batching up multiple devices together if err := context.Executor.ExecuteCommand(baseCommand, immediateExecuteArgs...); err != nil { + cvLog := readCVLogContent("/tmp/ceph-log/ceph-volume.log") + if cvLog != "" { + logger.Errorf("%s", cvLog) + } + return errors.Wrap(err, "failed ceph-volume") }