diff --git a/client/rpc.go b/client/rpc.go index a36c1acbd..231e1dbb4 100644 --- a/client/rpc.go +++ b/client/rpc.go @@ -11,7 +11,6 @@ import ( "github.com/hashicorp/consul/lib" "github.com/hashicorp/nomad/helper/codec" "github.com/hashicorp/nomad/helper/pool" - "github.com/hashicorp/nomad/nomad" "github.com/hashicorp/nomad/nomad/structs" "github.com/hashicorp/yamux" ) @@ -69,7 +68,7 @@ TRY: // We can wait a bit and retry! if time.Since(firstCheck) < c.config.RPCHoldTimeout { - jitter := lib.RandomStagger(c.config.RPCHoldTimeout / nomad.JitterFraction) + jitter := lib.RandomStagger(c.config.RPCHoldTimeout / structs.JitterFraction) select { case <-time.After(jitter): goto TRY diff --git a/nomad/rpc.go b/nomad/rpc.go index 0e133030a..149d29965 100644 --- a/nomad/rpc.go +++ b/nomad/rpc.go @@ -31,12 +31,6 @@ const ( // if no time is specified. Previously we would wait the maxQueryTime. defaultQueryTime = 300 * time.Second - // JitterFraction is a the limit to the amount of jitter we apply - // to a user specified MaxQueryTime. We divide the specified time by - // the fraction. So 16 == 6.25% limit of jitter. This jitter is also - // applied to RPCHoldTimeout. - JitterFraction = 16 - // Warn if the Raft command is larger than this. // If it's over 1MB something is probably being abusive. raftWarnSize = 1024 * 1024 @@ -279,7 +273,7 @@ CHECK_LEADER: firstCheck = time.Now() } if time.Now().Sub(firstCheck) < s.config.RPCHoldTimeout { - jitter := lib.RandomStagger(s.config.RPCHoldTimeout / JitterFraction) + jitter := lib.RandomStagger(s.config.RPCHoldTimeout / structs.JitterFraction) select { case <-time.After(jitter): goto CHECK_LEADER @@ -432,7 +426,7 @@ func (s *Server) blockingRPC(opts *blockingOptions) error { } // Apply a small amount of jitter to the request - opts.queryOpts.MaxQueryTime += lib.RandomStagger(opts.queryOpts.MaxQueryTime / JitterFraction) + opts.queryOpts.MaxQueryTime += lib.RandomStagger(opts.queryOpts.MaxQueryTime / structs.JitterFraction) // Setup a query timeout ctx, cancel = context.WithTimeout(context.Background(), opts.queryOpts.MaxQueryTime) diff --git a/nomad/structs/structs.go b/nomad/structs/structs.go index aa7cd23be..58d624564 100644 --- a/nomad/structs/structs.go +++ b/nomad/structs/structs.go @@ -116,6 +116,12 @@ const ( // DefaultNamespace is the default namespace. DefaultNamespace = "default" DefaultNamespaceDescription = "Default shared namespace" + + // JitterFraction is a the limit to the amount of jitter we apply + // to a user specified MaxQueryTime. We divide the specified time by + // the fraction. So 16 == 6.25% limit of jitter. This jitter is also + // applied to RPCHoldTimeout. + JitterFraction = 16 ) // Context defines the scope in which a search for Nomad object operates, and