From 6623dddf1815e7e5e9a8e13bf1b0236a88cca3ab Mon Sep 17 00:00:00 2001 From: Michael Schurter Date: Wed, 1 Dec 2021 14:36:02 -0800 Subject: [PATCH] core: remove all traces of unused protocol version Nomad inherited protocol version numbering configuration from Consul and Serf, but unlike those projects Nomad has never used it. Nomad's `protocol_version` has always been `1`. While the code is effectively unused and therefore poses no runtime risks to leave, I felt like removing it was best because: 1. Nomad's RPC subsystem has been able to evolve extensively without needing to increment the version number. 2. Nomad's HTTP API has evolved extensively without increment `API{Major,Minor}Version`. If we want to version the HTTP API in the future, I doubt this is the mechanism we would choose. 3. The presence of the `server.protocol_version` configuration parameter is confusing since `server.raft_protocol` *is* an important parameter for operators to consider. Even more confusing is that there is a distinct Serf protocol version which is included in `nomad server members` output under the heading `Protocol`. `raft_protocol` is the *only* protocol version relevant to Nomad developers and operators. The other protocol versions are either deadcode or have never changed (Serf). 4. If we were to need to version the RPC, HTTP API, or Serf protocols, I don't think these configuration parameters and variables are the best choice. If we come to that point we should choose a versioning scheme based on the use case and modern best practices -- not this 6+ year old dead code. --- client/client.go | 14 +--- client/rpc.go | 4 +- command/agent/agent.go | 3 - command/agent/command.go | 6 ++ command/agent/config.go | 2 + command/agent/testdata/basic.hcl | 1 - command/agent/testdata/basic.json | 1 - e2e/terraform/.terraform.lock.hcl | 8 +++ helper/pool/pool.go | 22 +++--- nomad/client_rpc.go | 3 +- nomad/config.go | 35 --------- nomad/eval_broker.go | 2 + nomad/node_endpoint.go | 2 - nomad/rpc.go | 8 +-- nomad/serf.go | 2 +- nomad/server.go | 9 +-- nomad/stats_fetcher.go | 2 +- nomad/status_endpoint.go | 17 ----- nomad/structs/structs.go | 15 ---- nomad/util.go | 71 +++++++------------ website/content/api-docs/agent.mdx | 3 - website/content/docs/configuration/server.mdx | 5 -- 22 files changed, 66 insertions(+), 169 deletions(-) diff --git a/client/client.go b/client/client.go index 8b6d0ad75e2a..d0cc7467a370 100644 --- a/client/client.go +++ b/client/client.go @@ -749,18 +749,6 @@ func (c *Client) secretNodeID() string { return c.config.Node.SecretID } -// RPCMajorVersion returns the structs.ApiMajorVersion supported by the -// client. -func (c *Client) RPCMajorVersion() int { - return structs.ApiMajorVersion -} - -// RPCMinorVersion returns the structs.ApiMinorVersion supported by the -// client. -func (c *Client) RPCMinorVersion() int { - return structs.ApiMinorVersion -} - // Shutdown is used to tear down the client func (c *Client) Shutdown() error { c.shutdownLock.Lock() @@ -2773,7 +2761,7 @@ DISCOLOOP: continue } var peers []string - if err := c.connPool.RPC(region, addr, c.RPCMajorVersion(), "Status.Peers", rpcargs, &peers); err != nil { + if err := c.connPool.RPC(region, addr, "Status.Peers", rpcargs, &peers); err != nil { mErr.Errors = append(mErr.Errors, err) continue } diff --git a/client/rpc.go b/client/rpc.go index 01c0bf358695..2a94a1835a1a 100644 --- a/client/rpc.go +++ b/client/rpc.go @@ -74,7 +74,7 @@ TRY: } // Make the request. - rpcErr := c.connPool.RPC(c.Region(), server.Addr, c.RPCMajorVersion(), method, args, reply) + rpcErr := c.connPool.RPC(c.Region(), server.Addr, method, args, reply) if rpcErr == nil { c.fireRpcRetryWatcher() @@ -427,7 +427,7 @@ func resolveServer(s string) (net.Addr, error) { // a potential error. func (c *Client) Ping(srv net.Addr) error { var reply struct{} - err := c.connPool.RPC(c.Region(), srv, c.RPCMajorVersion(), "Status.Ping", struct{}{}, &reply) + err := c.connPool.RPC(c.Region(), srv, "Status.Ping", struct{}{}, &reply) return err } diff --git a/command/agent/agent.go b/command/agent/agent.go index b070de555968..4d6c51f8a5bf 100644 --- a/command/agent/agent.go +++ b/command/agent/agent.go @@ -191,9 +191,6 @@ func convertServerConfig(agentConfig *Config) (*nomad.Config, error) { if agentConfig.Server.DataDir != "" { conf.DataDir = agentConfig.Server.DataDir } - if agentConfig.Server.ProtocolVersion != 0 { - conf.ProtocolVersion = uint8(agentConfig.Server.ProtocolVersion) - } if agentConfig.Server.RaftProtocol != 0 { conf.RaftConfig.ProtocolVersion = raft.ProtocolVersion(agentConfig.Server.RaftProtocol) } diff --git a/command/agent/command.go b/command/agent/command.go index 558e63ee120e..b78a47e4c0cc 100644 --- a/command/agent/command.go +++ b/command/agent/command.go @@ -413,6 +413,12 @@ func (c *Command) isValidConfig(config, cmdConfig *Config) bool { } } + // ProtocolVersion has never been used. Warn if it is set as someone + // has probably made a mistake. + if config.Server.ProtocolVersion != 0 { + c.agent.logger.Warn("Please remove deprecated protocol_version field from config.") + } + return true } diff --git a/command/agent/config.go b/command/agent/config.go index 2a18f0e2a8a7..832c4c233b17 100644 --- a/command/agent/config.go +++ b/command/agent/config.go @@ -385,6 +385,8 @@ type ServerConfig struct { // ProtocolVersion is the protocol version to speak. This must be between // ProtocolVersionMin and ProtocolVersionMax. + // + // Deprecated: This has never been used and will emit a warning if nonzero. ProtocolVersion int `hcl:"protocol_version"` // RaftProtocol is the Raft protocol version to speak. This must be from [1-3]. diff --git a/command/agent/testdata/basic.hcl b/command/agent/testdata/basic.hcl index c28cdfd938fe..27754b957573 100644 --- a/command/agent/testdata/basic.hcl +++ b/command/agent/testdata/basic.hcl @@ -106,7 +106,6 @@ server { authoritative_region = "foobar" bootstrap_expect = 5 data_dir = "/tmp/data" - protocol_version = 3 raft_protocol = 3 num_schedulers = 2 enabled_schedulers = ["test"] diff --git a/command/agent/testdata/basic.json b/command/agent/testdata/basic.json index a92d7748d503..406e314a960a 100644 --- a/command/agent/testdata/basic.json +++ b/command/agent/testdata/basic.json @@ -277,7 +277,6 @@ "node_gc_threshold": "12h", "non_voting_server": true, "num_schedulers": 2, - "protocol_version": 3, "raft_protocol": 3, "raft_multiplier": 4, "redundancy_zone": "foo", diff --git a/e2e/terraform/.terraform.lock.hcl b/e2e/terraform/.terraform.lock.hcl index 0b3477d0ded3..b84256fd235c 100644 --- a/e2e/terraform/.terraform.lock.hcl +++ b/e2e/terraform/.terraform.lock.hcl @@ -5,6 +5,7 @@ provider "registry.terraform.io/hashicorp/aws" { version = "3.55.0" hashes = [ "h1:Ls8MD4Olzybw9n0mP5Lr1S2PnZzlSKrpxvYN9u2p/dM=", + "h1:pQzssRQ6BMdyO65Lq5PRx766l8swjcCNKrNyCkcJa6I=", "zh:1795562df65e9e5a604c90fac17ab1a706bc398b38271a11bc43565d45532595", "zh:266fd71ace988b5fecd72dae5f2f503e953a4d2ea51d8d490d22d1218b1407dc", "zh:4b2daf1038352fb33df40a2bf9033f66383bb1f6509df70da08f86f4539df9f3", @@ -23,6 +24,7 @@ provider "registry.terraform.io/hashicorp/external" { version = "2.1.0" hashes = [ "h1:LTl5CGW8wiIEe16AC4MtXN/95xWWNDbap70zJsBTk0w=", + "h1:wbtDfLeawmv6xVT1W0w0fctRCb4ABlaD3JTxwb1jXag=", "zh:0d83ffb72fbd08986378204a7373d8c43b127049096eaf2765bfdd6b00ad9853", "zh:7577d6edc67b1e8c2cf62fe6501192df1231d74125d90e51d570d586d95269c5", "zh:9c669ded5d5affa4b2544952c4b6588dfed55260147d24ced02dca3a2829f328", @@ -41,6 +43,7 @@ provider "registry.terraform.io/hashicorp/http" { version = "2.1.0" hashes = [ "h1:GYoVrTtiSAE3AlP1fad3fFmHoPaXAPhm/DJyMcVCwZA=", + "h1:HmUcHqc59VeHReHD2SEhnLVQPUKHKTipJ8Jxq67GiDU=", "zh:03d82dc0887d755b8406697b1d27506bc9f86f93b3e9b4d26e0679d96b802826", "zh:0704d02926393ddc0cfad0b87c3d51eafeeae5f9e27cc71e193c141079244a22", "zh:095ea350ea94973e043dad2394f10bca4a4bf41be775ba59d19961d39141d150", @@ -58,6 +61,7 @@ provider "registry.terraform.io/hashicorp/http" { provider "registry.terraform.io/hashicorp/local" { version = "2.1.0" hashes = [ + "h1:EYZdckuGU3n6APs97nS2LxZm3dDtGqyM4qaIvsmac8o=", "h1:KfieWtVyGWwplSoLIB5usKAUnrIkDQBkWaR5TI+4WYg=", "zh:0f1ec65101fa35050978d483d6e8916664b7556800348456ff3d09454ac1eae2", "zh:36e42ac19f5d68467aacf07e6adcf83c7486f2e5b5f4339e9671f68525fc87ab", @@ -76,6 +80,7 @@ provider "registry.terraform.io/hashicorp/local" { provider "registry.terraform.io/hashicorp/null" { version = "3.1.0" hashes = [ + "h1:vpC6bgUQoJ0znqIKVFevOdq+YQw42bRq0u+H3nto8nA=", "h1:xhbHC6in3nQryvTQBWKxebi3inG5OCgHgc4fRxL0ymc=", "zh:02a1675fd8de126a00460942aaae242e65ca3380b5bb192e8773ef3da9073fd2", "zh:53e30545ff8926a8e30ad30648991ca8b93b6fa496272cd23b26763c8ee84515", @@ -94,6 +99,7 @@ provider "registry.terraform.io/hashicorp/null" { provider "registry.terraform.io/hashicorp/random" { version = "3.1.0" hashes = [ + "h1:BZMEPucF+pbu9gsPk0G0BHx7YP04+tKdq2MrRDF1EDM=", "h1:rKYu5ZUbXwrLG1w81k7H3nce/Ys6yAxXhWcbtk36HjY=", "zh:2bbb3339f0643b5daa07480ef4397bd23a79963cc364cdfbb4e86354cb7725bc", "zh:3cd456047805bf639fbf2c761b1848880ea703a054f76db51852008b11008626", @@ -113,6 +119,7 @@ provider "registry.terraform.io/hashicorp/template" { version = "2.2.0" hashes = [ "h1:0wlehNaxBX7GJQnPfQwTNvvAf38Jm0Nv7ssKGMaG6Og=", + "h1:94qn780bi1qjrbC3uQtjJh3Wkfwd5+tTtJHOb7KTg9w=", "zh:01702196f0a0492ec07917db7aaa595843d8f171dc195f4c988d2ffca2a06386", "zh:09aae3da826ba3d7df69efeb25d146a1de0d03e951d35019a0f80e4f58c89b53", "zh:09ba83c0625b6fe0a954da6fbd0c355ac0b7f07f86c91a2a97849140fea49603", @@ -130,6 +137,7 @@ provider "registry.terraform.io/hashicorp/tls" { version = "3.1.0" hashes = [ "h1:XTU9f6sGMZHOT8r/+LWCz2BZOPH127FBTPjMMEAAu1U=", + "h1:fUJX8Zxx38e2kBln+zWr1Tl41X+OuiE++REjrEyiOM4=", "zh:3d46616b41fea215566f4a957b6d3a1aa43f1f75c26776d72a98bdba79439db6", "zh:623a203817a6dafa86f1b4141b645159e07ec418c82fe40acd4d2a27543cbaa2", "zh:668217e78b210a6572e7b0ecb4134a6781cc4d738f4f5d09eb756085b082592e", diff --git a/helper/pool/pool.go b/helper/pool/pool.go index f1899d11f298..d173b7c04134 100644 --- a/helper/pool/pool.go +++ b/helper/pool/pool.go @@ -48,7 +48,6 @@ type Conn struct { addr net.Addr session *yamux.Session lastUsed time.Time - version int pool *ConnPool @@ -278,7 +277,7 @@ func (p *ConnPool) SetConnListener(l chan<- *Conn) { // Acquire is used to get a connection that is // pooled or to return a new connection -func (p *ConnPool) acquire(region string, addr net.Addr, version int) (*Conn, error) { +func (p *ConnPool) acquire(region string, addr net.Addr) (*Conn, error) { // Check to see if there's a pooled connection available. This is up // here since it should the vastly more common case than the rest // of the code here. @@ -305,7 +304,7 @@ func (p *ConnPool) acquire(region string, addr net.Addr, version int) (*Conn, er // If we are the lead thread, make the new connection and then wake // everybody else up to see if we got it. if isLeadThread { - c, err := p.getNewConn(region, addr, version) + c, err := p.getNewConn(region, addr) p.Lock() delete(p.limiter, addr.String()) close(wait) @@ -349,7 +348,7 @@ func (p *ConnPool) acquire(region string, addr net.Addr, version int) (*Conn, er } // getNewConn is used to return a new connection -func (p *ConnPool) getNewConn(region string, addr net.Addr, version int) (*Conn, error) { +func (p *ConnPool) getNewConn(region string, addr net.Addr) (*Conn, error) { // Try to dial the conn conn, err := net.DialTimeout("tcp", addr.String(), 10*time.Second) if err != nil { @@ -404,7 +403,6 @@ func (p *ConnPool) getNewConn(region string, addr net.Addr, version int) (*Conn, session: session, clients: list.New(), lastUsed: time.Now(), - version: version, pool: p, } return c, nil @@ -429,12 +427,12 @@ func (p *ConnPool) clearConn(conn *Conn) { } } -// getClient is used to get a usable client for an address and protocol version -func (p *ConnPool) getRPCClient(region string, addr net.Addr, version int) (*Conn, *StreamClient, error) { +// getClient is used to get a usable client for an address +func (p *ConnPool) getRPCClient(region string, addr net.Addr) (*Conn, *StreamClient, error) { retries := 0 START: // Try to get a conn first - conn, err := p.acquire(region, addr, version) + conn, err := p.acquire(region, addr) if err != nil { return nil, nil, fmt.Errorf("failed to get conn: %v", err) } @@ -457,8 +455,8 @@ START: // StreamingRPC is used to make an streaming RPC call. Callers must // close the connection when done. -func (p *ConnPool) StreamingRPC(region string, addr net.Addr, version int) (net.Conn, error) { - conn, err := p.acquire(region, addr, version) +func (p *ConnPool) StreamingRPC(region string, addr net.Addr) (net.Conn, error) { + conn, err := p.acquire(region, addr) if err != nil { return nil, fmt.Errorf("failed to get conn: %v", err) } @@ -477,9 +475,9 @@ func (p *ConnPool) StreamingRPC(region string, addr net.Addr, version int) (net. } // RPC is used to make an RPC call to a remote host -func (p *ConnPool) RPC(region string, addr net.Addr, version int, method string, args interface{}, reply interface{}) error { +func (p *ConnPool) RPC(region string, addr net.Addr, method string, args interface{}, reply interface{}) error { // Get a usable client - conn, sc, err := p.getRPCClient(region, addr, version) + conn, sc, err := p.getRPCClient(region, addr) if err != nil { return fmt.Errorf("rpc error: %w", err) } diff --git a/nomad/client_rpc.go b/nomad/client_rpc.go index 1c3471d1962f..74f08db6a86c 100644 --- a/nomad/client_rpc.go +++ b/nomad/client_rpc.go @@ -188,8 +188,7 @@ func (s *Server) serverWithNodeConn(nodeID, region string) (*serverParts, error) // Make the RPC var resp structs.NodeConnQueryResponse - err := s.connPool.RPC(s.config.Region, server.Addr, server.MajorVersion, - "Status.HasNodeConn", &req, &resp) + err := s.connPool.RPC(s.config.Region, server.Addr, "Status.HasNodeConn", &req, &resp) if err != nil { multierror.Append(&rpcErr, fmt.Errorf("failed querying server %q: %v", server.Addr.String(), err)) continue diff --git a/nomad/config.go b/nomad/config.go index 3ffe823f56c0..696080dfc22b 100644 --- a/nomad/config.go +++ b/nomad/config.go @@ -1,7 +1,6 @@ package nomad import ( - "fmt" "io" "net" "os" @@ -27,23 +26,6 @@ const ( DefaultSerfPort = 4648 ) -// These are the protocol versions that Nomad can understand -const ( - ProtocolVersionMin uint8 = 1 - ProtocolVersionMax = 1 -) - -// ProtocolVersionMap is the mapping of Nomad protocol versions -// to Serf protocol versions. We mask the Serf protocols using -// our own protocol version. -var protocolVersionMap map[uint8]uint8 - -func init() { - protocolVersionMap = map[uint8]uint8{ - 1: 4, - } -} - func DefaultRPCAddr() *net.TCPAddr { return &net.TCPAddr{IP: net.ParseIP("127.0.0.1"), Port: 4647} } @@ -93,10 +75,6 @@ type Config struct { // Logger is the logger used by the server. Logger log.InterceptLogger - // ProtocolVersion is the protocol version to speak. This must be between - // ProtocolVersionMin and ProtocolVersionMax. - ProtocolVersion uint8 - // RPCAddr is the RPC address used by Nomad. This should be reachable // by the other servers and clients RPCAddr *net.TCPAddr @@ -370,18 +348,6 @@ type Config struct { DeploymentQueryRateLimit float64 } -// CheckVersion is used to check if the ProtocolVersion is valid -func (c *Config) CheckVersion() error { - if c.ProtocolVersion < ProtocolVersionMin { - return fmt.Errorf("Protocol version '%d' too low. Must be in range: [%d, %d]", - c.ProtocolVersion, ProtocolVersionMin, ProtocolVersionMax) - } else if c.ProtocolVersion > ProtocolVersionMax { - return fmt.Errorf("Protocol version '%d' too high. Must be in range: [%d, %d]", - c.ProtocolVersion, ProtocolVersionMin, ProtocolVersionMax) - } - return nil -} - // DefaultConfig returns the default configuration. Only used as the basis for // merging agent or test parameters. func DefaultConfig() *Config { @@ -396,7 +362,6 @@ func DefaultConfig() *Config { Datacenter: DefaultDC, NodeName: hostname, NodeID: uuid.Generate(), - ProtocolVersion: ProtocolVersionMax, RaftConfig: raft.DefaultConfig(), RaftTimeout: 10 * time.Second, LogOutput: os.Stderr, diff --git a/nomad/eval_broker.go b/nomad/eval_broker.go index 0a6a9f185643..60cf0c604103 100644 --- a/nomad/eval_broker.go +++ b/nomad/eval_broker.go @@ -274,6 +274,8 @@ func (b *EvalBroker) enqueueWaiting(eval *structs.Evaluation) { } // enqueueLocked is used to enqueue with the lock held +// +// Are all evaluations we're enqueueing at this point pending? <--- func (b *EvalBroker) enqueueLocked(eval *structs.Evaluation, queue string) { // Do nothing if not enabled if !b.enabled { diff --git a/nomad/node_endpoint.go b/nomad/node_endpoint.go index 75e236947998..5bb313e03151 100644 --- a/nomad/node_endpoint.go +++ b/nomad/node_endpoint.go @@ -267,8 +267,6 @@ func (n *Node) constructNodeServerInfoResponse(snap *state.StateSnapshot, reply reply.Servers = append(reply.Servers, &structs.NodeServerInfo{ RPCAdvertiseAddr: v.RPCAddr.String(), - RPCMajorVersion: int32(v.MajorVersion), - RPCMinorVersion: int32(v.MinorVersion), Datacenter: v.Datacenter, }) } diff --git a/nomad/rpc.go b/nomad/rpc.go index 869c5bacb9e6..4d5cd6e127b6 100644 --- a/nomad/rpc.go +++ b/nomad/rpc.go @@ -612,7 +612,7 @@ func (r *rpcHandler) forwardLeader(server *serverParts, method string, args inte if server == nil { return structs.ErrNoLeader } - return r.connPool.RPC(r.config.Region, server.Addr, server.MajorVersion, method, args, reply) + return r.connPool.RPC(r.config.Region, server.Addr, method, args, reply) } // forwardServer is used to forward an RPC call to a particular server @@ -621,7 +621,7 @@ func (r *rpcHandler) forwardServer(server *serverParts, method string, args inte if server == nil { return errors.New("must be given a valid server address") } - return r.connPool.RPC(r.config.Region, server.Addr, server.MajorVersion, method, args, reply) + return r.connPool.RPC(r.config.Region, server.Addr, method, args, reply) } func (r *rpcHandler) findRegionServer(region string) (*serverParts, error) { @@ -648,7 +648,7 @@ func (r *rpcHandler) forwardRegion(region, method string, args interface{}, repl // Forward to remote Nomad metrics.IncrCounter([]string{"nomad", "rpc", "cross-region", region}, 1) - return r.connPool.RPC(region, server.Addr, server.MajorVersion, method, args, reply) + return r.connPool.RPC(region, server.Addr, method, args, reply) } func (r *rpcHandler) getServer(region, serverID string) (*serverParts, error) { @@ -676,7 +676,7 @@ func (r *rpcHandler) getServer(region, serverID string) (*serverParts, error) { // initial handshake, returning the connection or an error. It is the callers // responsibility to close the connection if there is no returned error. func (r *rpcHandler) streamingRpc(server *serverParts, method string) (net.Conn, error) { - c, err := r.connPool.StreamingRPC(r.config.Region, server.Addr, server.MajorVersion) + c, err := r.connPool.StreamingRPC(r.config.Region, server.Addr) if err != nil { return nil, err } diff --git a/nomad/serf.go b/nomad/serf.go index 0e63630bbe37..6e5a0a2d16e1 100644 --- a/nomad/serf.go +++ b/nomad/serf.go @@ -164,7 +164,7 @@ func (s *Server) maybeBootstrap() { // Retry with exponential backoff to get peer status from this server for attempt := uint(0); attempt < maxPeerRetries; attempt++ { - if err := s.connPool.RPC(s.config.Region, server.Addr, server.MajorVersion, + if err := s.connPool.RPC(s.config.Region, server.Addr, "Status.Peers", req, &peers); err != nil { nextRetry := (1 << attempt) * peerRetryBase s.logger.Error("failed to confirm peer status", "peer", server.Name, "error", err, "retry", nextRetry) diff --git a/nomad/server.go b/nomad/server.go index 557ed1759620..45923629e2b4 100644 --- a/nomad/server.go +++ b/nomad/server.go @@ -88,6 +88,8 @@ const ( // aclCacheSize is the number of ACL objects to keep cached. ACLs have a parsing and // construction cost, so we keep the hot objects cached to reduce the ACL token resolution time. aclCacheSize = 512 + + // serfProtocolVersion is the ) // Server is Nomad server which manages the job queues, @@ -289,10 +291,6 @@ type endpoints struct { // NewServer is used to construct a new Nomad server from the // configuration, potentially returning an error func NewServer(config *Config, consulCatalog consul.CatalogAPI, consulConfigEntries consul.ConfigAPI, consulACLs consul.ACLsAPI) (*Server, error) { - // Check the protocol version - if err := config.CheckVersion(); err != nil { - return nil, err - } // Create an eval broker evalBroker, err := NewEvalBroker( @@ -1380,8 +1378,6 @@ func (s *Server) setupSerf(conf *serf.Config, ch chan serf.Event, path string) ( conf.Tags["role"] = "nomad" conf.Tags["region"] = s.config.Region conf.Tags["dc"] = s.config.Datacenter - conf.Tags["vsn"] = fmt.Sprintf("%d", structs.ApiMajorVersion) - conf.Tags["mvn"] = fmt.Sprintf("%d", structs.ApiMinorVersion) conf.Tags["build"] = s.config.Build conf.Tags["raft_vsn"] = fmt.Sprintf("%d", s.config.RaftConfig.ProtocolVersion) conf.Tags["id"] = s.config.NodeID @@ -1415,7 +1411,6 @@ func (s *Server) setupSerf(conf *serf.Config, ch chan serf.Event, path string) ( return nil, err } } - conf.ProtocolVersion = protocolVersionMap[s.config.ProtocolVersion] conf.RejoinAfterLeave = true // LeavePropagateDelay is used to make sure broadcasted leave intents propagate // This value was tuned using https://www.serf.io/docs/internals/simulator.html to diff --git a/nomad/stats_fetcher.go b/nomad/stats_fetcher.go index 475d013d833b..9967698b6cab 100644 --- a/nomad/stats_fetcher.go +++ b/nomad/stats_fetcher.go @@ -43,7 +43,7 @@ func NewStatsFetcher(logger log.Logger, pool *pool.ConnPool, region string) *Sta func (f *StatsFetcher) fetch(server *serverParts, replyCh chan *autopilot.ServerStats) { var args struct{} var reply autopilot.ServerStats - err := f.pool.RPC(f.region, server.Addr, server.MajorVersion, "Status.RaftStats", &args, &reply) + err := f.pool.RPC(f.region, server.Addr, "Status.RaftStats", &args, &reply) if err != nil { f.logger.Warn("failed retrieving server health", "server", server.Name, "error", err) } else { diff --git a/nomad/status_endpoint.go b/nomad/status_endpoint.go index 543f160af3be..7b87afee7fb9 100644 --- a/nomad/status_endpoint.go +++ b/nomad/status_endpoint.go @@ -17,23 +17,6 @@ type Status struct { logger log.Logger } -// Version is used to allow clients to determine the capabilities -// of the server -func (s *Status) Version(args *structs.GenericRequest, reply *structs.VersionResponse) error { - if done, err := s.srv.forward("Status.Version", args, args, reply); done { - return err - } - - conf := s.srv.config - reply.Build = conf.Build - reply.Versions = map[string]int{ - structs.ProtocolVersion: int(conf.ProtocolVersion), - structs.APIMajorVersion: structs.ApiMajorVersion, - structs.APIMinorVersion: structs.ApiMinorVersion, - } - return nil -} - // Ping is used to just check for connectivity func (s *Status) Ping(args struct{}, reply *struct{}) error { return nil diff --git a/nomad/structs/structs.go b/nomad/structs/structs.go index 50f9f640b7cb..29651b7e0f05 100644 --- a/nomad/structs/structs.go +++ b/nomad/structs/structs.go @@ -122,21 +122,6 @@ const ( // methods directly that require an FSM MessageType MsgTypeTestSetup MessageType = IgnoreUnknownTypeFlag - // ApiMajorVersion is returned as part of the Status.Version request. - // It should be incremented anytime the APIs are changed in a way - // that would break clients for sane client versioning. - ApiMajorVersion = 1 - - // ApiMinorVersion is returned as part of the Status.Version request. - // It should be incremented anytime the APIs are changed to allow - // for sane client versioning. Minor changes should be compatible - // within the major version. - ApiMinorVersion = 1 - - ProtocolVersion = "protocol" - APIMajorVersion = "api.major" - APIMinorVersion = "api.minor" - GetterModeAny = "any" GetterModeFile = "file" GetterModeDir = "dir" diff --git a/nomad/util.go b/nomad/util.go index 2a5f5b0daf33..ae0c734e6809 100644 --- a/nomad/util.go +++ b/nomad/util.go @@ -30,21 +30,19 @@ func ensurePath(path string, dir bool) error { // serverParts is used to return the parts of a server role type serverParts struct { - Name string - ID string - Region string - Datacenter string - Port int - Bootstrap bool - Expect int - MajorVersion int - MinorVersion int - Build version.Version - RaftVersion int - Addr net.Addr - RPCAddr net.Addr - Status serf.MemberStatus - NonVoter bool + Name string + ID string + Region string + Datacenter string + Port int + Bootstrap bool + Expect int + Build version.Version + RaftVersion int + Addr net.Addr + RPCAddr net.Addr + Status serf.MemberStatus + NonVoter bool } func (s *serverParts) String() string { @@ -100,21 +98,6 @@ func isNomadServer(m serf.Member) (bool, *serverParts) { return false, nil } - // The "vsn" tag was Version, which is now the MajorVersion number. - majorVersionStr := m.Tags["vsn"] - majorVersion, err := strconv.Atoi(majorVersionStr) - if err != nil { - return false, nil - } - - // To keep some semblance of convention, "mvn" is now the "Minor - // Version Number." - minorVersionStr := m.Tags["mvn"] - minorVersion, err := strconv.Atoi(minorVersionStr) - if err != nil { - minorVersion = 0 - } - raftVsn := 0 raftVsnString, ok := m.Tags["raft_vsn"] if ok { @@ -130,21 +113,19 @@ func isNomadServer(m serf.Member) (bool, *serverParts) { addr := &net.TCPAddr{IP: m.Addr, Port: port} rpcAddr := &net.TCPAddr{IP: rpcIP, Port: port} parts := &serverParts{ - Name: m.Name, - ID: id, - Region: region, - Datacenter: datacenter, - Port: port, - Bootstrap: bootstrap, - Expect: expect, - Addr: addr, - RPCAddr: rpcAddr, - MajorVersion: majorVersion, - MinorVersion: minorVersion, - Build: *buildVersion, - RaftVersion: raftVsn, - Status: m.Status, - NonVoter: nonVoter, + Name: m.Name, + ID: id, + Region: region, + Datacenter: datacenter, + Port: port, + Bootstrap: bootstrap, + Expect: expect, + Addr: addr, + RPCAddr: rpcAddr, + Build: *buildVersion, + RaftVersion: raftVsn, + Status: m.Status, + NonVoter: nonVoter, } return true, parts } diff --git a/website/content/api-docs/agent.mdx b/website/content/api-docs/agent.mdx index e62a451054b3..542f247d3ac8 100644 --- a/website/content/api-docs/agent.mdx +++ b/website/content/api-docs/agent.mdx @@ -354,9 +354,6 @@ $ curl \ "latest_configuration": "[{Suffrage:Voter ID:127.0.0.1:4647 Address:127.0.0.1:4647}]", "last_contact": "never", "applied_index": "144", - "protocol_version": "1", - "protocol_version_min": "0", - "snapshot_version_min": "0", "state": "Leader", "last_snapshot_term": "0" }, diff --git a/website/content/docs/configuration/server.mdx b/website/content/docs/configuration/server.mdx index 8e6eeaa43c57..1c2c7f86e987 100644 --- a/website/content/docs/configuration/server.mdx +++ b/website/content/docs/configuration/server.mdx @@ -156,11 +156,6 @@ server { disallow this server from making any scheduling decisions. This defaults to the number of CPU cores. -- `protocol_version` `(int: 1)` - Specifies the Nomad protocol version to use - when communicating with other Nomad servers. This value is typically not - required as the agent internally knows the latest version, but may be useful - in some upgrade scenarios. - - `raft_protocol` `(int: 2)` - 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