Daniel Nephin
a97adadd2b
config: use logging.Config in RuntimeConfig
...
To add structure to RuntimeConfig, and remove the need to translate into a third type.
2020-08-19 13:21:00 -04:00
Daniel Nephin
84642486b9
agent: extract dependency creation from New
...
With this change, Agent.New() accepts many of the dependencies instead
of creating them in New. Accepting fully constructed dependencies from
a constructor makes the type easier to test, and easier to change.
There are still a number of dependencies created in Start() which can
be addressed in a follow up.
2020-08-18 19:04:55 -04:00
Matt Keeler
934f92f83b
Don’t leak metrics go routines in tests ( #8182 )
2020-06-24 10:15:25 -04:00
Matt Keeler
9dc9f7df15
Allow cancelling startup when performing auto-config ( #8157 )
...
Co-authored-by: Daniel Nephin <dnephin@hashicorp.com>
2020-06-19 15:16:00 -04:00
Matt Keeler
2c7844d220
Implement Client Agent Auto Config
...
There are a couple of things in here.
First, just like auto encrypt, any Cluster.AutoConfig RPC will implicitly use the less secure RPC mechanism.
This drastically modifies how the Consul Agent starts up and moves most of the responsibilities (other than signal handling) from the cli command and into the Agent.
2020-06-17 16:49:46 -04:00
Daniel Nephin
b7b652e8c9
config: rename Flags to BuilderOpts
...
Flags is an overloaded term in this context. It generally is used to
refer to command line flags. This struct, however, is a data object
used as input to the construction.
It happens to be partially populated by command line flags, but
otherwise has very little to do with them.
Renaming this struct should make the actual responsibility of this struct
more obvious, and remove the possibility that it is confused with
command line flags.
This change is in preparation for adding additional fields to
BuilderOpts.
2020-06-16 12:51:19 -04:00
Daniel Nephin
5ac012dddf
config: remove Args field from Flags
...
This field was populated for one reason, to test that it was empty.
Of all the callers, only a single one used this functionality. The rest
constructed a `Flags{}` struct which did not set Args.
I think this shows that the logic was in the wrong place. Only the agent
command needs to care about validating the args.
This commit removes the field, and moves the logic to the one caller
that cares.
Also fix some comments.
2020-06-16 12:49:53 -04:00
Daniel Nephin
7064dfbfba
command: remove unused logOutput field
2020-03-30 14:11:27 -04:00
Chris Piraino
f13d6ca812
Log "vew version available" message at info level ( #7462 )
2020-03-17 09:53:15 -05:00
Johannes Scheuermann
bc87976708
agent: log error when agent crashes in an early stage ( #7411 )
2020-03-09 10:45:21 +01:00
Chris Piraino
3dd0b59793
Allow users to configure either unstructured or JSON logging ( #7130 )
...
* hclog Allow users to choose between unstructured and JSON logging
2020-01-28 17:50:41 -06:00
javicrespo
d4f3eebf9d
log rotation: limit count of rotated log files ( #5831 )
2019-07-19 15:36:34 -06:00
Hans Hasselberg
be6edd6f90
agent: check for gossip encrypt key ( #6037 )
2019-06-28 00:57:29 +02:00
Hans Hasselberg
73c4e9f07c
tls: auto_encrypt enables automatic RPC cert provisioning for consul clients ( #5597 )
2019-06-27 22:22:07 +02:00
Freddy
a3ad908b56
Do not trigger update check when in dev mode
2019-05-07 09:15:34 -06:00
Paul Banks
1e4c5a1811
Connect Envoy Command ( #4735 )
...
* Plumb xDS server and proxyxfg into the agent startup
* Add `consul connect envoy` command to allow running Envoy as a connect sidecar.
* Add test for help tabs; typos and style fixups from review
2018-10-10 16:55:34 +01:00
Paul Banks
cba42d6790
XDS Server Config ( #4730 )
...
* Config for the coming XDS server
* Default gRPC to 8502 for -dev mode; Re-merge the command Info output that shows gRPC.
2018-10-10 16:55:34 +01:00
Siva Prasad
59dea9a31f
Adds a new command line flag -log-file for file based logging. ( #4581 )
...
* Added log-file flag to capture Consul logs in a user specified file
* Refactored code.
* Refactored code. Added flags to rotate logs based on bytes and duration
* Added the flags for log file and log rotation on the webpage
* Fixed TestSantize from failing due to the addition of 3 flags
* Introduced changes : mutex, data-dir log writes, rotation logic
* Added test for logfile and updated the default log destination for docs
* Log name now uses UnixNano
* TestLogFile is now uses t.Parallel()
* Removed unnecessary int64Val function
* Updated docs to reflect default log name for log-file
* No longer writes to data-dir and adds .log if the filename has no extension
2018-08-29 16:56:58 -04:00
Siva
2182e289a3
Merge branch 'master' of github.com:hashicorp/consul into WinService
2018-06-26 16:49:50 -04:00
Paul Banks
ca68136ac7
Refactor to use embedded struct.
2018-06-25 12:25:39 -07:00
Paul Banks
23be6ad1c8
StartupTelemetry => InitTelemetry
2018-06-25 12:25:39 -07:00
Paul Banks
93f346431b
WIP
2018-06-25 12:25:38 -07:00
Siva
e54fbbba51
Graceful exits added
2018-06-20 14:42:08 -04:00
Kyle Havlovitz
1e47c757c2
command/agent: don't re-parse the flags on reload
2018-05-31 16:59:51 -07:00
Paul Banks
06e1a62653
Merge pull request #4016 from pierresouchay/support_for_prometheus
...
Support for prometheus for metrics endpoint
2018-04-24 16:14:43 +01:00
James Nugent
e96b2b8d09
Only call signal.Notify once during agent startup
...
Calling twice appears to have no adverse effects, however serves to
confuse as to what the semantics of such code may be! This seems like it
was probably introduced while resolving conflicts during the merge of
the fix for #2404 .
2018-04-10 20:44:50 -05:00
Pierre Souchay
2e495ec8a6
Now use prometheus_retention_time > 0 to enable prometheus support
2018-04-06 14:21:05 +02:00
Pierre Souchay
583744d8c5
Added support exposing metrics in Prometheus format
2018-04-06 09:18:06 +02:00
Guido Iaquinti
244fc72b05
Add package name to log output
2018-03-21 15:56:14 +00:00
Frank Schroeder
c624c72d5c
config: return error on extra command line arguments ( #3397 )
...
The `consul agent` command was ignoring extra command line arguments
which can lead to confusion when the user has for example forgotten to
add a dash in front of an argument or is not using an `=` when setting
boolean flags to `true`. `-bootstrap true` is not the same as
`-bootstrap=true`, for example.
Since all command line flags are known and we don't expect unparsed
arguments we can return an error. However, this may make it slightly
more difficult in the future if we ever wanted to have these kinds of
arguments.
Fixes #3397
2017-10-23 08:07:48 +02:00
Frank Schroeder
8f58a603ea
commands: get HTTP API flags for usage automatically
2017-10-18 00:08:45 +02:00
Frank Schroeder
efab66e616
commands: cleanup help and synopsis.
...
* move Help and Synopsis to bottom
* make help and synopsis constants
* make sure help output is formatted
2017-10-18 00:08:45 +02:00
Frank Schroeder
a0b017d976
commands: move agent command to separate pkg
2017-10-18 00:08:45 +02:00
Frank Schroeder
cd837b0b18
pkg refactor
...
command/agent/* -> agent/*
command/consul/* -> agent/consul/*
command/agent/command{,_test}.go -> command/agent{,_test}.go
command/base/command.go -> command/base.go
command/base/* -> command/*
commands.go -> command/commands.go
The script which did the refactor is:
(
cd $GOPATH/src/github.com/hashicorp/consul
git mv command/agent/command.go command/agent.go
git mv command/agent/command_test.go command/agent_test.go
git mv command/agent/flag_slice_value{,_test}.go command/
git mv command/agent .
git mv command/base/command.go command/base.go
git mv command/base/config_util{,_test}.go command/
git mv commands.go command/
git mv consul agent
rmdir command/base/
gsed -i -e 's|package agent|package command|' command/agent{,_test}.go
gsed -i -e 's|package agent|package command|' command/flag_slice_value{,_test}.go
gsed -i -e 's|package base|package command|' command/base.go command/config_util{,_test}.go
gsed -i -e 's|package main|package command|' command/commands.go
gsed -i -e 's|base.Command|BaseCommand|' command/commands.go
gsed -i -e 's|agent.Command|AgentCommand|' command/commands.go
gsed -i -e 's|\tCommand:|\tBaseCommand:|' command/commands.go
gsed -i -e 's|base\.||' command/commands.go
gsed -i -e 's|command\.||' command/commands.go
gsed -i -e 's|command|c|' main.go
gsed -i -e 's|range Commands|range command.Commands|' main.go
gsed -i -e 's|Commands: Commands|Commands: command.Commands|' main.go
gsed -i -e 's|base\.BoolValue|BoolValue|' command/operator_autopilot_set.go
gsed -i -e 's|base\.DurationValue|DurationValue|' command/operator_autopilot_set.go
gsed -i -e 's|base\.StringValue|StringValue|' command/operator_autopilot_set.go
gsed -i -e 's|base\.UintValue|UintValue|' command/operator_autopilot_set.go
gsed -i -e 's|\bCommand\b|BaseCommand|' command/base.go
gsed -i -e 's|BaseCommand Options|Command Options|' command/base.go
gsed -i -e 's|base.Command|BaseCommand|' command/*.go
gsed -i -e 's|c\.Command|c.BaseCommand|g' command/*.go
gsed -i -e 's|\tCommand:|\tBaseCommand:|' command/*_test.go
gsed -i -e 's|base\.||' command/*_test.go
gsed -i -e 's|\bCommand\b|AgentCommand|' command/agent{,_test}.go
gsed -i -e 's|cmd.AgentCommand|cmd.BaseCommand|' command/agent.go
gsed -i -e 's|cli.AgentCommand = new(Command)|cli.Command = new(AgentCommand)|' command/agent_test.go
gsed -i -e 's|exec.AgentCommand|exec.Command|' command/agent_test.go
gsed -i -e 's|exec.BaseCommand|exec.Command|' command/agent_test.go
gsed -i -e 's|NewTestAgent|agent.NewTestAgent|' command/agent_test.go
gsed -i -e 's|= TestConfig|= agent.TestConfig|' command/agent_test.go
gsed -i -e 's|: RetryJoin|: agent.RetryJoin|' command/agent_test.go
gsed -i -e 's|\.\./\.\./|../|' command/config_util_test.go
gsed -i -e 's|\bverifyUniqueListeners|VerifyUniqueListeners|' agent/config{,_test}.go command/agent.go
gsed -i -e 's|\bserfLANKeyring\b|SerfLANKeyring|g' agent/{agent,keyring,testagent}.go command/agent.go
gsed -i -e 's|\bserfWANKeyring\b|SerfWANKeyring|g' agent/{agent,keyring,testagent}.go command/agent.go
gsed -i -e 's|\bNewAgent\b|agent.New|g' command/agent{,_test}.go
gsed -i -e 's|\bNewAgent|New|' agent/{acl_test,agent,testagent}.go
gsed -i -e 's|\bAgent\b|agent.&|g' command/agent{,_test}.go
gsed -i -e 's|\bBool\b|agent.&|g' command/agent{,_test}.go
gsed -i -e 's|\bConfig\b|agent.&|g' command/agent{,_test}.go
gsed -i -e 's|\bDefaultConfig\b|agent.&|g' command/agent{,_test}.go
gsed -i -e 's|\bDevConfig\b|agent.&|g' command/agent{,_test}.go
gsed -i -e 's|\bMergeConfig\b|agent.&|g' command/agent{,_test}.go
gsed -i -e 's|\bReadConfigPaths\b|agent.&|g' command/agent{,_test}.go
gsed -i -e 's|\bParseMetaPair\b|agent.&|g' command/agent{,_test}.go
gsed -i -e 's|\bSerfLANKeyring\b|agent.&|g' command/agent{,_test}.go
gsed -i -e 's|\bSerfWANKeyring\b|agent.&|g' command/agent{,_test}.go
gsed -i -e 's|circonus\.agent|circonus|g' command/agent{,_test}.go
gsed -i -e 's|logger\.agent|logger|g' command/agent{,_test}.go
gsed -i -e 's|metrics\.agent|metrics|g' command/agent{,_test}.go
gsed -i -e 's|// agent.Agent|// agent|' command/agent{,_test}.go
gsed -i -e 's|a\.agent\.Config|a.Config|' command/agent{,_test}.go
gsed -i -e 's|agent\.AppendSliceValue|AppendSliceValue|' command/{configtest,validate}.go
gsed -i -e 's|consul/consul|agent/consul|' GNUmakefile
gsed -i -e 's|\.\./test|../../test|' agent/consul/server_test.go
# fix imports
f=$(grep -rl 'github.com/hashicorp/consul/command/agent' * | grep '\.go')
gsed -i -e 's|github.com/hashicorp/consul/command/agent|github.com/hashicorp/consul/agent|' $f
goimports -w $f
f=$(grep -rl 'github.com/hashicorp/consul/consul' * | grep '\.go')
gsed -i -e 's|github.com/hashicorp/consul/consul|github.com/hashicorp/consul/agent/consul|' $f
goimports -w $f
goimports -w command/*.go main.go
)
2017-06-10 18:52:45 +02:00
Frank Schroeder
a56d0cc95f
agent: move watch plans into agent
2017-06-10 18:52:45 +02:00
Frank Schroeder
d98f0f7bab
log: use prefix [ERR] instead of [ERROR]
2017-06-08 09:50:47 +02:00
Frank Schröder
e206ab5cb6
agent: support custom header and method for http checks ( #3106 )
...
This patch adds support for custom headers and
method for HTTP checks.
Fixes #2474
Fixes #2657
Fixes #3106
2017-06-07 01:11:56 +02:00
James Phillips
037f72813b
Merge pull request #3105 from hashicorp/test-stability
...
Tweaks things for better test stability.
2017-06-03 10:09:12 -07:00
Frank Schroeder
92b2192b75
agent: fix graceful http server shutdown
2017-06-03 19:08:50 +02:00
Frank Schroeder
6262d85dab
agent: move config reloading into the agent
2017-06-03 19:08:50 +02:00
Frank Schroeder
02ce45e5bb
agent: move parseMetaPair to config and export
2017-06-03 19:08:50 +02:00
Frank Schroeder
63d336e11c
agent: move retry join into agent
2017-06-03 19:08:50 +02:00
Frank Schroeder
488beeb208
agent: add GossipEncrypted function
...
Remove dead code and expose a GossipEncrypted() method
on the agent instead of accessing the internal delegate.
2017-06-03 19:08:50 +02:00
James Phillips
26677b4117
Cleans up an unrelated vet error.
2017-06-02 21:07:15 -07:00
Frank Schroeder
b06c969deb
agent: use agent logger for consul client and deps
2017-05-31 11:05:02 +02:00
Frank Schroeder
4e6e9cb05a
agent: set tcpKeepAliveListener when there is no error
2017-05-31 10:24:32 +02:00
Frank Schroeder
c587561572
agent: simplify shutdown timeout logging
...
Note that we are currently timing out every time. This still
needs to be investigated.
2017-05-31 09:41:58 +02:00
Frank Schroeder
b220133785
agent: set proto to http since we are logging it now
2017-05-31 09:41:16 +02:00
Frank Schroeder
bb8a21c385
Address review comments
2017-05-31 01:05:21 +02:00
Frank Schroeder
45a9c2be8b
agent: refactor DNS and HTTP server
...
* refactor DNS server to be ready for multiple bind addresses
* drop tcpKeepAliveListener since it is default for the HTTP servers
* add startup timeout watcher for HTTP servers identical to DNS server
2017-05-31 00:29:29 +02:00