Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add retry for secondary pool mirroring disablement #468

Merged
merged 1 commit into from
Nov 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions microceph/ceph/rbd_mirror.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ import (
"os"
"path/filepath"
"strings"
"time"

"github.com/Rican7/retry"
"github.com/Rican7/retry/backoff"
"github.com/Rican7/retry/strategy"
"github.com/canonical/lxd/shared/logger"
"github.com/canonical/microceph/microceph/api/types"
"github.com/canonical/microceph/microceph/constants"
Expand Down Expand Up @@ -200,14 +204,21 @@ func DisablePoolMirroring(pool string, peer RbdReplicationPeer, localName string
// Disable pool mirroring on the local cluster.
err = configurePoolMirroring(pool, types.RbdResourceDisabled, "", "")
if err != nil {
logger.Errorf("REPRBD: %s", err.Error())
logger.Errorf("REPRBD: failed to disable the primary pool mirroring %s", err.Error())
return err
}

// Disable pool mirroring on the remote cluster.
err = configurePoolMirroring(pool, types.RbdResourceDisabled, localName, remoteName)
err = retry.Retry(func(i uint) error {
// Disable pool mirroring on the remote cluster.
err = configurePoolMirroring(pool, types.RbdResourceDisabled, localName, remoteName)
if err != nil {
logger.Errorf("REPRBD: attempt %d: %s", i, err.Error())
return err
}
return nil
}, strategy.Delay(5), strategy.Limit(10), strategy.Backoff(backoff.Linear(5*time.Second)))
if err != nil {
logger.Errorf("REPRBD: %s", err.Error())
logger.Errorf("REPRBD: failed to disable the secondary pool mirroring: %s", err.Error())
return err
}

Expand Down
Loading