agent

package
v1.5.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 30, 2023 License: MPL-2.0 Imports: 104 Imported by: 107

Documentation

Index

Constants

View Source
const (

	// DefaultRaftMultiplier is used as a baseline Raft configuration that
	// will be reliable on a very basic server.
	DefaultRaftMultiplier = 1

	// MaxRaftMultiplier is a fairly arbitrary upper bound that limits the
	// amount of performance detuning that's possible.
	MaxRaftMultiplier = 10
)
View Source
const (
	// ErrInvalidMethod is used if the HTTP method is not supported
	ErrInvalidMethod = "Invalid method"

	// ErrEntOnly is the error returned if accessing an enterprise only
	// endpoint
	ErrEntOnly = "Nomad Enterprise only endpoint"

	// ErrServerOnly is the error text returned if accessing a server only
	// endpoint
	ErrServerOnly = "Server only endpoint"

	// ContextKeyReqID is a unique ID for a given request
	ContextKeyReqID = "requestID"

	// MissingRequestID is a placeholder if we cannot retrieve a request
	// UUID from context
	MissingRequestID = "<missing request id>"
)
View Source
const (
	// EnterpriseTestAgent is used to configure a TestAgent's Enterprise flag
	EnterpriseTestAgent = false
)

Variables

View Source
var TempDir = os.TempDir()

TempDir defines the base dir for temporary directories.

Functions

func ApiAffinitiesToStructs added in v0.9.0

func ApiAffinitiesToStructs(in []*api.Affinity) []*structs.Affinity

func ApiAffinityToStructs added in v0.9.0

func ApiAffinityToStructs(a1 *api.Affinity) *structs.Affinity

func ApiCSIPluginConfigToStructsCSIPluginConfig added in v0.11.0

func ApiCSIPluginConfigToStructsCSIPluginConfig(apiConfig *api.TaskCSIPluginConfig) *structs.TaskCSIPluginConfig

func ApiConstraintToStructs added in v0.5.5

func ApiConstraintToStructs(in *api.Constraint) *structs.Constraint

func ApiConstraintsToStructs added in v0.9.0

func ApiConstraintsToStructs(in []*api.Constraint) []*structs.Constraint

func ApiConsulConnectToStructs added in v0.10.0

func ApiConsulConnectToStructs(in *api.ConsulConnect) *structs.ConsulConnect

func ApiJobToStructJob added in v0.5.5

func ApiJobToStructJob(job *api.Job) *structs.Job

func ApiNetworkResourceToStructs added in v0.10.0

func ApiNetworkResourceToStructs(in []*api.NetworkResource) []*structs.NetworkResource

func ApiPortToStructs added in v0.12.0

func ApiPortToStructs(in api.Port) structs.Port

func ApiResourcesToStructs added in v0.9.0

func ApiResourcesToStructs(in *api.Resources) *structs.Resources

func ApiScalingPolicyToStructs added in v0.11.0

func ApiScalingPolicyToStructs(count int, ap *api.ScalingPolicy) *structs.ScalingPolicy

func ApiServicesToStructs added in v0.10.0

func ApiServicesToStructs(in []*api.Service, group bool) []*structs.Service

func ApiSpreadToStructs added in v0.9.0

func ApiSpreadToStructs(a1 *api.Spread) *structs.Spread

func ApiTaskToStructsTask added in v0.5.5

func ApiTaskToStructsTask(job *structs.Job, group *structs.TaskGroup,
	apiTask *api.Task, structsTask *structs.Task)

ApiTaskToStructsTask is a copy and type conversion between the API representation of a task from a struct representation of a task.

func ApiTgToStructsTG added in v0.5.5

func ApiTgToStructsTG(job *structs.Job, taskGroup *api.TaskGroup, tg *structs.TaskGroup)

func LevelFilter

func LevelFilter() *logutils.LevelFilter

LevelFilter returns a LevelFilter that is configured with the log levels that we use.

func SetupLoggers added in v0.12.1

func SetupLoggers(ui cli.Ui, config *Config) (*logutils.LevelFilter, *gatedwriter.Writer, io.Writer)

SetupLoggers is used to set up the logGate, and our logOutput

func ValidateLevelFilter

func ValidateLevelFilter(minLevel logutils.LogLevel, filter *logutils.LevelFilter) bool

ValidateLevelFilter verifies that the log levels within the filter are valid.

Types

type ACLConfig added in v0.7.0

type ACLConfig struct {
	// Enabled controls if we are enforce and manage ACLs
	Enabled bool `hcl:"enabled"`

	// TokenTTL controls how long we cache ACL tokens. This controls
	// how stale they can be when we are enforcing policies. Defaults
	// to "30s". Reducing this impacts performance by forcing more
	// frequent resolution.
	TokenTTL    time.Duration
	TokenTTLHCL string `hcl:"token_ttl" json:"-"`

	// PolicyTTL controls how long we cache ACL policies. This controls
	// how stale they can be when we are enforcing policies. Defaults
	// to "30s". Reducing this impacts performance by forcing more
	// frequent resolution.
	PolicyTTL    time.Duration
	PolicyTTLHCL string `hcl:"policy_ttl" json:"-"`

	// RoleTTL controls how long we cache ACL roles. This controls how stale
	// they can be when we are enforcing policies. Defaults to "30s".
	// Reducing this impacts performance by forcing more frequent resolution.
	RoleTTL    time.Duration
	RoleTTLHCL string `hcl:"role_ttl" json:"-"`

	// ReplicationToken is used by servers to replicate tokens and policies
	// from the authoritative region. This must be a valid management token
	// within the authoritative region.
	ReplicationToken string `hcl:"replication_token"`

	// TokenMinExpirationTTL is used to enforce the lowest acceptable value for
	// ACL token expiration. This is used by the Nomad servers to validate ACL
	// tokens with an expiration value set upon creation.
	TokenMinExpirationTTL    time.Duration
	TokenMinExpirationTTLHCL string `hcl:"token_min_expiration_ttl" json:"-"`

	// TokenMaxExpirationTTL is used to enforce the highest acceptable value
	// for ACL token expiration. This is used by the Nomad servers to validate
	// ACL tokens with an expiration value set upon creation.
	TokenMaxExpirationTTL    time.Duration
	TokenMaxExpirationTTLHCL string `hcl:"token_max_expiration_ttl" json:"-"`

	// ExtraKeysHCL is used by hcl to surface unexpected keys
	ExtraKeysHCL []string `hcl:",unusedKeys" json:"-"`
}

ACLConfig is configuration specific to the ACL system

func (*ACLConfig) Copy added in v1.2.13

func (a *ACLConfig) Copy() *ACLConfig

func (*ACLConfig) Merge added in v0.7.0

func (a *ACLConfig) Merge(b *ACLConfig) *ACLConfig

Merge is used to merge two ACL configs together. The settings from the input always take precedence.

type Addresses

type Addresses struct {
	HTTP string `hcl:"http"`
	RPC  string `hcl:"rpc"`
	Serf string `hcl:"serf"`
	// ExtraKeysHCL is used by hcl to surface unexpected keys
	ExtraKeysHCL []string `hcl:",unusedKeys" json:"-"`
}

Addresses encapsulates all of the addresses we bind to for various network services. Everything is optional and defaults to BindAddr.

func (*Addresses) Copy added in v1.2.13

func (a *Addresses) Copy() *Addresses

func (*Addresses) Merge

func (a *Addresses) Merge(b *Addresses) *Addresses

Merge is used to merge two address configs together.

type AdvertiseAddrs

type AdvertiseAddrs struct {
	HTTP string `hcl:"http"`
	RPC  string `hcl:"rpc"`
	Serf string `hcl:"serf"`
	// ExtraKeysHCL is used by hcl to surface unexpected keys
	ExtraKeysHCL []string `hcl:",unusedKeys" json:"-"`
}

AdvertiseAddrs is used to control the addresses we advertise out for different network services. All are optional and default to BindAddr and their default Port.

func (*AdvertiseAddrs) Copy added in v1.2.13

func (a *AdvertiseAddrs) Copy() *AdvertiseAddrs

func (*AdvertiseAddrs) Merge

Merge merges two advertise addrs configs together.

type Agent

type Agent struct {

	// EnterpriseAgent holds information and methods for enterprise functionality
	EnterpriseAgent *EnterpriseAgent
	// contains filtered or unexported fields
}

Agent is a long running daemon that is used to run both clients and servers. Servers are responsible for managing state and making scheduling decisions. Clients can be scheduled to, and are responsible for interfacing with servers to run allocations.

func NewAgent

