diff --git a/agent/consul/server.go b/agent/consul/server.go index 4ec9c29610..cc85f28f2f 100644 --- a/agent/consul/server.go +++ b/agent/consul/server.go @@ -1189,13 +1189,13 @@ func (s *Server) setupRaft() error { return nil } // Only use WAL if there is no existing raft.db, even if it's enabled. - if s.config.LogStoreConfig.Backend == LogStoreBackendDefault && !boltFileExists { + if (s.config.LogStoreConfig.Backend == LogStoreBackendDefault || s.config.LogStoreConfig.Backend == LogStoreBackendWAL) && !boltFileExists { s.config.LogStoreConfig.Backend = LogStoreBackendWAL if err = initWAL(); err != nil { return err } } else { - if s.config.LogStoreConfig.Backend == LogStoreBackendWAL { + if s.config.LogStoreConfig.Backend == LogStoreBackendWAL || s.config.LogStoreConfig.Backend == LogStoreBackendDefault { // User configured the new storage, but still has old raft.db. Warn // them! s.logger.Warn("BoltDB file raft.db found, IGNORING raft_logstore.backend which is set to 'wal'") diff --git a/agent/consul/server_test.go b/agent/consul/server_test.go index 6b147d8eae..f01d24cb4b 100644 --- a/agent/consul/server_test.go +++ b/agent/consul/server_test.go @@ -466,15 +466,14 @@ func TestServer_RaftBackend_BoltDB(t *testing.T) { // Start up a server and then stop it. _, s1 := testServerWithConfig(t, func(config *Config) { config.LogStoreConfig.Backend = LogStoreBackendBoltDB - config.LogStoreConfig.Verification.Enabled = true + config.LogStoreConfig.Verification.Enabled = false }) - store, ok := s1.raftStore.(*raftboltdb.BoltStore) + _, ok := s1.raftStore.(*raftboltdb.BoltStore) defer func() { if err := s1.Shutdown(); err != nil { t.Fatalf("err: %v", err) } }() - fmt.Printf("%v\n", store) require.True(t, ok) }