server: Refactor databaseFileMissing function
This commit is contained in:
@ -434,7 +434,7 @@ func (c *bootstrapedCluster) Finalize(cfg config.ServerConfig, s *bootstrappedSt
|
|||||||
c.cl.SetBackend(schema.NewMembershipBackend(cfg.Logger, s.backend.be))
|
c.cl.SetBackend(schema.NewMembershipBackend(cfg.Logger, s.backend.be))
|
||||||
if s.wal.haveWAL {
|
if s.wal.haveWAL {
|
||||||
c.cl.Recover(api.UpdateCapability)
|
c.cl.Recover(api.UpdateCapability)
|
||||||
if c.cl.Version() != nil && !c.cl.Version().LessThan(semver.Version{Major: 3}) && !s.backend.beExist {
|
if c.databaseFileMissing(s) {
|
||||||
bepath := cfg.BackendPath()
|
bepath := cfg.BackendPath()
|
||||||
os.RemoveAll(bepath)
|
os.RemoveAll(bepath)
|
||||||
return fmt.Errorf("database file (%v) of the backend is missing", bepath)
|
return fmt.Errorf("database file (%v) of the backend is missing", bepath)
|
||||||
@ -443,6 +443,11 @@ func (c *bootstrapedCluster) Finalize(cfg config.ServerConfig, s *bootstrappedSt
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *bootstrapedCluster) databaseFileMissing(s *bootstrappedStorage) bool {
|
||||||
|
v3Cluster := c.cl.Version() != nil && !c.cl.Version().LessThan(semver.Version{Major: 3})
|
||||||
|
return v3Cluster && !s.backend.beExist
|
||||||
|
}
|
||||||
|
|
||||||
func bootstrapRaft(cfg config.ServerConfig, cluster *bootstrapedCluster, bwal *bootstrappedWAL) *bootstrappedRaft {
|
func bootstrapRaft(cfg config.ServerConfig, cluster *bootstrapedCluster, bwal *bootstrappedWAL) *bootstrappedRaft {
|
||||||
switch {
|
switch {
|
||||||
case !bwal.haveWAL && !cfg.NewCluster:
|
case !bwal.haveWAL && !cfg.NewCluster:
|
||||||
|
Reference in New Issue
Block a user