Closed EugenKon closed 5 months ago
So today I investigating more into this. I have terminated my instances and plan/apply
.
Here I copied suspicious log lines:
Jun 07 14:22:38 ip-172-31-31-81 consul[935]: Node ID: '36828085-505c-d4ea-ae89-21bcd145abbd'
Jun 07 14:21:10 ip-172-31-31-81 consul[371]: Datacenter: 'dc1' (Segment: '')
Jun 07 14:21:10 ip-172-31-31-81 consul[371]: Server: false (Bootstrap: false)
Jun 07 14:21:10 ip-172-31-31-81 consul[371]: ACL Enabled: false
Jun 07 14:21:10 ip-172-31-31-81 consul[371]: 2024-06-07T14:21:10.173Z [WARN] agent: skipping file /etc/consul.d/consul.env, extension must be .hcl or .json, or config format must be set
Jun 07 14:21:10 ip-172-31-31-81 consul[371]: 2024-06-07T14:21:10.249Z [WARN] agent.auto_config: skipping file /etc/consul.d/consul.env, extension must be .hcl or .json, or config format must be set
...
Jun 07 14:24:12 ip-172-31-31-81 consul[1094]: agent: skipping file /etc/consul.d/consul.env, extension must be .hcl or .json, or config format must be set
Jun 07 14:24:12 ip-172-31-31-81 consul[1094]: agent: BootstrapExpect is set to 1; this is the same as Bootstrap mode.
Jun 07 14:24:12 ip-172-31-31-81 consul[1094]: agent: bootstrap = true: do not enable unless necessary
Jun 07 14:24:12 ip-172-31-31-81 consul[1094]: ==> Starting Consul agent...
Jun 07 14:24:12 ip-172-31-31-81 consul[1094]: Node ID: '17e21bdf-fed3-33d4-f361-9575e1d0cc99'
Jun 07 14:24:12 ip-172-31-31-81 consul[1094]: Datacenter: 'dc1' (Segment: '<all>')
Jun 07 14:24:12 ip-172-31-31-81 consul[1094]: Server: true (Bootstrap: true)
Jun 07 14:24:12 ip-172-31-31-81 consul[1094]: ACL Enabled: true
Jun 07 14:24:12 ip-172-31-31-81 consul[1094]: 2024-06-07T14:24:12.890Z [WARN] agent: skipping file /etc/consul.d/consul.env, extension must be .hcl or .json, or config format must be set
Jun 07 14:24:12 ip-172-31-31-81 consul[1094]: 2024-06-07T14:24:12.891Z [WARN] agent: BootstrapExpect is set to 1; this is the same as Bootstrap mode.
Jun 07 14:24:12 ip-172-31-31-81 consul[1094]: 2024-06-07T14:24:12.891Z [WARN] agent: bootstrap = true: do not enable unless necessary
You can notice that on the first start there is no "earlier" reading of config file, but for the 3rd systemd consul start approach it is:
Jun 07 14:24:12 ip-172-31-31-81 consul[1094]: agent: skipping file /etc/consul.d/consul.env, extension must be .hcl or .json, or config format must be set
Also for the first two starts there are Server: false (Bootstrap: false)
and ACL Enabled: false
. In compare to the 3rd start it looks like the config was not read, because on the 3rd time we see Server: true (Bootstrap: true)
and ACL Enabled: true
.
I suppose that for the first two starts the configuration file was not read.
I resolved the problem. It was a problem with a host provision. The Consul was started with default config, then a new config was copied, then the consul was restarted like here.
It is better to not start the service ahead of time. https://github.com/hashicorp/learn-nomad-cluster-setup/blob/main/shared/scripts/server.sh#L48
Then I would not experience the problem later. https://github.com/hashicorp/learn-nomad-cluster-setup/blob/main/shared/data-scripts/user-data-client.sh#L16
So this is not the problem with consul, just a rough tutorial. Otherwise everything is good.
Details are here: https://github.com/hashicorp/learn-nomad-cluster-setup/issues/39