From 237dd6e3f9b624328ef031e8ec572cb0c6209a60 Mon Sep 17 00:00:00 2001 From: Luciano Lo Giudice Date: Wed, 27 Sep 2023 15:54:15 -0300 Subject: [PATCH] Fix OSD cleanup Signed-off-by: Luciano Lo Giudice --- microceph/ceph/osd.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/microceph/ceph/osd.go b/microceph/ceph/osd.go index ce31c2dd..2feac183 100644 --- a/microceph/ceph/osd.go +++ b/microceph/ceph/osd.go @@ -376,7 +376,13 @@ func AddOSD(s *state.State, data types.DiskParameter, wal *types.DiskParameter, logger.Debugf("Created disk record for osd.%d", nr) - // if we fail later, make sure we free up the record + // Keep the old path in case it changes after encrypting. + oldPath := data.Path + + dataPath := filepath.Join(os.Getenv("SNAP_COMMON"), "data") + osdDataPath := filepath.Join(dataPath, "osd", fmt.Sprintf("ceph-%d", nr)) + + // if we fail later, make sure we free up the record revert.Add(func() { os.RemoveAll(osdDataPath) s.Database.Transaction(s.Context, func(ctx context.Context, tx *sql.Tx) error { @@ -385,12 +391,6 @@ func AddOSD(s *state.State, data types.DiskParameter, wal *types.DiskParameter, }) }) - dataPath := filepath.Join(os.Getenv("SNAP_COMMON"), "data") - osdDataPath := filepath.Join(dataPath, "osd", fmt.Sprintf("ceph-%d", nr)) - - // Keep the old path in case it changes after encrypting. - oldPath := data.Path - // Create directory. err = os.MkdirAll(osdDataPath, 0700) if err != nil {