open-nomad/command/agent
Mahmood Ali cdddd64a42
logging: Log the cause behind agent startup failure (#11353)
Log the failure error when the agent fails to start. Previously, the
agent startup failure error would be emitted to the command UI but not
logged. So it doesn't get emitted to syslog or `log_file` if they are
set, and it makes debugging much harder. Also, logging the error again
before exit makes the error more visible: previously, the operator
needed to scroll to the top to find the error.

On a sample failure, the output will look like:
```
==> WARNING: Bootstrap mode enabled! Potentially unsafe operation.
==> Loaded configuration from sample-configs/config-bad
==> Starting Nomad agent...
==> Error starting agent: setting up server node ID failed: mkdir /path-without-permission: read-only file system
    2021-10-20T14:38:51.179-0400 [WARN]  agent.plugin_loader: skipping external plugins since plugin_dir doesn't exist: plugin_dir=/path-without-permission/plugins
    2021-10-20T14:38:51.181-0400 [DEBUG] agent.plugin_loader.docker: using client connection initialized from environment: plugin_dir=/path-without-permission/plugins
    2021-10-20T14:38:51.181-0400 [DEBUG] agent.plugin_loader.docker: using client connection initialized from environment: plugin_dir=/path-without-permission/plugins
    2021-10-20T14:38:51.181-0400 [INFO]  agent: detected plugin: name=java type=driver plugin_version=0.1.0
    2021-10-20T14:38:51.181-0400 [INFO]  agent: detected plugin: name=docker type=driver plugin_version=0.1.0
    2021-10-20T14:38:51.181-0400 [INFO]  agent: detected plugin: name=mock_driver type=driver plugin_version=0.1.0
    2021-10-20T14:38:51.181-0400 [INFO]  agent: detected plugin: name=raw_exec type=driver plugin_version=0.1.0
    2021-10-20T14:38:51.181-0400 [INFO]  agent: detected plugin: name=exec type=driver plugin_version=0.1.0
    2021-10-20T14:38:51.181-0400 [INFO]  agent: detected plugin: name=qemu type=driver plugin_version=0.1.0
    2021-10-20T14:38:51.181-0400 [ERROR] agent: error starting agent: error="setting up server node ID failed: mkdir /path-without-permission: read-only file system"
```

This change adds the final `ERROR` message. It's easy to miss the `==>
Error starting agent` above.
2021-10-27 10:41:17 -07:00
..
consul fix panic when Connect mesh gateway doesn't have a proxy block (#11257) 2021-10-04 15:52:07 -04:00
event
host gofmt all the files 2021-10-01 10:14:28 -04:00
monitor
pprof
test-resources
testdata Add FailoverHeartbeatTTL to config (#11127) 2021-10-06 18:48:12 -04:00
acl_endpoint.go HTTP API support for 'nomad ui -login' 2021-03-10 08:17:56 -05:00
acl_endpoint_test.go command/agent: fix dropped test errors 2021-04-13 01:51:24 -07:00
agent.go Merge pull request #11167 from a-zagaevskiy/master 2021-10-13 16:47:38 -07:00
agent_endpoint.go
agent_endpoint_test.go
agent_oss.go gofmt all the files 2021-10-01 10:14:28 -04:00
agent_test.go Add FailoverHeartbeatTTL to config (#11127) 2021-10-06 18:48:12 -04:00
alloc_endpoint.go exec: http: close websocket connection gracefully 2021-05-24 13:37:23 -04:00
alloc_endpoint_test.go
bindata_assetfs.go Merge missing commits from 1.2.0-beta1 release branch (#11319) 2021-10-14 16:10:05 -04:00
command.go logging: Log the cause behind agent startup failure (#11353) 2021-10-27 10:41:17 -07:00
command_test.go client: improve errors & tests for dynamic ports 2021-10-13 16:25:25 -07:00
config.go Merge pull request #11167 from a-zagaevskiy/master 2021-10-13 16:47:38 -07:00
config_oss.go gofmt all the files 2021-10-01 10:14:28 -04:00
config_parse.go Add FailoverHeartbeatTTL to config (#11127) 2021-10-06 18:48:12 -04:00
config_parse_test.go Add FailoverHeartbeatTTL to config (#11127) 2021-10-06 18:48:12 -04:00
config_test.go client: output reserved ports with min/max ports 2021-09-30 17:05:46 -07:00
csi_endpoint.go CSI ListSnapshots secrets implementation 2021-07-28 11:30:29 -07:00
csi_endpoint_test.go CSI: capability block is required for volume registration 2021-04-08 13:02:24 -04:00
deployment_endpoint.go
deployment_endpoint_test.go
eval_endpoint.go
eval_endpoint_test.go
event_endpoint.go
event_endpoint_test.go
fs_endpoint.go
fs_endpoint_test.go
helpers.go
helpers_test.go
http.go Set/parse idempotency_token query param 2021-07-07 16:26:55 -05:00
http_oss.go gofmt all the files 2021-10-01 10:14:28 -04:00
http_stdlog.go
http_stdlog_test.go
http_test.go tests: use standard library testing.TB 2021-06-09 16:18:45 -07:00
job_endpoint.go allow configuration of Docker hostnames in bridge mode (#11173) 2021-09-16 08:13:09 +02:00
job_endpoint_test.go allow configuration of Docker hostnames in bridge mode (#11173) 2021-09-16 08:13:09 +02:00
keyring.go
keyring_test.go
log_file.go prevent active log from being overwritten when agent starts (#11386) 2021-10-26 20:57:07 -04:00
log_file_bsd.go prevent active log from being overwritten when agent starts (#11386) 2021-10-26 20:57:07 -04:00
log_file_linux.go prevent active log from being overwritten when agent starts (#11386) 2021-10-26 20:57:07 -04:00
log_file_test.go prevent active log from being overwritten when agent starts (#11386) 2021-10-26 20:57:07 -04:00
log_file_windows.go prevent active log from being overwritten when agent starts (#11386) 2021-10-26 20:57:07 -04:00
log_levels.go
log_levels_test.go
metrics_endpoint.go agent: return req error if prometheus metrics are disabled. 2021-03-09 15:28:58 +01:00
metrics_endpoint_test.go agent: return req error if prometheus metrics are disabled. 2021-03-09 15:28:58 +01:00
namespace_endpoint.go
namespace_endpoint_test.go gofmt all the files 2021-10-01 10:14:28 -04:00
node_endpoint.go Node Drain Metadata (#10250) 2021-05-07 13:58:40 -04:00
node_endpoint_test.go Node Drain Metadata (#10250) 2021-05-07 13:58:40 -04:00
operator_endpoint.go Return SchedulerConfig instead of SchedulerConfigResponse struct (#10799) 2021-10-13 21:23:13 -04:00
operator_endpoint_oss.go gofmt all the files 2021-10-01 10:14:28 -04:00
operator_endpoint_test.go Return SchedulerConfig instead of SchedulerConfigResponse struct (#10799) 2021-10-13 21:23:13 -04:00
plugins.go
region_endpoint.go
region_endpoint_test.go
retry_join.go
retry_join_test.go
scaling_endpoint.go
scaling_endpoint_test.go
search_endpoint.go api: implement fuzzy search API 2021-04-16 16:36:07 -06:00
search_endpoint_test.go api: implement fuzzy search API 2021-04-16 16:36:07 -06:00
stats_endpoint.go
stats_endpoint_test.go
status_endpoint.go
status_endpoint_test.go
stub_asset.go gofmt all the files 2021-10-01 10:14:28 -04:00
syslog.go
syslog_test.go
system_endpoint.go
system_endpoint_test.go
testagent.go tests: use standard library testing.TB 2021-06-09 16:18:45 -07:00
testagent_oss.go gofmt all the files 2021-10-01 10:14:28 -04:00
testingutils_test.go