func NewAgent(config *Config, logger log.InterceptLogger, logOutput io.Writer, inmem *metrics.InmemSink) (*Agent, error)

NewAgent is used to create a new agent with the given configuration

func (*Agent) Client

func (a *Agent) Client() *client.Client

Client returns the configured client or nil

func (*Agent) GetConfig added in v0.7.1

func (a *Agent) GetConfig() *Config

GetConfig returns the current agent configuration. The Config should *not* be mutated directly. First call Config.Copy.

func (*Agent) GetMetricsSink added in v1.5.0

func (a *Agent) GetMetricsSink() *metrics.InmemSink

GetMetricsSink returns the metrics sink.

func (*Agent) Leave

func (a *Agent) Leave() error

Leave is used gracefully exit. Clients will inform servers of their departure so that allocations can be rescheduled.

func (*Agent) RPC

func (a *Agent) RPC(method string, args interface{}, reply interface{}) error

RPC is used to make an RPC call to the Nomad servers

func (*Agent) Reload added in v0.7.1

func (a *Agent) Reload(newConfig *Config) error

Reload handles configuration changes for the agent. Provides a method that is easier to unit test, as this action is invoked via SIGHUP.

func (*Agent) Server

func (a *Agent) Server() *nomad.Server

Server returns the configured server or nil

func (*Agent) ShouldReload added in v0.8.0

func (a *Agent) ShouldReload(newConfig *Config) (agent, http bool)

ShouldReload determines if we should reload the configuration and agent connections. If the TLS Configuration has not changed, we shouldn't reload.

func (*Agent) Shutdown

func (a *Agent) Shutdown() error

Shutdown is used to terminate the agent.

func (*Agent) Stats

func (a *Agent) Stats() map[string]map[string]string

Stats is used to return statistics for debugging and insight for various sub-systems

type ClientConfig

type ClientConfig struct {
	// Enabled controls if we are a client
	Enabled bool `hcl:"enabled"`

	// StateDir is the state directory
	StateDir string `hcl:"state_dir"`

	// AllocDir is the directory for storing allocation data
	AllocDir string `hcl:"alloc_dir"`

	// Servers is a list of known server addresses. These are as "host:port"
	Servers []string `hcl:"servers"`

	// NodeClass is used to group the node by class
	NodeClass string `hcl:"node_class"`

	// Options is used for configuration of nomad internals,
	// like fingerprinters and drivers. The format is:
	//
	//  namespace.option = value
	Options map[string]string `hcl:"options"`

	// Metadata associated with the node
	Meta map[string]string `hcl:"meta"`

	// A mapping of directories on the host OS to attempt to embed inside each
	// task's chroot.
	ChrootEnv map[string]string `hcl:"chroot_env"`

	// Interface to use for network fingerprinting
	NetworkInterface string `hcl:"network_interface"`

	// NetworkSpeed is used to override any detected or default network link
	// speed.
	NetworkSpeed int `hcl:"network_speed"`

	// CpuCompute is used to override any detected or default total CPU compute.
	CpuCompute int `hcl:"cpu_total_compute"`

	// MemoryMB is used to override any detected or default total memory.
	MemoryMB int `hcl:"memory_total_mb"`

	// DiskTotalMB is used to override any detected or default total disk space.
	DiskTotalMB int `hcl:"disk_total_mb"`

	// DiskFreeMB is used to override any detected or default free disk space.
	DiskFreeMB int `hcl:"disk_free_mb"`

	// ReservableCores is used to override detected reservable cpu cores.
	ReserveableCores string `hcl:"reservable_cores"`

	// MaxKillTimeout allows capping the user-specifiable KillTimeout.
	MaxKillTimeout string `hcl:"max_kill_timeout"`

	// ClientMaxPort is the upper range of the ports that the client uses for
	// communicating with plugin subsystems
	ClientMaxPort int `hcl:"client_max_port"`

	// ClientMinPort is the lower range of the ports that the client uses for
	// communicating with plugin subsystems
	ClientMinPort int `hcl:"client_min_port"`

	// MaxDynamicPort is the upper range of the dynamic ports that the client
	// uses for allocations
	MaxDynamicPort int `hcl:"max_dynamic_port"`

	// MinDynamicPort is the lower range of the dynamic ports that the client
	// uses for allocations
	MinDynamicPort int `hcl:"min_dynamic_port"`

	// Reserved is used to reserve resources from being used by Nomad. This can
	// be used to target a certain utilization or to prevent Nomad from using a
	// particular set of ports.
	Reserved *Resources `hcl:"reserved"`

	// GCInterval is the time interval at which the client triggers garbage
	// collection
	GCInterval    time.Duration
	GCIntervalHCL string `hcl:"gc_interval" json:"-"`

	// GCParallelDestroys is the number of parallel destroys the garbage
	// collector will allow.
	GCParallelDestroys int `hcl:"gc_parallel_destroys"`

	// GCDiskUsageThreshold is the disk usage threshold given as a percent
	// beyond which the Nomad client triggers GC of terminal allocations
	GCDiskUsageThreshold float64 `hcl:"gc_disk_usage_threshold"`

	// GCInodeUsageThreshold is the inode usage threshold beyond which the Nomad
	// client triggers GC of the terminal allocations
	GCInodeUsageThreshold float64 `hcl:"gc_inode_usage_threshold"`

	// GCMaxAllocs is the maximum number of allocations a node can have
	// before garbage collection is triggered.
	GCMaxAllocs int `hcl:"gc_max_allocs"`

	// NoHostUUID disables using the host's UUID and will force generation of a
	// random UUID.
	NoHostUUID *bool `hcl:"no_host_uuid"`

	// DisableRemoteExec disables remote exec targeting tasks on this client
	DisableRemoteExec bool `hcl:"disable_remote_exec"`

	// TemplateConfig includes configuration for template rendering
	TemplateConfig *client.ClientTemplateConfig `hcl:"template"`

	// ServerJoin contains information that is used to attempt to join servers
	ServerJoin *ServerJoin `hcl:"server_join"`

	// HostVolumes contains information about the volumes an operator has made
	// available to jobs running on this node.
	HostVolumes []*structs.ClientHostVolumeConfig `hcl:"host_volume"`

	// CNIPath is the path to search for CNI plugins, multiple paths can be
	// specified colon delimited
	CNIPath string `hcl:"cni_path"`

	// CNIConfigDir is the directory where CNI network configuration is located. The
	// client will use this path when fingerprinting CNI networks.
	CNIConfigDir string `hcl:"cni_config_dir"`

	// BridgeNetworkName is the name of the bridge to create when using the
	// bridge network mode
	BridgeNetworkName string `hcl:"bridge_network_name"`

	// BridgeNetworkSubnet is the subnet to allocate IP addresses from when
	// creating allocations with bridge networking mode. This range is local to
	// the host
	BridgeNetworkSubnet string `hcl:"bridge_network_subnet"`

	// BridgeNetworkHairpinMode is whether or not to enable hairpin mode on the
	// internal bridge network
	BridgeNetworkHairpinMode bool `hcl:"bridge_network_hairpin_mode"`

	// HostNetworks describes the different host networks available to the host
	// if the host uses multiple interfaces
	HostNetworks []*structs.ClientHostNetworkConfig `hcl:"host_network"`

	// BindWildcardDefaultHostNetwork toggles if when there are no host networks,
	// should the port mapping rules match the default network address (false) or
	// matching any destination address (true). Defaults to true
	BindWildcardDefaultHostNetwork bool `hcl:"bind_wildcard_default_host_network"`

	// CgroupParent sets the parent cgroup for subsystems managed by Nomad. If the cgroup
	// doest not exist Nomad will attempt to create it during startup. Defaults to '/nomad'
	CgroupParent string `hcl:"cgroup_parent"`

	// NomadServiceDiscovery is a boolean parameter which allows operators to
	// enable/disable to Nomad native service discovery feature on the client.
	// This parameter is exposed via the Nomad fingerprinter and used to ensure
	// correct scheduling decisions on allocations which require this.
	NomadServiceDiscovery *bool `hcl:"nomad_service_discovery"`

	// Artifact contains the configuration for artifacts.
	Artifact *config.ArtifactConfig `hcl:"artifact"`

	// Drain specifies whether to drain the client on shutdown; ignored in dev mode.
	Drain *config.DrainConfig `hcl:"drain_on_shutdown"`

	// ExtraKeysHCL is used by hcl to surface unexpected keys
	ExtraKeysHCL []string `hcl:",unusedKeys" json:"-"`
}

ClientConfig is configuration specific to the client mode

func (*ClientConfig) Copy added in v1.2.13

func (c *ClientConfig) Copy() *ClientConfig

