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.
This commit is contained in:
Seth Hoenig 2022-06-23 07:28:45 -05:00
parent 7b7c72b21d
commit 91e08d5e23
5 changed files with 46 additions and 3 deletions

3
.changelog/13467.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:breaking-change
core: remove support for raft protocol version 2
```

View File

@ -201,6 +201,9 @@ func convertServerConfig(agentConfig *Config) (*nomad.Config, error) {
if agentConfig.Server.RaftProtocol != 0 { if agentConfig.Server.RaftProtocol != 0 {
conf.RaftConfig.ProtocolVersion = raft.ProtocolVersion(agentConfig.Server.RaftProtocol) 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) raftMultiplier := int(DefaultRaftMultiplier)
if agentConfig.Server.RaftMultiplier != nil && *agentConfig.Server.RaftMultiplier != 0 { if agentConfig.Server.RaftMultiplier != nil && *agentConfig.Server.RaftMultiplier != 0 {
raftMultiplier = *agentConfig.Server.RaftMultiplier raftMultiplier = *agentConfig.Server.RaftMultiplier

View File

@ -15,6 +15,7 @@ import (
"github.com/hashicorp/nomad/helper/testlog" "github.com/hashicorp/nomad/helper/testlog"
"github.com/hashicorp/nomad/nomad/structs" "github.com/hashicorp/nomad/nomad/structs"
"github.com/hashicorp/nomad/nomad/structs/config" "github.com/hashicorp/nomad/nomad/structs/config"
"github.com/shoenig/test/must"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "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) { func TestAgent_ClientConfig(t *testing.T) {
ci.Parallel(t) ci.Parallel(t)
conf := DefaultConfig() conf := DefaultConfig()

View File

@ -166,7 +166,8 @@ server {
- `raft_protocol` `(int: 3)` - Specifies the Raft protocol version to use when - `raft_protocol` `(int: 3)` - Specifies the Raft protocol version to use when
communicating with other Nomad servers. This affects available Autopilot communicating with other Nomad servers. This affects available Autopilot
features and is typically not required as the agent internally knows the 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 - `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 scale key Raft timing parameters. Omitting this value or setting it to 0 uses

View File

@ -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 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. 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 ## Nomad 1.3.1, 1.2.8, 1.1.14
#### Default `artifact` limits #### 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. release of Nomad, 1.4.0.
In Nomad 1.3.0, the default raft protocol version has been updated to 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 server will automatically upgrade that server's raft protocol. See the
[Upgrading to Raft Protocol 3] guide. [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 [preemption]: /docs/internals/scheduling/preemption
[proxy_concurrency]: /docs/job-specification/sidecar_task#proxy_concurrency [proxy_concurrency]: /docs/job-specification/sidecar_task#proxy_concurrency
[`sidecar_task.config`]: /docs/job-specification/sidecar_task#config [`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 [`raft protocol`]: /docs/configuration/server#raft_protocol
[reserved]: /docs/configuration/client#reserved-parameters [reserved]: /docs/configuration/client#reserved-parameters
[task-config]: /docs/job-specification/task#config [task-config]: /docs/job-specification/task#config