Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deployment query rate limit #10706

Merged
merged 7 commits into from
Jun 4, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions command/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package agent
import (
"context"
"fmt"
"github.com/hashicorp/nomad/nomad/deploymentwatcher"
"io"
"io/ioutil"
golog "log"
Expand Down Expand Up @@ -420,6 +421,15 @@ func convertServerConfig(agentConfig *Config) (*nomad.Config, error) {
conf.RPCMaxConnsPerClient = limit
}

// Set deployment rate limit
if rate := agentConfig.Server.DeploymentRateLimit; rate == 0 {
conf.DeploymentRateLimit = deploymentwatcher.LimitStateQueriesPerSecond
} else if rate > 0 {
conf.DeploymentRateLimit = rate
} else {
return nil, fmt.Errorf("deployment-rate-limit must be greater than 0")
jazzyfresh marked this conversation as resolved.
Show resolved Hide resolved
}

jazzyfresh marked this conversation as resolved.
Show resolved Hide resolved
// Add Enterprise license configs
conf.LicenseEnv = agentConfig.Server.LicenseEnv
conf.LicensePath = agentConfig.Server.LicensePath
Expand Down
1 change: 1 addition & 0 deletions command/agent/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ func (c *Command) readConfig() *Config {
cmdConfig.Server.ServerJoin.RetryInterval = d
return nil
}), "retry-interval", "")
flags.Float64Var(&cmdConfig.Server.DeploymentRateLimit, "deployment-rate-limit", 0, "")
jazzyfresh marked this conversation as resolved.
Show resolved Hide resolved

// Client-only options
flags.StringVar(&cmdConfig.Client.StateDir, "state-dir", "", "")
Expand Down
4 changes: 4 additions & 0 deletions command/agent/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,10 @@ type ServerConfig struct {
ExtraKeysHCL []string `hcl:",unusedKeys" json:"-"`

Search *Search `hcl:"search"`

// DeploymentRateLimit is in queries per second and is used by the
// DeploymentWatcher to throttle the amount of simultaneously deployments
DeploymentRateLimit float64
jazzyfresh marked this conversation as resolved.
Show resolved Hide resolved
jazzyfresh marked this conversation as resolved.
Show resolved Hide resolved
}

// Search is used in servers to configure search API options.
Expand Down
4 changes: 4 additions & 0 deletions nomad/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,10 @@ type Config struct {
// AgentShutdown is used to call agent.Shutdown from the context of a Server
// It is used primarily for licensing
AgentShutdown func() error

// DeploymentRateLimit is in queries per second and is used by the
// DeploymentWatcher to throttle the amount of simultaneously deployments
DeploymentRateLimit float64
}

// CheckVersion is used to check if the ProtocolVersion is valid
Expand Down
2 changes: 1 addition & 1 deletion nomad/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,7 @@ func (s *Server) setupDeploymentWatcher() error {
raftShim,
s.staticEndpoints.Deployment,
s.staticEndpoints.Job,
deploymentwatcher.LimitStateQueriesPerSecond,
s.config.DeploymentRateLimit,
deploymentwatcher.CrossDeploymentUpdateBatchDuration,
)

Expand Down