func (*ClientConfig) Merge

func (a *ClientConfig) Merge(b *ClientConfig) *ClientConfig

Merge is used to merge two client configs together

type Command

type Command struct {
	Version    *version.VersionInfo
	Ui         cli.Ui
	ShutdownCh <-chan struct{}
	// contains filtered or unexported fields
}

Command is a Command implementation that runs a Nomad agent. The command will not end unless a shutdown message is sent on the ShutdownCh. If two messages are sent on the ShutdownCh it will forcibly exit.

func (*Command) AutocompleteArgs added in v0.6.0

func (c *Command) AutocompleteArgs() complete.Predictor

func (*Command) AutocompleteFlags added in v0.6.0

func (c *Command) AutocompleteFlags() complete.Flags

func (*Command) Help

func (c *Command) Help() string

func (*Command) IsValidConfig added in v1.3.0

func (c *Command) IsValidConfig(config, cmdConfig *Config) bool

func (*Command) Run

func (c *Command) Run(args []string) int

func (*Command) Synopsis

func (c *Command) Synopsis() string

type Config

type Config struct {
	// Region is the region this agent is in. Defaults to global.
	Region string `hcl:"region"`

	// Datacenter is the datacenter this agent is in. Defaults to dc1
	Datacenter string `hcl:"datacenter"`

	// NodeName is the name we register as. Defaults to hostname.
	NodeName string `hcl:"name"`

	// DataDir is the directory to store our state in
	DataDir string `hcl:"data_dir"`

	// PluginDir is the directory to lookup plugins.
	PluginDir string `hcl:"plugin_dir"`

	// LogLevel is the level of the logs to put out
	LogLevel string `hcl:"log_level"`

	// LogJson enables log output in a JSON format
	LogJson bool `hcl:"log_json"`

	// LogFile enables logging to a file
	LogFile string `hcl:"log_file"`

	// LogRotateDuration is the time period that logs should be rotated in
	LogRotateDuration string `hcl:"log_rotate_duration"`

	// LogRotateBytes is the max number of bytes that should be written to a file
	LogRotateBytes int `hcl:"log_rotate_bytes"`

	// LogRotateMaxFiles is the max number of log files to keep
	LogRotateMaxFiles int `hcl:"log_rotate_max_files"`

	// BindAddr is the address on which all of nomad's services will
	// be bound. If not specified, this defaults to 127.0.0.1.
	BindAddr string `hcl:"bind_addr"`

	// EnableDebug is used to enable debugging HTTP endpoints
	EnableDebug bool `hcl:"enable_debug"`

	// Ports is used to control the network ports we bind to.
	Ports *Ports `hcl:"ports"`

	// Addresses is used to override the network addresses we bind to.
	//
	// Use normalizedAddrs if you need the host+port to bind to.
	Addresses *Addresses `hcl:"addresses"`

	// AdvertiseAddrs is used to control the addresses we advertise.
	AdvertiseAddrs *AdvertiseAddrs `hcl:"advertise"`

	// Client has our client related settings
	Client *ClientConfig `hcl:"client"`

	// Server has our server related settings
	Server *ServerConfig `hcl:"server"`

	// ACL has our acl related settings
	ACL *ACLConfig `hcl:"acl"`

	// Telemetry is used to configure sending telemetry
	Telemetry *Telemetry `hcl:"telemetry"`

	// LeaveOnInt is used to gracefully leave on the interrupt signal
	LeaveOnInt bool `hcl:"leave_on_interrupt"`

	// LeaveOnTerm is used to gracefully leave on the terminate signal
	LeaveOnTerm bool `hcl:"leave_on_terminate"`

	// EnableSyslog is used to enable sending logs to syslog
	EnableSyslog bool `hcl:"enable_syslog"`

	// SyslogFacility is used to control the syslog facility used.
	SyslogFacility string `hcl:"syslog_facility"`

	// DisableUpdateCheck is used to disable the periodic update
	// and security bulletin checking.
	DisableUpdateCheck *bool `hcl:"disable_update_check"`

	// DisableAnonymousSignature is used to disable setting the
	// anonymous signature when doing the update check and looking
	// for security bulletins
	DisableAnonymousSignature bool `hcl:"disable_anonymous_signature"`

	// Consul contains the configuration for the Consul Agent and
	// parameters necessary to register services, their checks, and
	// discover the current Nomad servers.
	Consul *config.ConsulConfig `hcl:"consul"`

	// Vault contains the configuration for the Vault Agent and
	// parameters necessary to derive tokens.
	Vault *config.VaultConfig `hcl:"vault"`

	// UI is used to configure the web UI
	UI *config.UIConfig `hcl:"ui"`

	// NomadConfig is used to override the default config.
	// This is largely used for testing purposes.
	NomadConfig *nomad.Config `hcl:"-" json:"-"`

	// ClientConfig is used to override the default config.
	// This is largely used for testing purposes.
	ClientConfig *client.Config `hcl:"-" json:"-"`

	// DevMode is set by the -dev CLI flag.
	DevMode bool `hcl:"-"`

	// Version information is set at compilation time
	Version *version.VersionInfo

	// List of config files that have been loaded (in order)
	Files []string `hcl:"-"`

	// TLSConfig provides TLS related configuration for the Nomad server and
	// client
	TLSConfig *config.TLSConfig `hcl:"tls"`

	// HTTPAPIResponseHeaders allows users to configure the Nomad http agent to
	// set arbitrary headers on API responses
	HTTPAPIResponseHeaders map[string]string `hcl:"http_api_response_headers"`

	// Sentinel holds sentinel related settings
	Sentinel *config.SentinelConfig `hcl:"sentinel"`

	// Autopilot contains the configuration for Autopilot behavior.
	Autopilot *config.AutopilotConfig `hcl:"autopilot"`

	// Plugins is the set of configured plugins
	Plugins []*config.PluginConfig `hcl:"plugin"`

	// Limits contains the configuration for timeouts.
	Limits config.Limits `hcl:"limits"`

	// Audit contains the configuration for audit logging.
	Audit *config.AuditConfig `hcl:"audit"`

	// ExtraKeysHCL is used by hcl to surface unexpected keys
	ExtraKeysHCL []string `hcl:",unusedKeys" json:"-"`
	// contains filtered or unexported fields
}

Config is the configuration for the Nomad agent.

time.Duration values have two parts:

  • a string field tagged with an hcl:"foo" and json:"-"
  • a time.Duration field in the same struct and a call to duration in config_parse.go ParseConfigFile

All config structs should have an ExtraKeysHCL field to check for unexpected keys

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig is the baseline configuration for Nomad.

func DefaultEntConfig added in v0.8.0

func DefaultEntConfig() *Config

DefaultEntConfig is an empty config in open source

func DevConfig

func DevConfig(mode *devModeConfig) *Config

DevConfig is a Config that is used for dev mode of Nomad.

func LoadConfig

func LoadConfig(path string) (*Config, error)

LoadConfig loads the configuration at the given path, regardless if its a file or directory. Called for each -config to build up the runtime config value. Do not apply any default values, defaults should be added once in DefaultConfig

func LoadConfigDir

func LoadConfigDir(dir string) (*Config, error)

LoadConfigDir loads all the configurations in the given directory in alphabetical order.

func ParseConfigFile added in v0.3.1

func ParseConfigFile(path string) (*Config, error)

ParseConfigFile returns an agent.Config from parsed from a file.

func (*Config) Copy added in v1.2.13

func (c *Config) Copy() *Config

Copy returns a deep copy safe for mutation.

func (*Config) Listener

func (c *Config) Listener(proto, addr string, port int) (net.Listener, error)

Listener can be used to get a new listener using a custom bind address. If the bind provided address is empty, the BindAddr is used instead.

func (*Config) Merge

func (c *Config) Merge(b *Config) *Config

Merge merges two configurations.

type DiscoverInterface added in v0.8.4

type DiscoverInterface interface {
	// Addrs discovers ip addresses of nodes that match the given filter
	// criteria.
	// The config string must have the format 'provider=xxx key=val key=val ...'
	// where the keys and values are provider specific. The values are URL
	// encoded.
	Addrs(string, *golog.Logger) ([]string, error)

	// Help describes the format of the configuration string for address
	// discovery and the various provider specific options.
	Help() string

	// Names returns the names of the configured providers.
	Names() []string
}

DiscoverInterface is an interface for the Discover type in the go-discover library. Using an interface allows for ease of testing.

type EnterpriseAgent added in v0.12.0

type EnterpriseAgent struct{}

EnterpriseAgent holds information and methods for enterprise functionality in OSS it is an empty struct.

type HTTPCodedError

