Skip to content

Commit 6ccfd47

Browse files
fix: failing enable workflow
The prefill operation uses commands which require the mirroring module to be enabled. Previously it was being managed externally, However, this should be done by microceph automatically. Signed-off-by: Utkarsh Bhatt <utkarsh.bhatt@canonical.com>
1 parent 5adaa75 commit 6ccfd47

2 files changed

Lines changed: 30 additions & 2 deletions

File tree

microceph/ceph/manager.go

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ import (
55
"fmt"
66
"path/filepath"
77
"strings"
8+
"time"
9+
10+
"github.com/Rican7/retry"
11+
"github.com/Rican7/retry/backoff"
12+
"github.com/Rican7/retry/strategy"
813

914
"github.com/canonical/microceph/microceph/common"
1015
"github.com/canonical/microceph/microceph/constants"
@@ -66,7 +71,21 @@ func EnableMgrModule(ctx context.Context, module string, remote string, local st
6671
return err
6772
}
6873

69-
return verifyMgrModuleEnabled(ctx, module, remote, local)
74+
err = retry.Retry(func(i uint) error {
75+
err := verifyMgrModuleEnabled(ctx, module, remote, local)
76+
if err != nil {
77+
logger.Debugf("Attempt %d: Failed verifying enablement of mirroring module", i)
78+
return err
79+
}
80+
81+
return nil
82+
}, strategy.Delay(2*time.Second), strategy.Limit(10), strategy.Backoff(backoff.Linear(10*time.Second)))
83+
if err != nil {
84+
logger.Errorf("Failed to enable %s cluster mgr module %s: %v", remote, module, err)
85+
return err
86+
}
87+
88+
return nil
7089
}
7190

7291
func verifyMgrModuleEnabled(ctx context.Context, module string, remote string, local string) error {

microceph/ceph/replication_cephfs.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ func (rh *CephfsReplicationHandler) PreFill(ctx context.Context, request types.R
6565
req := request.(types.CephfsReplicationRequest)
6666
rh.Request = req
6767

68+
// Enable ceph-mgr mirroring module on local cluster
69+
err = EnableMgrModule(ctx, constants.MgrModuleMirroring, "", "")
70+
if err != nil {
71+
return fmt.Errorf("failed to enable mgr module %s: %w", constants.MgrModuleMirroring, err)
72+
}
73+
6874
// fetch snapshot mirror daemon status
6975
rh.FsMirrorDaemonStatus, err = GetCephFSSnapshotMirrorDaemonStatus(ctx)
7076
if err != nil {
@@ -146,8 +152,11 @@ func (rh *CephfsReplicationHandler) EnableHandler(ctx context.Context, args ...a
146152
return err
147153
}
148154

149-
err = enableCephFSMgrModules(ctx, dbRec[0].Name, dbRec[0].LocalName)
155+
// Enable the mgr module on the remote cluster.
156+
err = EnableMgrModule(ctx, constants.MgrModuleMirroring, dbRec[0].Name, dbRec[0].LocalName)
150157
if err != nil {
158+
err := fmt.Errorf("failed to enable mgr module %s on remote cluster %s: %w", constants.MgrModuleMirroring, dbRec[0].Name, err)
159+
logger.Error(err.Error())
151160
return err
152161
}
153162

0 commit comments

Comments
 (0)