Skip to content

Commit 6fa8ea8

Browse files
shuo-wumergify[bot]
authored andcommitted
fix: rebuilding gets stuck if verification fails and longhorn-manager crashes
Longhorn 8589 Signed-off-by: Shuo Wu <[email protected]> (cherry picked from commit 921f63f)
1 parent 61ad220 commit 6fa8ea8

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

pkg/controller/rebuild.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,20 @@ func (c *Controller) getCurrentAndRWReplica(address string) (*types.Replica, *ty
3535
return current, rwReplica, nil
3636
}
3737

38-
func (c *Controller) VerifyRebuildReplica(address, instanceName string) error {
38+
func (c *Controller) VerifyRebuildReplica(address, instanceName string) (err error) {
3939
// Prevent snapshot happens at the same time, as well as prevent
4040
// writing from happening since we're updating revision counter
4141
c.Lock()
4242
defer c.Unlock()
4343

44+
// TODO: It's unreasonable to set the replica mode to ERR for some of the below errors. Need to improve in the future.
45+
defer func() {
46+
if err != nil {
47+
logrus.WithError(err).Errorf("Failed to verify rebuild replica %v for volume %v", address, c.VolumeName)
48+
c.setReplicaModeNoLock(address, types.ERR)
49+
}
50+
}()
51+
4452
replica, rwReplica, err := c.getCurrentAndRWReplica(address)
4553
if err != nil {
4654
return err

pkg/sync/rpc/server.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,7 @@ func (s *SyncAgentServer) FilesSync(ctx context.Context, req *enginerpc.FilesSyn
430430
s.RebuildStatus.State = types.ProcessStateError
431431
logrus.WithError(err).Error("Sync agent gRPC server failed to rebuild replica/sync files")
432432
} else {
433+
s.RebuildStatus.Progress = 100
433434
s.RebuildStatus.State = types.ProcessStateComplete
434435
logrus.Infof("Sync agent gRPC server finished rebuilding replica/sync files for replica %v", req.ToHost)
435436
}

0 commit comments

Comments
 (0)