type HTTPCodedError interface {
	error
	Code() int
}

HTTPCodedError is used to provide the HTTP error code

func CodedError

func CodedError(c int, s string) HTTPCodedError

type HTTPServer

type HTTPServer struct {
	Addr string
	// contains filtered or unexported fields
}

HTTPServer is used to wrap an Agent and expose it over an HTTP interface

func NewHTTPServers added in v1.2.4

func NewHTTPServers(agent *Agent, config *Config) ([]*HTTPServer, error)

NewHTTPServers starts an HTTP server for every address.http configured in the agent.

func (*HTTPServer) ACLAuthMethodListRequest added in v1.5.0

func (s *HTTPServer) ACLAuthMethodListRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

ACLAuthMethodListRequest performs a listing of ACL auth-methods and is callable via the /v1/acl/auth-methods HTTP API.

func (*HTTPServer) ACLAuthMethodRequest added in v1.5.0

func (s *HTTPServer) ACLAuthMethodRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

ACLAuthMethodRequest creates a new ACL auth-method and is callable via the /v1/acl/auth-method HTTP API.

func (*HTTPServer) ACLAuthMethodSpecificRequest added in v1.5.0

func (s *HTTPServer) ACLAuthMethodSpecificRequest(
	resp http.ResponseWriter, req *http.Request) (interface{}, error)

ACLAuthMethodSpecificRequest is callable via the /v1/acl/auth-method/ HTTP API and handles reads, updates, and deletions of named methods.

func (*HTTPServer) ACLBindingRuleListRequest added in v1.5.0

func (s *HTTPServer) ACLBindingRuleListRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

ACLBindingRuleListRequest performs a listing of ACL binding rules and is callable via the /v1/acl/binding-rules HTTP API.

func (*HTTPServer) ACLBindingRuleRequest added in v1.5.0

func (s *HTTPServer) ACLBindingRuleRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

ACLBindingRuleRequest creates a new ACL binding rule and is callable via the /v1/acl/binding-rule HTTP API.

func (*HTTPServer) ACLBindingRuleSpecificRequest added in v1.5.0

func (s *HTTPServer) ACLBindingRuleSpecificRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

ACLBindingRuleSpecificRequest is callable via the /v1/acl/binding-rule/ HTTP API and handles read via both the ID, updates, and deletions.

func (*HTTPServer) ACLLoginRequest added in v1.5.4

func (s *HTTPServer) ACLLoginRequest(resp http.ResponseWriter, req *http.Request) (any, error)

ACLLoginRequest performs a non-interactive authentication request

func (*HTTPServer) ACLOIDCAuthURLRequest added in v1.5.0

func (s *HTTPServer) ACLOIDCAuthURLRequest(_ http.ResponseWriter, req *http.Request) (interface{}, error)

ACLOIDCAuthURLRequest starts the OIDC login workflow.

func (*HTTPServer) ACLOIDCCompleteAuthRequest added in v1.5.0

func (s *HTTPServer) ACLOIDCCompleteAuthRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

ACLOIDCCompleteAuthRequest completes the OIDC login workflow.

func (*HTTPServer) ACLPoliciesRequest added in v0.7.0

func (s *HTTPServer) ACLPoliciesRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

func (*HTTPServer) ACLPolicySpecificRequest added in v0.7.0

func (s *HTTPServer) ACLPolicySpecificRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

func (*HTTPServer) ACLRoleListRequest added in v1.4.0

func (s *HTTPServer) ACLRoleListRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

ACLRoleListRequest performs a listing of ACL roles and is callable via the /v1/acl/roles HTTP API.

func (*HTTPServer) ACLRoleRequest added in v1.4.0

func (s *HTTPServer) ACLRoleRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

ACLRoleRequest creates a new ACL role and is callable via the /v1/acl/role HTTP API.

func (*HTTPServer) ACLRoleSpecificRequest added in v1.4.0

func (s *HTTPServer) ACLRoleSpecificRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

ACLRoleSpecificRequest is callable via the /v1/acl/role/ HTTP API and handles read via both the role name and ID, updates, and deletions.

func (*HTTPServer) ACLTokenBootstrap added in v0.7.0

func (s *HTTPServer) ACLTokenBootstrap(resp http.ResponseWriter, req *http.Request) (interface{}, error)

func (*HTTPServer) ACLTokenSpecificRequest added in v0.7.0

func (s *HTTPServer) ACLTokenSpecificRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

func (*HTTPServer) ACLTokensRequest added in v0.7.0

func (s *HTTPServer) ACLTokensRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

func (*HTTPServer) AgentForceLeaveRequest

func (s *HTTPServer) AgentForceLeaveRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

func (*HTTPServer) AgentHostRequest added in v0.12.0

func (s *HTTPServer) AgentHostRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

AgentHostRequest runs on servers and clients, and captures information about the host system to add to the nomad operator debug archive.

func (*HTTPServer) AgentJoinRequest

func (s *HTTPServer) AgentJoinRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

func (*HTTPServer) AgentMembersRequest

func (s *HTTPServer) AgentMembersRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

func (*HTTPServer) AgentMonitor added in v0.10.2

func (s *HTTPServer) AgentMonitor(resp http.ResponseWriter, req *http.Request) (interface{}, error)

func (*HTTPServer) AgentPprofRequest added in v0.10.4

func (s *HTTPServer) AgentPprofRequest(resp http.ResponseWriter, req *http.Request) ([]byte, error)

func (*HTTPServer) AgentSchedulerWorkerConfigRequest added in v1.2.4

func (s *HTTPServer) AgentSchedulerWorkerConfigRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

AgentSchedulerWorkerConfigRequest is used to query the count (and state eventually) of the scheduler workers running in a Nomad server agent. This endpoint can also be used to update the count of running workers for a given agent.

func (*HTTPServer) AgentSchedulerWorkerInfoRequest added in v1.2.4

func (s *HTTPServer) AgentSchedulerWorkerInfoRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

AgentSchedulerWorkerInfoRequest is used to query the running state of the agent's scheduler workers.

func (*HTTPServer) AgentSelfRequest

func (s *HTTPServer) AgentSelfRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

func (*HTTPServer) AgentServersRequest

func (s *HTTPServer) AgentServersRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

AgentServersRequest is used to query the list of servers used by the Nomad Client for RPCs. This endpoint can also be used to update the list of servers for a given agent.

func (*HTTPServer) AllocSpecificRequest

func (s *HTTPServer) AllocSpecificRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

func (*HTTPServer) AllocsRequest

func (s *HTTPServer) AllocsRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

func (*HTTPServer) CSIExternalVolumesRequest added in v1.1.0

func (s *HTTPServer) CSIExternalVolumesRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

func (*HTTPServer) CSIPluginSpecificRequest added in v0.11.0

func (s *HTTPServer) CSIPluginSpecificRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

CSIPluginSpecificRequest list the job with CSIInfo

func (*HTTPServer) CSIPluginsRequest added in v0.11.0

func (s *HTTPServer) CSIPluginsRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

CSIPluginsRequest lists CSI plugins

func (*HTTPServer) CSISnapshotsRequest added in v1.1.0

func (s *HTTPServer) CSISnapshotsRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

func (*HTTPServer) CSIVolumeSpecificRequest added in v0.11.0

func (s *HTTPServer) CSIVolumeSpecificRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

CSIVolumeSpecificRequest dispatches GET and PUT

func (*HTTPServer) CSIVolumesRequest added in v0.11.0

func (s *HTTPServer) CSIVolumesRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

func (*HTTPServer) ClientAllocRequest added in v0.4.0

func (s *HTTPServer) ClientAllocRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

func (*HTTPServer) ClientGCRequest added in v0.5.2

func (s *HTTPServer) ClientGCRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

func (*HTTPServer) ClientStatsRequest added in v0.4.0

func (s *HTTPServer) ClientStatsRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

func (*HTTPServer) DeploymentSpecificRequest added in v0.6.0

func (s *HTTPServer) DeploymentSpecificRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

func (*HTTPServer) DeploymentsRequest added in v0.6.0

func (s *HTTPServer) DeploymentsRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

func (*HTTPServer) DirectoryListRequest added in v0.3.0

func (s *HTTPServer) DirectoryListRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

func (*HTTPServer) EvalSpecificRequest

func (s *HTTPServer) EvalSpecificRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

func (*HTTPServer) EvalsCountRequest added in v1.4.3

func (s *HTTPServer) EvalsCountRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

func (*HTTPServer) EvalsRequest

func (s *HTTPServer) EvalsRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

EvalsRequest is the entry point for /v1/evaluations and is responsible for handling both the listing of evaluations, and the bulk deletion of evaluations. The latter is a dangerous operation and should use the eval delete command to perform this.

