Skip to content

Commit dfc5411

Browse files
feat(replica_remove): cancel snapshot hash when the replica is removed in v1
Signed-off-by: David Cheng <[email protected]>
1 parent 85750b8 commit dfc5411

File tree

3 files changed

+66
-0
lines changed

3 files changed

+66
-0
lines changed

pkg/proxy/replica.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,9 +475,47 @@ func (ops V1DataEngineProxyOps) ReplicaRemove(ctx context.Context, req *rpc.Engi
475475
}
476476
}()
477477

478+
err = ops.cancelSnapshotHashesForReplica(ctx, c, req.ReplicaAddress, req.ProxyEngineRequest)
479+
if err != nil {
480+
logrus.WithFields(logrus.Fields{
481+
"serviceURL": req.ProxyEngineRequest.Address,
482+
"engineName": req.ProxyEngineRequest.EngineName,
483+
"volumeName": req.ProxyEngineRequest.VolumeName,
484+
"replicaName": req.ReplicaName,
485+
"replicaAddress": req.ReplicaAddress,
486+
}).WithError(err).Warn("Failed to stop snapshot hash")
487+
}
488+
478489
return nil, c.ReplicaDelete(req.ReplicaAddress)
479490
}
480491

492+
func (ops V1DataEngineProxyOps) cancelSnapshotHashesForReplica(ctx context.Context, c *eclient.ControllerClient, replicaAddress string, proxyEngineRequest *rpc.ProxyEngineRequest) error {
493+
recv, err := c.ReplicaList()
494+
if err != nil {
495+
return err
496+
}
497+
498+
snapshotsDiskInfo, err := esync.GetSnapshotsInfo(recv, proxyEngineRequest.VolumeName)
499+
if err != nil {
500+
return err
501+
}
502+
snapshots := []string{}
503+
for _, snapshotInfo := range snapshotsDiskInfo {
504+
snapshots = append(snapshots, snapshotInfo.Name)
505+
}
506+
507+
task, err := esync.NewTask(ctx, proxyEngineRequest.Address, proxyEngineRequest.VolumeName, proxyEngineRequest.EngineName)
508+
if err != nil {
509+
return err
510+
}
511+
512+
if err := task.CancelSnapshotHashesForReplica(replicaAddress, snapshots); err != nil {
513+
return err
514+
}
515+
516+
return nil
517+
}
518+
481519
func (ops V2DataEngineProxyOps) ReplicaRemove(ctx context.Context, req *rpc.EngineReplicaRemoveRequest) (*emptypb.Empty, error) {
482520
c, err := getSPDKClientFromAddress(req.ProxyEngineRequest.Address)
483521
if err != nil {

vendor/github.com/longhorn/longhorn-engine/pkg/replica/client/client.go

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/longhorn/longhorn-engine/pkg/sync/sync.go

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)