datamanager: add deleteEtcd method
This commit is contained in:
parent
21964f90fd
commit
8fbb9fdcbe
|
@ -57,7 +57,6 @@ var (
|
|||
etcdWalsDataKey = path.Join(etcdWalBaseDir, "walsdata")
|
||||
etcdWalSeqKey = path.Join(etcdWalBaseDir, "walseq")
|
||||
etcdLastCommittedStorageWalSeqKey = path.Join(etcdWalBaseDir, "lastcommittedstoragewalseq")
|
||||
|
||||
etcdCheckpointSeqKey = path.Join(etcdWalBaseDir, "checkpointseq")
|
||||
|
||||
etcdInitEtcdLockKey = path.Join(etcdWalBaseDir, "initetcd")
|
||||
|
@ -172,6 +171,26 @@ func etcdWalKey(walSeq string) string {
|
|||
return path.Join(etcdWalsDir, walSeq)
|
||||
}
|
||||
|
||||
// deleteEtcd deletes all etcd data excluding keys used for locking
|
||||
func (d *DataManager) deleteEtcd(ctx context.Context) error {
|
||||
prefixes := []string{
|
||||
etcdWalsDir + "/",
|
||||
etcdWalsDataKey,
|
||||
etcdWalSeqKey,
|
||||
etcdLastCommittedStorageWalSeqKey,
|
||||
etcdCheckpointSeqKey,
|
||||
etcdChangeGroupsDir + "/",
|
||||
etcdChangeGroupMinRevisionKey,
|
||||
}
|
||||
for _, prefix := range prefixes {
|
||||
if err := d.e.DeletePrefix(ctx, prefix); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *DataManager) Run(ctx context.Context, readyCh chan struct{}) error {
|
||||
for {
|
||||
err := d.InitEtcd(ctx)
|
||||
|
|
Loading…
Reference in New Issue