func (*HTTPServer) EventStream added in v1.0.0

func (s *HTTPServer) EventStream(resp http.ResponseWriter, req *http.Request) (interface{}, error)

func (*HTTPServer) ExchangeOneTimeToken added in v1.1.0

func (s *HTTPServer) ExchangeOneTimeToken(resp http.ResponseWriter, req *http.Request) (interface{}, error)

func (*HTTPServer) FileCatRequest added in v0.3.2

func (s *HTTPServer) FileCatRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

func (*HTTPServer) FileReadAtRequest added in v0.3.0

func (s *HTTPServer) FileReadAtRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

func (*HTTPServer) FileStatRequest added in v0.3.0

func (s *HTTPServer) FileStatRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

func (*HTTPServer) FsRequest added in v0.3.1

func (s *HTTPServer) FsRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

func (*HTTPServer) FuzzySearchRequest added in v1.1.0

func (s *HTTPServer) FuzzySearchRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

func (*HTTPServer) GarbageCollectRequest added in v0.3.0

func (s *HTTPServer) GarbageCollectRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

func (*HTTPServer) HealthRequest added in v0.7.0

func (s *HTTPServer) HealthRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

func (*HTTPServer) JobSpecificRequest

func (s *HTTPServer) JobSpecificRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

func (*HTTPServer) JobsParseRequest added in v0.8.2

func (s *HTTPServer) JobsParseRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

JobsParseRequest parses a hcl jobspec and returns a api.Job

func (*HTTPServer) JobsRequest

func (s *HTTPServer) JobsRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

func (*HTTPServer) KeyringOperationRequest added in v0.5.0

func (s *HTTPServer) KeyringOperationRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

KeyringOperationRequest allows an operator to install/delete/use keys

func (*HTTPServer) KeyringRequest added in v1.4.0

func (s *HTTPServer) KeyringRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

KeyringRequest is used route operator/raft API requests to the implementing functions.

func (*HTTPServer) LicenseRequest added in v1.0.4

func (s *HTTPServer) LicenseRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

func (*HTTPServer) Logs added in v0.4.1

func (s *HTTPServer) Logs(resp http.ResponseWriter, req *http.Request) (interface{}, error)

Logs streams the content of a log blocking on EOF. The parameters are:

  • task: task name to stream logs for.
  • type: stdout/stderr to stream.
  • follow: A boolean of whether to follow the logs.
  • offset: The offset to start streaming data at, defaults to zero.
  • origin: Either "start" or "end" and defines from where the offset is applied. Defaults to "start".

func (*HTTPServer) MetricsRequest added in v0.7.0

func (s *HTTPServer) MetricsRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

MetricsRequest returns metrics for the agent. Metrics are JSON by default but Prometheus is an optional format.

func (*HTTPServer) NamespaceCreateRequest added in v1.0.0

func (s *HTTPServer) NamespaceCreateRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

func (*HTTPServer) NamespaceSpecificRequest added in v1.0.0

func (s *HTTPServer) NamespaceSpecificRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

func (*HTTPServer) NamespacesRequest added in v1.0.0

func (s *HTTPServer) NamespacesRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

func (*HTTPServer) NodeMetaRequest added in v1.5.0

func (s *HTTPServer) NodeMetaRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

func (*HTTPServer) NodeSpecificRequest

func (s *HTTPServer) NodeSpecificRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

func (*HTTPServer) NodesRequest

func (s *HTTPServer) NodesRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

func (*HTTPServer) OperatorAutopilotConfiguration added in v0.8.0

func (s *HTTPServer) OperatorAutopilotConfiguration(resp http.ResponseWriter, req *http.Request) (interface{}, error)

OperatorAutopilotConfiguration is used to inspect the current Autopilot configuration. This supports the stale query mode in case the cluster doesn't have a leader.

func (*HTTPServer) OperatorRaftConfiguration added in v0.5.5

func (s *HTTPServer) OperatorRaftConfiguration(resp http.ResponseWriter, req *http.Request) (interface{}, error)

OperatorRaftConfiguration is used to inspect the current Raft configuration. This supports the stale query mode in case the cluster doesn't have a leader.

func (*HTTPServer) OperatorRaftPeer added in v0.5.5

func (s *HTTPServer) OperatorRaftPeer(resp http.ResponseWriter, req *http.Request) (interface{}, error)

OperatorRaftPeer supports actions on Raft peers. Currently we only support removing peers by address.

func (*HTTPServer) OperatorRequest added in v0.5.5

func (s *HTTPServer) OperatorRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

OperatorRequest is used route operator/raft API requests to the implementing functions.

func (*HTTPServer) OperatorSchedulerConfiguration added in v0.9.0

func (s *HTTPServer) OperatorSchedulerConfiguration(resp http.ResponseWriter, req *http.Request) (interface{}, error)

OperatorSchedulerConfiguration is used to inspect the current Scheduler configuration. This supports the stale query mode in case the cluster doesn't have a leader.

func (*HTTPServer) OperatorServerHealth added in v0.8.0

func (s *HTTPServer) OperatorServerHealth(resp http.ResponseWriter, req *http.Request) (interface{}, error)

OperatorServerHealth is used to get the health of the servers in the given Region.

func (*HTTPServer) ReconcileJobSummaries added in v0.4.1

func (s *HTTPServer) ReconcileJobSummaries(resp http.ResponseWriter, req *http.Request) (interface{}, error)

func (*HTTPServer) RegionListRequest added in v0.2.1

func (s *HTTPServer) RegionListRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

func (*HTTPServer) ResolveToken added in v1.0.18

func (s *HTTPServer) ResolveToken(req *http.Request) (*acl.ACL, error)

ResolveToken extracts the ACL token secret ID from the request and translates it into an ACL object. Returns nil if ACLs are disabled.

func (*HTTPServer) ScalingPoliciesRequest added in v0.11.0

func (s *HTTPServer) ScalingPoliciesRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

func (*HTTPServer) ScalingPolicySpecificRequest added in v0.11.0

func (s *HTTPServer) ScalingPolicySpecificRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

func (*HTTPServer) SearchRequest added in v0.6.1

func (s *HTTPServer) SearchRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

SearchRequest accepts a prefix and context and returns a list of matching IDs for that context.

func (*HTTPServer) ServiceRegistrationListRequest added in v1.3.0

func (s *HTTPServer) ServiceRegistrationListRequest(
	resp http.ResponseWriter, req *http.Request) (interface{}, error)

ServiceRegistrationListRequest performs a listing of service registrations using the structs.ServiceRegistrationListRPCMethod RPC endpoint and is callable via the /v1/services HTTP API.

func (*HTTPServer) ServiceRegistrationRequest added in v1.3.0

func (s *HTTPServer) ServiceRegistrationRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

ServiceRegistrationRequest is callable via the /v1/service/ HTTP API and handles service reads and individual service registration deletions.

func (*HTTPServer) Shutdown

func (s *HTTPServer) Shutdown()

Shutdown is used to shutdown the HTTP server

func (*HTTPServer) SnapshotRequest added in v0.12.0

func (s *HTTPServer) SnapshotRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

func (*HTTPServer) StatusLeaderRequest

func (s *HTTPServer) StatusLeaderRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

func (*HTTPServer) StatusPeersRequest

func (s *HTTPServer) StatusPeersRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

func (*HTTPServer) Stream added in v0.4.1

func (s *HTTPServer) Stream(resp http.ResponseWriter, req *http.Request) (interface{}, error)

Stream streams the content of a file blocking on EOF. The parameters are:

  • path: path to file to stream.
  • follow: A boolean of whether to follow the file, defaults to true.
  • offset: The offset to start streaming data at, defaults to zero.
  • origin: Either "start" or "end" and defines from where the offset is applied. Defaults to "start".

func (*HTTPServer) UpsertOneTimeToken added in v1.1.0

func (s *HTTPServer) UpsertOneTimeToken(resp http.ResponseWriter, req *http.Request) (interface{}, error)

func (*HTTPServer) ValidateJobRequest added in v0.5.5

func (s *HTTPServer) ValidateJobRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

func (*HTTPServer) VariableSpecificRequest added in v1.4.0

func (s *HTTPServer) VariableSpecificRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

func (*HTTPServer) VariablesListRequest added in v1.4.0

func (s *HTTPServer) VariablesListRequest(resp http.ResponseWriter, req *http.Request) (interface{}, error)

type Member

