From 91e08d5e234de479c33c6ee8a494dc0c1ccb7c2f Mon Sep 17 00:00:00 2001 From: Seth Hoenig Date: Thu, 23 Jun 2022 07:28:45 -0500 Subject: [PATCH] core: remove support for raft protocol version 2 This PR checks server config for raft_protocol, which must now be set to 3 or unset (0). When unset, version 3 is used as the default. --- .changelog/13467.txt | 3 +++ command/agent/agent.go | 3 +++ command/agent/agent_test.go | 26 +++++++++++++++++++ website/content/docs/configuration/server.mdx | 3 ++- .../content/docs/upgrade/upgrade-specific.mdx | 14 ++++++++-- 5 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 .changelog/13467.txt diff --git a/.changelog/13467.txt b/.changelog/13467.txt new file mode 100644 index 000000000..84dac0ace --- /dev/null +++ b/.changelog/13467.txt @@ -0,0 +1,3 @@ +```release-note:breaking-change +core: remove support for raft protocol version 2 +``` diff --git a/command/agent/agent.go b/command/agent/agent.go index cdfb2135f..0c8217d35 100644 --- a/command/agent/agent.go +++ b/command/agent/agent.go @@ -201,6 +201,9 @@ func convertServerConfig(agentConfig *Config) (*nomad.Config, error) { if agentConfig.Server.RaftProtocol != 0 { conf.RaftConfig.ProtocolVersion = raft.ProtocolVersion(agentConfig.Server.RaftProtocol) } + if v := conf.RaftConfig.ProtocolVersion; v != 3 { + return nil, fmt.Errorf("raft_protocol must be 3 in Nomad v1.4 and later, got %d", v) + } raftMultiplier := int(DefaultRaftMultiplier) if agentConfig.Server.RaftMultiplier != nil && *agentConfig.Server.RaftMultiplier != 0 { raftMultiplier = *agentConfig.Server.RaftMultiplier diff --git a/command/agent/agent_test.go b/command/agent/agent_test.go index 6bea52f42..a4845f85f 100644 --- a/command/agent/agent_test.go +++ b/command/agent/agent_test.go @@ -15,6 +15,7 @@ import ( "github.com/hashicorp/nomad/helper/testlog" "github.com/hashicorp/nomad/nomad/structs" "github.com/hashicorp/nomad/nomad/structs/config" + "github.com/shoenig/test/must" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -472,6 +473,31 @@ func TestAgent_ServerConfig_RaftMultiplier_Bad(t *testing.T) { } } +func TestAgent_ServerConfig_RaftProtocol_3(t *testing.T) { + ci.Parallel(t) + + cases := []int{ + 0, 1, 2, 3, 4, + } + + for _, tc := range cases { + t.Run(fmt.Sprintf("protocol_version %d", tc), func(t *testing.T) { + conf := DevConfig(nil) + conf.Server.RaftProtocol = tc + must.NoError(t, conf.normalizeAddrs()) + _, err := convertServerConfig(conf) + + switch tc { + case 0, 3: // 0 defers to default + must.NoError(t, err) + default: + exp := fmt.Sprintf("raft_protocol must be 3 in Nomad v1.4 and later, got %d", tc) + must.EqError(t, err, exp) + } + }) + } +} + func TestAgent_ClientConfig(t *testing.T) { ci.Parallel(t) conf := DefaultConfig() diff --git a/website/content/docs/configuration/server.mdx b/website/content/docs/configuration/server.mdx index 7872913a0..588aaa33b 100644 --- a/website/content/docs/configuration/server.mdx +++ b/website/content/docs/configuration/server.mdx @@ -166,7 +166,8 @@ server { - `raft_protocol` `(int: 3)` - Specifies the Raft protocol version to use when communicating with other Nomad servers. This affects available Autopilot features and is typically not required as the agent internally knows the - latest version, but may be useful in some upgrade scenarios. + latest version, but may be useful in some upgrade scenarios. Must be `3` in + Nomad v1.4 or later. - `raft_multiplier` `(int: 1)` - An integer multiplier used by Nomad servers to scale key Raft timing parameters. Omitting this value or setting it to 0 uses diff --git a/website/content/docs/upgrade/upgrade-specific.mdx b/website/content/docs/upgrade/upgrade-specific.mdx index 5b9dc4402..c1cc40164 100644 --- a/website/content/docs/upgrade/upgrade-specific.mdx +++ b/website/content/docs/upgrade/upgrade-specific.mdx @@ -22,6 +22,16 @@ upgrade. However, specific versions of Nomad may have more details provided for their upgrades as a result of new features or changed behavior. This page is used to document those details separately from the standard upgrade flow. +## Nomad 1.4.0 + +#### Raft Protocol Version 2 Unsupported + +Raft protocol version 2 was deprecated in Nomad v1.3.0, and is being removed +in Nomad v1.4.0. In Nomad 1.3.0, the default raft protocol version was updated +to version 3, and in Nomad 1.4.0 Nomad requires the use of raft protocol version +3. If [`raft_protocol`] version is explicitly set, it must now be set to `3`. +For more information see the [Upgrading to Raft Protocol 3] guide. + ## Nomad 1.3.1, 1.2.8, 1.1.14 #### Default `artifact` limits @@ -42,7 +52,7 @@ Raft protocol version 2 will be removed from Nomad in the next major release of Nomad, 1.4.0. In Nomad 1.3.0, the default raft protocol version has been updated to -3. If the [`raft_protocol_version`] is not explicitly set, upgrading a +3. If the [`raft_protocol`] version is not explicitly set, upgrading a server will automatically upgrade that server's raft protocol. See the [Upgrading to Raft Protocol 3] guide. @@ -1407,7 +1417,7 @@ deleted and then Nomad 0.3.0 can be launched. [preemption]: /docs/internals/scheduling/preemption [proxy_concurrency]: /docs/job-specification/sidecar_task#proxy_concurrency [`sidecar_task.config`]: /docs/job-specification/sidecar_task#config -[`raft_protocol_version`]: /docs/configuration/server#raft_protocol +[`raft_protocol`]: /docs/configuration/server#raft_protocol [`raft protocol`]: /docs/configuration/server#raft_protocol [reserved]: /docs/configuration/client#reserved-parameters [task-config]: /docs/job-specification/task#config