mirror of
https://github.com/status-im/consul.git
synced 2025-01-11 14:24:39 +00:00
agent: consolidates data dir checker
This commit is contained in:
parent
10b971df21
commit
de287e3efb
@ -168,8 +168,9 @@ func (c *Command) readConfig() *Config {
|
|||||||
// server. Consul refuses to start if this is present to protect a server
|
// server. Consul refuses to start if this is present to protect a server
|
||||||
// with existing data from starting on a fresh data set.
|
// with existing data from starting on a fresh data set.
|
||||||
if config.Server {
|
if config.Server {
|
||||||
if err := checkDataFormat(config.DataDir); err != nil {
|
mdbPath := filepath.Join(config.DataDir, "mdb")
|
||||||
c.Ui.Error(fmt.Sprintf("CRITICAL: %v", err))
|
if _, err := os.Stat(mdbPath); !os.IsNotExist(err) {
|
||||||
|
c.Ui.Error(fmt.Sprintf("CRITICAL: Deprecated data folder found at %q!", mdbPath))
|
||||||
c.Ui.Error("Consul will refuse to boot with this directory present.")
|
c.Ui.Error("Consul will refuse to boot with this directory present.")
|
||||||
c.Ui.Error("See https://consul.io/docs/upgrade-specific.html for more information.")
|
c.Ui.Error("See https://consul.io/docs/upgrade-specific.html for more information.")
|
||||||
return nil
|
return nil
|
||||||
@ -866,17 +867,6 @@ func (c *Command) handleReload(config *Config) *Config {
|
|||||||
return newConf
|
return newConf
|
||||||
}
|
}
|
||||||
|
|
||||||
// checkDataFormat checks the Consul data directory for the deprecated "mdb"
|
|
||||||
// folder. If it exists, Consul will fail to boot, avoiding situations where
|
|
||||||
// non-migrated servers start with a fresh data set.
|
|
||||||
func checkDataFormat(dataDir string) error {
|
|
||||||
mdbPath := filepath.Join(dataDir, "mdb")
|
|
||||||
if _, err := os.Stat(mdbPath); !os.IsNotExist(err) {
|
|
||||||
return fmt.Errorf("Deprecated data folder found at %q!", mdbPath)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// startScadaClient is used to start a new SCADA provider and listener,
|
// startScadaClient is used to start a new SCADA provider and listener,
|
||||||
// replacing any existing listeners.
|
// replacing any existing listeners.
|
||||||
func (c *Command) setupScadaConn(config *Config) error {
|
func (c *Command) setupScadaConn(config *Config) error {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user