type Member struct {
	Name        string
	Addr        net.IP
	Port        uint16
	Tags        map[string]string
	Status      string
	ProtocolMin uint8
	ProtocolMax uint8
	ProtocolCur uint8
	DelegateMin uint8
	DelegateMax uint8
	DelegateCur uint8
}

type NormalizedAddrs added in v1.2.4

type NormalizedAddrs struct {
	HTTP []string
	RPC  string
	Serf string
}

AdvertiseAddrs is used to control the addresses we advertise out for different network services. All are optional and default to BindAddr and their default Port.

func (*NormalizedAddrs) Copy added in v1.2.13

func (n *NormalizedAddrs) Copy() *NormalizedAddrs

type PlanRejectionTracker added in v1.3.2

type PlanRejectionTracker struct {
	// Enabled controls if the plan rejection tracker is active or not.
	Enabled *bool `hcl:"enabled"`

	// NodeThreshold is the number of times a node can have plan rejections
	// before it is marked as ineligible.
	NodeThreshold int `hcl:"node_threshold"`

	// NodeWindow is the time window used to track active plan rejections for
	// nodes.
	NodeWindow    time.Duration
	NodeWindowHCL string `hcl:"node_window" json:"-"`

	// ExtraKeysHCL is used by hcl to surface unexpected keys
	ExtraKeysHCL []string `hcl:",unusedKeys" json:"-"`
}

PlanRejectionTracker is used in servers to configure the plan rejection tracker.

func (*PlanRejectionTracker) Copy added in v1.3.6

func (*PlanRejectionTracker) Merge added in v1.3.2

type Ports

type Ports struct {
	HTTP int `hcl:"http"`
	RPC  int `hcl:"rpc"`
	Serf int `hcl:"serf"`
	// ExtraKeysHCL is used by hcl to surface unexpected keys
	ExtraKeysHCL []string `hcl:",unusedKeys" json:"-"`
}

Ports encapsulates the various ports we bind to for network services. If any are not specified then the defaults are used instead.

func (*Ports) Copy added in v1.2.13

func (p *Ports) Copy() *Ports

func (*Ports) Merge

func (a *Ports) Merge(b *Ports) *Ports

Merge is used to merge two port configurations.

type RPCer added in v1.5.0

type RPCer interface {
	RPC(string, any, any) error
	Server() *nomad.Server
	Client() *client.Client
	Stats() map[string]map[string]string
	GetConfig() *Config
	GetMetricsSink() *metrics.InmemSink
}

type RaftBoltConfig added in v1.3.0

type RaftBoltConfig struct {
	// NoFreelistSync toggles whether the underlying raft storage should sync its
	// freelist to disk within the bolt .db file. When disabled, IO performance
	// will be improved but at the expense of longer startup times.
	//
	// Default: false.
	NoFreelistSync bool `hcl:"no_freelist_sync"`
}

RaftBoltConfig is used in servers to configure parameters of the boltdb used for raft consensus.

func (*RaftBoltConfig) Copy added in v1.3.6

func (r *RaftBoltConfig) Copy() *RaftBoltConfig

type Resources added in v0.3.1

type Resources struct {
	CPU           int    `hcl:"cpu"`
	MemoryMB      int    `hcl:"memory"`
	DiskMB        int    `hcl:"disk"`
	ReservedPorts string `hcl:"reserved_ports"`
	Cores         string `hcl:"cores"`
	// ExtraKeysHCL is used by hcl to surface unexpected keys
	ExtraKeysHCL []string `hcl:",unusedKeys" json:"-"`
}

func (*Resources) Copy added in v1.2.13

func (r *Resources) Copy() *Resources

func (*Resources) Merge added in v0.3.1

func (r *Resources) Merge(b *Resources) *Resources
type Search struct {
	// FuzzyEnabled toggles whether the FuzzySearch API is enabled. If not
	// enabled, requests to /v1/search/fuzzy will reply with a 404 response code.
	//
	// Default: enabled.
	FuzzyEnabled bool `hcl:"fuzzy_enabled"`

	// LimitQuery limits the number of objects searched in the FuzzySearch API.
	// The results are indicated as truncated if the limit is reached.
	//
	// Lowering this value can reduce resource consumption of Nomad server when
	// the FuzzySearch API is enabled.
	//
	// Default value: 20.
	LimitQuery int `hcl:"limit_query"`

	// LimitResults limits the number of results provided by the FuzzySearch API.
	// The results are indicated as truncate if the limit is reached.
	//
	// Lowering this value can reduce resource consumption of Nomad server per
	// fuzzy search request when the FuzzySearch API is enabled.
	//
	// Default value: 100.
	LimitResults int `hcl:"limit_results"`

	// MinTermLength is the minimum length of Text required before the FuzzySearch
	// API will return results.
	//
	// Increasing this value can avoid resource consumption on Nomad server by
	// reducing searches with less meaningful results.
	//
	// Default value: 2.
	MinTermLength int `hcl:"min_term_length"`
}

Search is used in servers to configure search API options.

func (*Search) Copy added in v1.2.13

func (s *Search) Copy() *Search

type ServerConfig

