Skip to content

Commit

Permalink
feat(backuptarget): add cleanup all mounts grpc function
Browse files Browse the repository at this point in the history
ref: longhorn/longhorn 5741

Signed-off-by: Jack Lin <jack.lin@suse.com>
  • Loading branch information
ChanYiLin authored and David Ko committed Nov 22, 2023
1 parent f9c7b8b commit 3a66afa
Show file tree
Hide file tree
Showing 12 changed files with 236 additions and 156 deletions.
5 changes: 5 additions & 0 deletions controller/backup_target_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,11 @@ func (btc *BackupTargetController) cleanUpAllMounts(backupTarget *longhorn.Backu
return err
}
defer engineClientProxy.Close()
// cleanup mount points in instance-manager
if err := engineClientProxy.CleanupBackupMountPoints(); err != nil {
return err
}
// clean mount points in longhorn-manager
err = backupTargetClient.BackupCleanUpAllMounts()
return err
}
Expand Down
6 changes: 6 additions & 0 deletions engineapi/backups.go
Original file line number Diff line number Diff line change
Expand Up @@ -459,3 +459,9 @@ func (e *EngineBinary) BackupRestoreStatus(*longhorn.Engine) (map[string]*longho
}
return replicaStatusMap, nil
}

// CleanupBackupMountPoints calls engine binary
// TODO: Deprecated, replaced by gRPC proxy, just to match the interface
func (e *EngineBinary) CleanupBackupMountPoints() error {
return fmt.Errorf(ErrNotImplement)
}
4 changes: 4 additions & 0 deletions engineapi/enginesim.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,3 +264,7 @@ func (e *EngineSimulator) ReplicaModeUpdate(engine *longhorn.Engine, url, mode s
func (e *EngineSimulator) MetricsGet(*longhorn.Engine) (*Metrics, error) {
return nil, fmt.Errorf(ErrNotImplement)
}

func (e *EngineSimulator) CleanupBackupMountPoints() error {
return fmt.Errorf(ErrNotImplement)
}
4 changes: 4 additions & 0 deletions engineapi/proxy_backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,7 @@ func (p *Proxy) BackupRestoreStatus(e *longhorn.Engine) (status map[string]*long
}
return status, nil
}

func (p *Proxy) CleanupBackupMountPoints() (err error) {
return p.grpcClient.CleanupBackupMountPoints()
}
2 changes: 2 additions & 0 deletions engineapi/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ type EngineClient interface {
BackupRestore(engine *longhorn.Engine, backupTarget, backupName, backupVolume, lastRestored string, credential map[string]string, concurrentLimit int) error
BackupRestoreStatus(engine *longhorn.Engine) (map[string]*longhorn.RestoreStatus, error)

CleanupBackupMountPoints() error

MetricsGet(engine *longhorn.Engine) (*Metrics, error)
}

Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ require (
github.com/longhorn/backing-image-manager v1.4.0-rc1.0.20230521151917-38ff27cc2cbb
github.com/longhorn/backupstore v0.0.0-20231114103026-af339bb498d3
github.com/longhorn/go-iscsi-helper v0.0.0-20231113050545-9df1e6b605c7
github.com/longhorn/go-spdk-helper v0.0.0-20231002161457-6c31a95f76e8
github.com/longhorn/go-spdk-helper v0.0.0-20231113055029-9acddd184246
github.com/longhorn/longhorn-engine v1.4.0-rc1.0.20230914160943-b42224518443
github.com/longhorn/longhorn-instance-manager v1.4.0-rc1.0.20231006015831-4dca206b03f0
github.com/longhorn/longhorn-instance-manager v1.4.0-rc1.0.20231117031020-055db7ef0240
github.com/longhorn/longhorn-share-manager v1.4.0-rc1.0.20231115135615-fb85b56534a4
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.16.0
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1035,12 +1035,12 @@ github.com/longhorn/backupstore v0.0.0-20231114103026-af339bb498d3 h1:z1+k7ANPYj
github.com/longhorn/backupstore v0.0.0-20231114103026-af339bb498d3/go.mod h1:JzuHEmLyQPhGuxtKpJ2vCXPfGbylXJiBVg4KLVKsj9c=
github.com/longhorn/go-iscsi-helper v0.0.0-20231113050545-9df1e6b605c7 h1:YOOhIENIfhVCOaD00oWFeothjP0UyItBScUmpwGg8TM=
github.com/longhorn/go-iscsi-helper v0.0.0-20231113050545-9df1e6b605c7/go.mod h1:xz30xMoSLdYxfUygCzM/s99CA8/LNrkcEULFWExhqz4=
github.com/longhorn/go-spdk-helper v0.0.0-20231002161457-6c31a95f76e8 h1:tV7DKLG7xKdM3CratmRLF2JsOA1BpzFGj90nu0PiNCc=
github.com/longhorn/go-spdk-helper v0.0.0-20231002161457-6c31a95f76e8/go.mod h1:XoGXOYHw1KW3qdvTSimwY+Anyg5cPl6EVkjXxS25Upg=
github.com/longhorn/go-spdk-helper v0.0.0-20231113055029-9acddd184246 h1:Pry2QHJEqEy9jsRIaACmq/1Hre8N9wfE061+gQKspKg=
github.com/longhorn/go-spdk-helper v0.0.0-20231113055029-9acddd184246/go.mod h1:PCawMRVllTJnjbIYIC8axRfEI7aEhhjbsoBS/Y/EUYQ=
github.com/longhorn/longhorn-engine v1.4.0-rc1.0.20230914160943-b42224518443 h1:4P/dmOAq8nMGg9vnXkT04NBdNidOCPXg2LM3J63ewn8=
github.com/longhorn/longhorn-engine v1.4.0-rc1.0.20230914160943-b42224518443/go.mod h1:zcfS53mU3LkxWAWf2MkHsa75Q4t01GmiW++mfp1+78M=
github.com/longhorn/longhorn-instance-manager v1.4.0-rc1.0.20231006015831-4dca206b03f0 h1:s4fSDgPEnw76Uwbiy+L9RbL/OJ8qb/Uu6Ki0QhIiZT4=
github.com/longhorn/longhorn-instance-manager v1.4.0-rc1.0.20231006015831-4dca206b03f0/go.mod h1:t3yBsQRDOL56ONfxEdzUkgCOqfmU0mF4B5MHMteYsOw=
github.com/longhorn/longhorn-instance-manager v1.4.0-rc1.0.20231117031020-055db7ef0240 h1:ODDgqV+etH3mOI+Ss9C2jb5wHqll7kyet//bjBYhvaI=
github.com/longhorn/longhorn-instance-manager v1.4.0-rc1.0.20231117031020-055db7ef0240/go.mod h1:UEKMX5u3sHynT3KAddLUaxcrLABl8Y2H/NH8Oy4Kv3U=
github.com/longhorn/longhorn-share-manager v1.4.0-rc1.0.20231115135615-fb85b56534a4 h1:jf2jLuUZS5l7TyI1cNRqm7e9X/lrwBNsI16Q7P/o7JE=
github.com/longhorn/longhorn-share-manager v1.4.0-rc1.0.20231115135615-fb85b56534a4/go.mod h1:A/Z/YpW//hdULf+ZxelXQi8VEfAIIDRvEFvmv0xHSU0=
github.com/longhorn/longhorn-spdk-engine v0.0.0-20231005170812-e9b634e07e47 h1:hadV15fSF+akBFZ8dMQFscTsJUVpEC1t6Go3B28ZNYw=
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3a66afa

Please sign in to comment.