Skip to content

Commit

Permalink
core: remove support for raft protocol version 2
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
shoenig committed Jun 23, 2022
1 parent c52741a commit f1cafd0
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .changelog/13467.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:breaking-change
core: remove support for raft protocol version 2
```
3 changes: 3 additions & 0 deletions command/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 26 additions & 0 deletions command/agent/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion website/content/docs/configuration/server.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 12 additions & 2 deletions website/content/docs/upgrade/upgrade-specific.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f1cafd0

Please sign in to comment.