type ServerConfig struct {
	// Enabled controls if we are a server
	Enabled bool `hcl:"enabled"`

	// AuthoritativeRegion is used to control which region is treated as
	// the source of truth for global tokens and ACL policies.
	AuthoritativeRegion string `hcl:"authoritative_region"`

	// BootstrapExpect tries to automatically bootstrap the Consul cluster,
	// by withholding peers until enough servers join.
	BootstrapExpect int `hcl:"bootstrap_expect"`

	// DataDir is the directory to store our state in
	DataDir string `hcl:"data_dir"`

	// 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" json:"-"`

	// RaftProtocol is the Raft protocol version to speak. This must be from [1-3].
	RaftProtocol int `hcl:"raft_protocol"`

	// RaftMultiplier scales the Raft timing parameters
	RaftMultiplier *int `hcl:"raft_multiplier"`

	// NumSchedulers is the number of scheduler thread that are run.
	// This can be as many as one per core, or zero to disable this server
	// from doing any scheduling work.
	NumSchedulers *int `hcl:"num_schedulers"`

	// EnabledSchedulers controls the set of sub-schedulers that are
	// enabled for this server to handle. This will restrict the evaluations
	// that the workers dequeue for processing.
	EnabledSchedulers []string `hcl:"enabled_schedulers"`

	// NodeGCThreshold controls how "old" a node must be to be collected by GC.
	// Age is not the only requirement for a node to be GCed but the threshold
	// can be used to filter by age.
	NodeGCThreshold string `hcl:"node_gc_threshold"`

	// JobGCInterval controls how often we dispatch a job to GC jobs that are
	// available for garbage collection.
	JobGCInterval string `hcl:"job_gc_interval"`

	// JobGCThreshold controls how "old" a job must be to be collected by GC.
	// Age is not the only requirement for a Job to be GCed but the threshold
	// can be used to filter by age.
	JobGCThreshold string `hcl:"job_gc_threshold"`

	// EvalGCThreshold controls how "old" an eval must be to be collected by GC.
	// Age is not the only requirement for a eval to be GCed but the threshold
	// can be used to filter by age. Please note that batch job evaluations are
	// controlled by 'BatchEvalGCThreshold' instead.
	EvalGCThreshold string `hcl:"eval_gc_threshold"`

	// BatchEvalGCThreshold controls how "old" an evaluation must be to be eligible
	// for GC if the eval belongs to a batch job.
	BatchEvalGCThreshold string `hcl:"batch_eval_gc_threshold"`

	// DeploymentGCThreshold controls how "old" a deployment must be to be
	// collected by GC. Age is not the only requirement for a deployment to be
	// GCed but the threshold can be used to filter by age.
	DeploymentGCThreshold string `hcl:"deployment_gc_threshold"`

	// CSIVolumeClaimGCInterval is how often we dispatch a job to GC
	// volume claims.
	CSIVolumeClaimGCInterval string `hcl:"csi_volume_claim_gc_interval"`

	// CSIVolumeClaimGCThreshold controls how "old" a CSI volume must be to
	// have its claims collected by GC.	Age is not the only requirement for
	// a volume to be GCed but the threshold can be used to filter by age.
	CSIVolumeClaimGCThreshold string `hcl:"csi_volume_claim_gc_threshold"`

	// CSIPluginGCThreshold controls how "old" a CSI plugin must be to be
	// collected by GC. Age is not the only requirement for a plugin to be
	// GCed but the threshold can be used to filter by age.
	CSIPluginGCThreshold string `hcl:"csi_plugin_gc_threshold"`

	// ACLTokenGCThreshold controls how "old" an expired ACL token must be to
	// be collected by GC.
	ACLTokenGCThreshold string `hcl:"acl_token_gc_threshold"`

	// RootKeyGCInterval is how often we dispatch a job to GC
	// encryption key metadata
	RootKeyGCInterval string `hcl:"root_key_gc_interval"`

	// RootKeyGCThreshold is how "old" encryption key metadata must be
	// to be eligible for GC.
	RootKeyGCThreshold string `hcl:"root_key_gc_threshold"`

	// RootKeyRotationThreshold is how "old" an encryption key must be
	// before it is automatically rotated on the next garbage
	// collection interval.
	RootKeyRotationThreshold string `hcl:"root_key_rotation_threshold"`

	// HeartbeatGrace is the grace period beyond the TTL to account for network,
	// processing delays and clock skew before marking a node as "down".
	HeartbeatGrace    time.Duration
	HeartbeatGraceHCL string `hcl:"heartbeat_grace" json:"-"`

	// MinHeartbeatTTL is the minimum time between heartbeats. This is used as
	// a floor to prevent excessive updates.
	MinHeartbeatTTL    time.Duration
	MinHeartbeatTTLHCL string `hcl:"min_heartbeat_ttl" json:"-"`

	// MaxHeartbeatsPerSecond is the maximum target rate of heartbeats
	// being processed per second. This allows the TTL to be increased
	// to meet the target rate.
	MaxHeartbeatsPerSecond float64 `hcl:"max_heartbeats_per_second"`

	// FailoverHeartbeatTTL is the TTL applied to heartbeats after
	// a new leader is elected, since we no longer know the status
	// of all the heartbeats.
	FailoverHeartbeatTTL    time.Duration
	FailoverHeartbeatTTLHCL string `hcl:"failover_heartbeat_ttl" json:"-"`

	// StartJoin is a list of addresses to attempt to join when the
	// agent starts. If Serf is unable to communicate with any of these
	// addresses, then the agent will error and exit.
	// Deprecated in Nomad 0.10
	StartJoin []string `hcl:"start_join"`

	// RetryJoin is a list of addresses to join with retry enabled.
	// Deprecated in Nomad 0.10
	RetryJoin []string `hcl:"retry_join"`

	// RetryMaxAttempts specifies the maximum number of times to retry joining a
	// host on startup. This is useful for cases where we know the node will be
	// online eventually.
	// Deprecated in Nomad 0.10
	RetryMaxAttempts int `hcl:"retry_max"`

	// RetryInterval specifies the amount of time to wait in between join
	// attempts on agent start. The minimum allowed value is 1 second and
	// the default is 30s.
	// Deprecated in Nomad 0.10
	RetryInterval    time.Duration
	RetryIntervalHCL string `hcl:"retry_interval" json:"-"`

	// RejoinAfterLeave controls our interaction with the cluster after leave.
	// When set to false (default), a leave causes Nomad to not rejoin
	// the cluster until an explicit join is received. If this is set to
	// true, we ignore the leave, and rejoin the cluster on start.
	RejoinAfterLeave bool `hcl:"rejoin_after_leave"`

	// (Enterprise-only) NonVotingServer is whether this server will act as a
	// non-voting member of the cluster to help provide read scalability.
	NonVotingServer bool `hcl:"non_voting_server"`

	// (Enterprise-only) RedundancyZone is the redundancy zone to use for this server.
	RedundancyZone string `hcl:"redundancy_zone"`

	// (Enterprise-only) UpgradeVersion is the custom upgrade version to use when
	// performing upgrade migrations.
	UpgradeVersion string `hcl:"upgrade_version"`

	// Encryption key to use for the Serf communication
	EncryptKey string `hcl:"encrypt" json:"-"`

	// ServerJoin contains information that is used to attempt to join servers
	ServerJoin *ServerJoin `hcl:"server_join"`

	// DefaultSchedulerConfig configures the initial scheduler config to be persisted in Raft.
	// Once the cluster is bootstrapped, and Raft persists the config (from here or through API),
	// This value is ignored.
	DefaultSchedulerConfig *structs.SchedulerConfiguration `hcl:"default_scheduler_config"`

	// PlanRejectionTracker configures the node plan rejection tracker that
	// detects potentially bad nodes.
	PlanRejectionTracker *PlanRejectionTracker `hcl:"plan_rejection_tracker"`

	// EnableEventBroker configures whether this server's state store
	// will generate events for its event stream.
	EnableEventBroker *bool `hcl:"enable_event_broker"`

	// EventBufferSize configure the amount of events to be held in memory.
	// If EnableEventBroker is set to true, the minimum allowable value
	// for the EventBufferSize is 1.
	EventBufferSize *int `hcl:"event_buffer_size"`

	// LicensePath is the path to search for an enterprise license.
	LicensePath string `hcl:"license_path"`

	// LicenseEnv is the full enterprise license.  If NOMAD_LICENSE
	// is set, LicenseEnv will be set to the value at startup.
	LicenseEnv string

	// ExtraKeysHCL is used by hcl to surface unexpected keys
	ExtraKeysHCL []string `hcl:",unusedKeys" json:"-"`

	// Search configures UI search features.
	Search *Search `hcl:"search"`

	// DeploymentQueryRateLimit is in queries per second and is used by the
	// DeploymentWatcher to throttle the amount of simultaneously deployments
	DeploymentQueryRateLimit float64 `hcl:"deploy_query_rate_limit"`

	// RaftBoltConfig configures boltdb as used by raft.
	RaftBoltConfig *RaftBoltConfig `hcl:"raft_boltdb"`

	// RaftSnapshotThreshold controls how many outstanding logs there must be
	// before we perform a snapshot. This is to prevent excessive snapshotting by
	// replaying a small set of logs instead. The value passed here is the initial
	// setting used. This can be tuned during operation with a hot reload.
	RaftSnapshotThreshold *int `hcl:"raft_snapshot_threshold"`

	// RaftSnapshotInterval controls how often we check if we should perform a
	// snapshot. We randomly stagger between this value and 2x this value to avoid
	// the entire cluster from performing a snapshot at once. The value passed
	// here is the initial setting used. This can be tuned during operation with a
	// hot reload.
	RaftSnapshotInterval *string `hcl:"raft_snapshot_interval"`

	// RaftTrailingLogs controls how many logs are left after a snapshot. This is
	// used so that we can quickly replay logs on a follower instead of being
	// forced to send an entire snapshot. The value passed here is the initial
	// setting used. This can be tuned during operation using a hot reload.
	RaftTrailingLogs *int `hcl:"raft_trailing_logs"`

	// JobDefaultPriority is the default Job priority if not specified.
	JobDefaultPriority *int `hcl:"job_default_priority"`

	// JobMaxPriority is an upper bound on the Job priority.
	JobMaxPriority *int `hcl:"job_max_priority"`
	// contains filtered or unexported fields
}

ServerConfig is configuration specific to the server mode

func (*ServerConfig) Copy added in v1.2.13

func (s *ServerConfig) Copy() *ServerConfig

func (*ServerConfig) EncryptBytes added in v0.5.0

func (s *ServerConfig) EncryptBytes() ([]byte, error)

EncryptBytes returns the encryption key configured.

func (*ServerConfig) Merge

func (s *ServerConfig) Merge(b *ServerConfig) *ServerConfig

Merge is used to merge two server configs together

type ServerJoin added in v0.8.4

type ServerJoin struct {
	// StartJoin is a list of addresses to attempt to join when the
	// agent starts. If Serf is unable to communicate with any of these
	// addresses, then the agent will error and exit.
	StartJoin []string `hcl:"start_join"`

	// RetryJoin is a list of addresses to join with retry enabled, or a single
	// value to find multiple servers using go-discover syntax.
	RetryJoin []string `hcl:"retry_join"`

	// RetryMaxAttempts specifies the maximum number of times to retry joining a
	// host on startup. This is useful for cases where we know the node will be
	// online eventually.
	RetryMaxAttempts int `hcl:"retry_max"`

	// RetryInterval specifies the amount of time to wait in between join
	// attempts on agent start. The minimum allowed value is 1 second and
	// the default is 30s.
	RetryInterval    time.Duration
	RetryIntervalHCL string `hcl:"retry_interval" json:"-"`

	// ExtraKeysHCL is used by hcl to surface unexpected keys
	ExtraKeysHCL []string `hcl:",unusedKeys" json:"-"`
}

ServerJoin is used in both clients and servers to bootstrap connections to servers

func (*ServerJoin) Copy added in v1.2.13

func (s *ServerJoin) Copy() *ServerJoin

func (*ServerJoin) Merge added in v0.8.4

func (s *ServerJoin) Merge(b *ServerJoin) *ServerJoin

type SyslogWrapper

