mirror of https://github.com/status-im/consul.git
Add UpgradeVersionTag to autopilot config
This commit is contained in:
parent
fe51640263
commit
19eae3d14b
|
@ -750,6 +750,9 @@ func (a *Agent) consulConfig() (*consul.Config, error) {
|
||||||
if a.config.Autopilot.DisableUpgradeMigration != nil {
|
if a.config.Autopilot.DisableUpgradeMigration != nil {
|
||||||
base.AutopilotConfig.DisableUpgradeMigration = *a.config.Autopilot.DisableUpgradeMigration
|
base.AutopilotConfig.DisableUpgradeMigration = *a.config.Autopilot.DisableUpgradeMigration
|
||||||
}
|
}
|
||||||
|
if a.config.Autopilot.UpgradeVersionTag != "" {
|
||||||
|
base.AutopilotConfig.UpgradeVersionTag = a.config.Autopilot.UpgradeVersionTag
|
||||||
|
}
|
||||||
|
|
||||||
// make sure the advertise address is always set
|
// make sure the advertise address is always set
|
||||||
if base.RPCAdvertise == nil {
|
if base.RPCAdvertise == nil {
|
||||||
|
|
|
@ -324,6 +324,10 @@ type Autopilot struct {
|
||||||
// strategy of waiting until enough newer-versioned servers have been added to the
|
// strategy of waiting until enough newer-versioned servers have been added to the
|
||||||
// cluster before promoting them to voters.
|
// cluster before promoting them to voters.
|
||||||
DisableUpgradeMigration *bool `mapstructure:"disable_upgrade_migration"`
|
DisableUpgradeMigration *bool `mapstructure:"disable_upgrade_migration"`
|
||||||
|
|
||||||
|
// (Enterprise-only) UpgradeVersionTag is the node tag to use for version info when
|
||||||
|
// performing upgrade migrations. If left blank, the Consul version will be used.
|
||||||
|
UpgradeVersionTag string `mapstructure:"upgrade_version_tag"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Config is the configuration that can be set for an Agent.
|
// Config is the configuration that can be set for an Agent.
|
||||||
|
@ -1687,6 +1691,9 @@ func MergeConfig(a, b *Config) *Config {
|
||||||
if b.Autopilot.DisableUpgradeMigration != nil {
|
if b.Autopilot.DisableUpgradeMigration != nil {
|
||||||
result.Autopilot.DisableUpgradeMigration = b.Autopilot.DisableUpgradeMigration
|
result.Autopilot.DisableUpgradeMigration = b.Autopilot.DisableUpgradeMigration
|
||||||
}
|
}
|
||||||
|
if b.Autopilot.UpgradeVersionTag != "" {
|
||||||
|
result.Autopilot.UpgradeVersionTag = b.Autopilot.UpgradeVersionTag
|
||||||
|
}
|
||||||
if b.Telemetry.DisableHostname == true {
|
if b.Telemetry.DisableHostname == true {
|
||||||
result.Telemetry.DisableHostname = true
|
result.Telemetry.DisableHostname = true
|
||||||
}
|
}
|
||||||
|
|
|
@ -181,6 +181,10 @@ func TestDecodeConfig(t *testing.T) {
|
||||||
in: `{"autopilot":{"disable_upgrade_migration":true}}`,
|
in: `{"autopilot":{"disable_upgrade_migration":true}}`,
|
||||||
c: &Config{Autopilot: Autopilot{DisableUpgradeMigration: Bool(true)}},
|
c: &Config{Autopilot: Autopilot{DisableUpgradeMigration: Bool(true)}},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
in: `{"autopilot":{"upgrade_version_tag":"rev"}}`,
|
||||||
|
c: &Config{Autopilot: Autopilot{UpgradeVersionTag: "rev"}},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
in: `{"autopilot":{"last_contact_threshold":"2s"}}`,
|
in: `{"autopilot":{"last_contact_threshold":"2s"}}`,
|
||||||
c: &Config{Autopilot: Autopilot{LastContactThreshold: Duration(2 * time.Second), LastContactThresholdRaw: "2s"}},
|
c: &Config{Autopilot: Autopilot{LastContactThreshold: Duration(2 * time.Second), LastContactThresholdRaw: "2s"}},
|
||||||
|
|
|
@ -3,6 +3,7 @@ package state
|
||||||
import (
|
import (
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/hashicorp/consul/agent/consul/structs"
|
"github.com/hashicorp/consul/agent/consul/structs"
|
||||||
)
|
)
|
||||||
|
@ -12,6 +13,12 @@ func TestStateStore_Autopilot(t *testing.T) {
|
||||||
|
|
||||||
expected := &structs.AutopilotConfig{
|
expected := &structs.AutopilotConfig{
|
||||||
CleanupDeadServers: true,
|
CleanupDeadServers: true,
|
||||||
|
LastContactThreshold: 5 * time.Second,
|
||||||
|
MaxTrailingLogs: 500,
|
||||||
|
ServerStabilizationTime: 100 * time.Second,
|
||||||
|
RedundancyZoneTag: "az",
|
||||||
|
DisableUpgradeMigration: true,
|
||||||
|
UpgradeVersionTag: "build",
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := s.AutopilotSetConfig(0, expected); err != nil {
|
if err := s.AutopilotSetConfig(0, expected); err != nil {
|
||||||
|
|
|
@ -35,6 +35,10 @@ type AutopilotConfig struct {
|
||||||
// cluster before promoting them to voters.
|
// cluster before promoting them to voters.
|
||||||
DisableUpgradeMigration bool
|
DisableUpgradeMigration bool
|
||||||
|
|
||||||
|
// (Enterprise-only) UpgradeVersionTag is the node tag to use for version info when
|
||||||
|
// performing upgrade migrations. If left blank, the Consul version will be used.
|
||||||
|
UpgradeVersionTag string
|
||||||
|
|
||||||
// RaftIndex stores the create/modify indexes of this configuration.
|
// RaftIndex stores the create/modify indexes of this configuration.
|
||||||
RaftIndex
|
RaftIndex
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,10 @@ type AutopilotConfiguration struct {
|
||||||
// cluster before promoting them to voters.
|
// cluster before promoting them to voters.
|
||||||
DisableUpgradeMigration bool
|
DisableUpgradeMigration bool
|
||||||
|
|
||||||
|
// (Enterprise-only) UpgradeVersionTag is the node tag to use for version info when
|
||||||
|
// performing upgrade migrations. If left blank, the Consul version will be used.
|
||||||
|
UpgradeVersionTag string
|
||||||
|
|
||||||
// CreateIndex holds the index corresponding the creation of this configuration.
|
// CreateIndex holds the index corresponding the creation of this configuration.
|
||||||
// This is a read-only field.
|
// This is a read-only field.
|
||||||
CreateIndex uint64
|
CreateIndex uint64
|
||||||
|
|
Loading…
Reference in New Issue