diff --git a/nomad/fsm.go b/nomad/fsm.go index 5ce00d3884f..39b4cf8f06f 100644 --- a/nomad/fsm.go +++ b/nomad/fsm.go @@ -2140,6 +2140,9 @@ func (s *nomadSnapshot) persistSchedulerConfig(sink raft.SnapshotSink, if err != nil { return err } + if schedConfig == nil { + return nil + } // Write out scheduler config sink.Write([]byte{byte(SchedulerConfigSnapshot)}) if err := encoder.Encode(schedConfig); err != nil { @@ -2156,6 +2159,9 @@ func (s *nomadSnapshot) persistClusterMetadata(sink raft.SnapshotSink, if err != nil { return err } + if clusterMetadata == nil { + return nil + } // Write out the cluster metadata sink.Write([]byte{byte(ClusterMetadataSnapshot)}) diff --git a/nomad/state/state_store.go b/nomad/state/state_store.go index 9b0eca9cc16..81cba1edec8 100644 --- a/nomad/state/state_store.go +++ b/nomad/state/state_store.go @@ -5114,7 +5114,7 @@ func (s *StateStore) setClusterMetadata(txn *memdb.Txn, meta *structs.ClusterMet if existing != nil { existingClusterID := existing.(*structs.ClusterMetadata).ClusterID - if meta.ClusterID != existingClusterID { + if meta.ClusterID != existingClusterID && existingClusterID != "" { // there is a bug in cluster ID detection return fmt.Errorf("refusing to set new cluster id, previous: %s, new: %s", existingClusterID, meta.ClusterID) }