type SyslogWrapper struct {
	// contains filtered or unexported fields
}

SyslogWrapper is used to cleanup log messages before writing them to a Syslogger. Implements the io.Writer interface.

func (*SyslogWrapper) Write

func (s *SyslogWrapper) Write(p []byte) (int, error)

Write is used to implement io.Writer

type Telemetry

type Telemetry struct {
	StatsiteAddr       string   `hcl:"statsite_address"`
	StatsdAddr         string   `hcl:"statsd_address"`
	DataDogAddr        string   `hcl:"datadog_address"`
	DataDogTags        []string `hcl:"datadog_tags"`
	PrometheusMetrics  bool     `hcl:"prometheus_metrics"`
	DisableHostname    bool     `hcl:"disable_hostname"`
	UseNodeName        bool     `hcl:"use_node_name"`
	CollectionInterval string   `hcl:"collection_interval"`

	PublishAllocationMetrics bool `hcl:"publish_allocation_metrics"`
	PublishNodeMetrics       bool `hcl:"publish_node_metrics"`

	// PrefixFilter allows for filtering out metrics from being collected
	PrefixFilter []string `hcl:"prefix_filter"`

	// FilterDefault controls whether to allow metrics that have not been specified
	// by the filter
	FilterDefault *bool `hcl:"filter_default"`

	// DisableDispatchedJobSummaryMetrics allows ignoring dispatched jobs when
	// publishing Job summary metrics. This is useful in environments that produce
	// high numbers of single count dispatch jobs as the metrics for each take up
	// a small memory overhead.
	DisableDispatchedJobSummaryMetrics bool `hcl:"disable_dispatched_job_summary_metrics"`

	// DisableRPCRateMetricsLabels drops the label for the identity of the
	// requester when publishing metrics on RPC rate on the server. This may be
	// useful to control metrics collection costs in environments where request
	// rate is well-controlled but cardinality of requesters is high.
	DisableRPCRateMetricsLabels bool `hcl:"disable_rpc_rate_metrics_labels"`

	// CirconusAPIToken is a valid API Token used to create/manage check. If provided,
	// metric management is enabled.
	// Default: none
	CirconusAPIToken string `hcl:"circonus_api_token"`
	// CirconusAPIApp is an app name associated with API token.
	// Default: "nomad"
	CirconusAPIApp string `hcl:"circonus_api_app"`
	// CirconusAPIURL is the base URL to use for contacting the Circonus API.
	// Default: "https://api.circonus.com/v2"
	CirconusAPIURL string `hcl:"circonus_api_url"`
	// CirconusSubmissionInterval is the interval at which metrics are submitted to Circonus.
	// Default: 10s
	CirconusSubmissionInterval string `hcl:"circonus_submission_interval"`
	// CirconusCheckSubmissionURL is the check.config.submission_url field from a
	// previously created HTTPTRAP check.
	// Default: none
	CirconusCheckSubmissionURL string `hcl:"circonus_submission_url"`
	// CirconusCheckID is the check id (not check bundle id) from a previously created
	// HTTPTRAP check. The numeric portion of the check._cid field.
	// Default: none
	CirconusCheckID string `hcl:"circonus_check_id"`
	// CirconusCheckForceMetricActivation will force enabling metrics, as they are encountered,
	// if the metric already exists and is NOT active. If check management is enabled, the default
	// behavior is to add new metrics as they are encountered. If the metric already exists in the
	// check, it will *NOT* be activated. This setting overrides that behavior.
	// Default: "false"
	CirconusCheckForceMetricActivation string `hcl:"circonus_check_force_metric_activation"`
	// CirconusCheckInstanceID serves to uniquely identify the metrics coming from this "instance".
	// It can be used to maintain metric continuity with transient or ephemeral instances as
	// they move around within an infrastructure.
	// Default: hostname:app
	CirconusCheckInstanceID string `hcl:"circonus_check_instance_id"`
	// CirconusCheckSearchTag is a special tag which, when coupled with the instance id, helps to
	// narrow down the search results when neither a Submission URL or Check ID is provided.
	// Default: service:app (e.g. service:nomad)
	CirconusCheckSearchTag string `hcl:"circonus_check_search_tag"`
	// CirconusCheckTags is a comma separated list of tags to apply to the check. Note that
	// the value of CirconusCheckSearchTag will always be added to the check.
	// Default: none
	CirconusCheckTags string `hcl:"circonus_check_tags"`
	// CirconusCheckDisplayName is the name for the check which will be displayed in the Circonus UI.
	// Default: value of CirconusCheckInstanceID
	CirconusCheckDisplayName string `hcl:"circonus_check_display_name"`
	// CirconusBrokerID is an explicit broker to use when creating a new check. The numeric portion
	// of broker._cid. If metric management is enabled and neither a Submission URL nor Check ID
	// is provided, an attempt will be made to search for an existing check using Instance ID and
	// Search Tag. If one is not found, a new HTTPTRAP check will be created.
	// Default: use Select Tag if provided, otherwise, a random Enterprise Broker associated
	// with the specified API token or the default Circonus Broker.
	// Default: none
	CirconusBrokerID string `hcl:"circonus_broker_id"`
	// CirconusBrokerSelectTag is a special tag which will be used to select a broker when
	// a Broker ID is not provided. The best use of this is to as a hint for which broker
	// should be used based on *where* this particular instance is running.
	// (e.g. a specific geo location or datacenter, dc:sfo)
	// Default: none
	CirconusBrokerSelectTag string `hcl:"circonus_broker_select_tag"`

	// ExtraKeysHCL is used by hcl to surface unexpected keys
	ExtraKeysHCL []string `hcl:",unusedKeys" json:"-"`
	// contains filtered or unexported fields
}

Telemetry is the telemetry configuration for the server

func (*Telemetry) Copy added in v1.2.13

func (t *Telemetry) Copy() *Telemetry

func (*Telemetry) Merge

func (a *Telemetry) Merge(b *Telemetry) *Telemetry

Merge is used to merge two telemetry configs together

func (*Telemetry) PrefixFilters added in v0.8.7

func (a *Telemetry) PrefixFilters() (allowed, blocked []string, err error)

PrefixFilters parses the PrefixFilter field and returns a list of allowed and blocked filters

type TestAgent added in v0.6.0

type TestAgent struct {
	// T is the testing object
	T testing.TB

	// Name is an optional name of the agent.
	Name string

	// ConfigCallback is an optional callback that allows modification of the
	// configuration before the agent is started.
	ConfigCallback func(*Config)

	// Config is the agent configuration. If Config is nil then
	// TestConfig() is used. If Config.DataDir is set then it is
	// the callers responsibility to clean up the data directory.
	// Otherwise, a temporary data directory is created and removed
	// when Shutdown() is called.
	Config *Config

	// DataDir is the data directory which is used when Config.DataDir
	// is not set. It is created automatically and removed when
	// Shutdown() is called.
	DataDir string

	// Key is the optional encryption key for the keyring.
	Key string

	// All HTTP servers started. Used to prevent server leaks and preserve
	// backwards compatibility.
	Servers []*HTTPServer

	// Server is a reference to the primary, started HTTP endpoint.
	// It is valid after Start().
	Server *HTTPServer

	// Agent is the embedded Nomad agent.
	// It is valid after Start().
	*Agent

	// RootToken is auto-bootstrapped if ACLs are enabled
	RootToken *structs.ACLToken

	// Enterprise specifies if the agent is enterprise or not
	Enterprise bool
	// contains filtered or unexported fields
}

TestAgent encapsulates an Agent with a default configuration and startup procedure suitable for testing. It manages a temporary data directory which is removed after shutdown.

func NewTestAgent added in v0.6.0

func NewTestAgent(t testing.TB, name string, configCallback func(*Config)) *TestAgent

NewTestAgent returns a started agent with the given name and configuration. The caller should call Shutdown() to stop the agent and remove temporary directories.

func (*TestAgent) Client added in v0.6.0

func (a *TestAgent) Client() *api.Client

func (*TestAgent) HTTPAddr added in v0.6.0

func (a *TestAgent) HTTPAddr() string

func (*TestAgent) Shutdown added in v0.6.0

func (a *TestAgent) Shutdown()

Shutdown stops the agent and removes the data directory if it is managed by the test agent.

func (*TestAgent) Start added in v0.6.0

func (a *TestAgent) Start() *TestAgent

Start starts a test agent.

type UIAssetWrapper added in v0.7.0

type UIAssetWrapper struct {
	FileSystem *assetfs.AssetFS
}

func (*UIAssetWrapper) Open added in v0.7.0

func (fs *UIAssetWrapper) Open(name string) (http.File, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL