agent: Support protocol version setting

This commit is contained in:
Armon Dadgar 2014-03-09 15:57:03 -07:00
parent 1f8f875b12
commit ffca4f5544
6 changed files with 19 additions and 4 deletions

View File

@ -165,6 +165,9 @@ func (a *Agent) consulConfig() *consul.Config {
if a.config.Bootstrap {
base.Bootstrap = true
}
if a.config.Protocol > 0 {
base.ProtocolVersion = uint8(a.config.Protocol)
}
// Setup the ServerUp callback
base.ServerUp = a.state.ConsulServerUp

View File

@ -61,6 +61,7 @@ func (c *Command) readConfig() *Config {
cmdFlags.BoolVar(&cmdConfig.Server, "server", false, "run agent as server")
cmdFlags.BoolVar(&cmdConfig.Bootstrap, "bootstrap", false, "enable server bootstrap mode")
cmdFlags.StringVar(&cmdConfig.StatsiteAddr, "statsite", "", "address of statsite instance")
cmdFlags.IntVar(&cmdConfig.Protocol, "protocol", -1, "protocol version")
if err := cmdFlags.Parse(c.args); err != nil {
return nil
}

View File

@ -97,6 +97,9 @@ type Config struct {
// metrics will be streamed to that instance.
StatsiteAddr string `mapstructure:"statsite_addr"`
// Protocol is the Consul protocol version to use.
Protocol int `mapstructure:"protocol"`
// Checks holds the provided check definitions
Checks []*CheckDefinition `mapstructure:"-"`
@ -122,6 +125,7 @@ func DefaultConfig() *Config {
SerfLanPort: consul.DefaultLANSerfPort,
SerfWanPort: consul.DefaultWANSerfPort,
Server: false,
Protocol: consul.ProtocolVersionMax,
}
}
@ -284,6 +288,9 @@ func MergeConfig(a, b *Config) *Config {
if b.LogLevel != "" {
result.LogLevel = b.LogLevel
}
if b.Protocol > 0 {
result.Protocol = b.Protocol
}
if b.NodeName != "" {
result.NodeName = b.NodeName
}

View File

@ -118,6 +118,10 @@ The options below are all specified on the command-line.
various telemetry information to that instance for aggregation. This can be used to capture various
runtime information.
* `-protocol` - The Consul protocol version to use. This defaults to the latest
version. This should be set only when [upgrading](/docs/upgrading.html).
You can view the protocol versions supported by Consul by running `serf -v`.
## Configuration Files
In addition to the command-line options, configuration can be put into

View File

@ -34,7 +34,7 @@ upgrading, see the [upgrading page](/docs/upgrading.html).
</tr>
<tr>
<td>0.1</td>
<td>0</td>
<td>1</td>
</tr>
</table>

View File

@ -22,13 +22,13 @@ below, assume you're running version A of Consul, and then version B comes out.
2. Shut down version A, and start version B with the `-protocol=PREVIOUS`
flag, where "PREVIOUS" is the protocol version of version A (which can
be discovered by running `consul -v` or `consul members -detailed`).
be discovered by running `consul -v` or `consul members`).
3. Once all nodes are running version B, go through every node and restart
the version B agent _without_ the `-protocol` flag.
4. Done! You're now running the latest Consul agent speaking the latest protocol.
You can verify this is the case by running `consul members -detailed` to
You can verify this is the case by running `consul members` to
make sure all members are speaking the same, latest protocol version.
The key to making this work is the [protocol compatibility](/docs/compatibility.html)
@ -46,7 +46,7 @@ running `consul -v`. You'll see output similar to that below:
```
$ consul -v
Consul v0.1.0
Agent Protocol: 1 (Understands back to: 0)
Consul Protocol: 1 (Understands back to: 1)
```
This says the version of Consul as well as the latest protocol version (1,