Skip to content

Nomad Cluster Leader not Created

Nomad Cluster Leader not Created in Nomad Issues.

4 min read Updated SS RS

Nomad Cluster Leader not Created#

Case 1: Unused containers#

This issue occurs when unused containers in the system interfere with the network configuration. Follow the steps below to rectify it.

1. Clear the unused containers from Podman:

podman system prune -a

Expected output (the CNI teardown error is shown, but the containers/images are still deleted):

WARNING! This command removes:
        - all stopped containers
        - all networks not used by at least one container
        - all images without at least one container associated with them
        - all build cache
Are you sure you want to continue? [y/N] y
ERRO[0003] Unable to clean up network for container 8ae2b2e5...: "error tearing
    down network namespace configuration ... plugin type=\"bridge\" failed (delete):
    cni plugin bridge failed: running [/sbin/iptables -t nat -D POSTROUTING
    -s 192.0.2.115 -j CNI-d8a7b0bc040f714a0b744da3 ...]: exit status 2:
    iptables v1.8.4 (nf_tables): Chain 'CNI-d8a7b0bc040f714a0b744da3' does not exist"
Deleted Containers
8ae2b2e56afda321c8f4449ae8cdcddeca5a15c68cac5b27411a73b78c84eee2
Deleted Images
...
Total reclaimed space: 1.232GB

2. The containers are removed, but confirm none remain at the network level:

podman ps -a

Expected output (no containers listed):

CONTAINER ID  IMAGE  COMMAND  CREATED  STATUS  PORTS  NAMES

3. Check the processes using the relevant ports.

Port 2809:

netstat -anp | grep 2809

Expected output:

unix  3  [ ]  STREAM  CONNECTED  28090761  1265/dbus-daemon  /run/dbus/system_bus_socket

Port 2908:

netstat -anp | grep 2908

Expected output:

tcp  0  0  192.0.2.72:2908  0.0.0.0:*  LISTEN  2311559/conmon
udp  0  0  192.0.2.72:2908  0.0.0.0:*          2311559/conmon

4. The container is still present at the network level. The fix is to manually kill the process using port 2908 on each node:

kill -9 <pid>

Case 2: Firewalld Service Issue#

Another possible cause is an unstable firewalld service that reports errors related to unknown sources. The fix is to restart firewalld on each node.

1. Check the status of the firewalld service:

systemctl status firewalld

2. Restart the firewalld service:

systemctl restart firewalld

Resolving Nomad Certificate Expiry#

1. Back up the folder: take a backup of the /etc/nomad.d/ folder on all HEAL servers.

2. Primary HEAL server adjustments:

a. Navigate to the Certificate utilities directory:

/<Install-Dir>/Appsone_Service/utilities/Certificate/

b. Update the expiry key value to 43800h in the ca-config.json file located at:

/<Install-Dir>/Appsone_Service/utilities/Certificate/conf/

3. Execute the following commands sequentially.

a. Create a new Certificate Authority (CA) certificate:

./CreateCertificate.sh -c

b. Create a signed certificate from the newly generated CA certificate:

./CreateCertificate.sh nomad

c. Copy the Nomad CA certificates (nomad-ca*) from the ca_cert directory to /etc/nomad.d/:

cp ca_cert/nomad-ca* /etc/nomad.d/

d. Copy all Nomad certificates (from the nomad_cert directory) to /etc/nomad.d/:

cp nomad_cert/* /etc/nomad.d/

e. Change to the /etc/nomad.d/ directory:

cd /etc/nomad.d/

f. Remove all Certificate Signing Request (CSR) files in the directory:

rm *.csr

g. Make all files in the directory executable:

chmod +x *

h. Change ownership of all files to the nomad user and group:

chown -R nomad:nomad *

4. Distribute certificates to other servers: copy the newly generated certificate files to the /etc/nomad.d/ folder on all other HEAL instances.

5. Verify configuration files: ensure the nomad.hcl file is unique for each server and was not overwritten during this process.

6. Restart the Nomad service: run systemctl restart nomad on all HEAL servers.

7. Restart HEAL services (if required): restart HEAL services on the respective servers.

Nomad Issue: Unexpected Response Code 500 (No Cluster Leader)#

The Nomad service returns a 500 response code with the message “No cluster leader”. This is observed when querying jobs in Nomad, as shown by the error message.

Solution:

1. Service and directory management:

  • a. Identify whether a cloned Nomad service is running, which may have contributed to the issue.
  • b. Stop the cloned Nomad service to prevent conflicts.
  • c. Remove the old Nomad directories that may contain outdated configuration or data causing the error.

2. Service restart: restart the Nomad service after cleaning up the directories and stopping the cloned service. This resets the Nomad environment so it operates with the correct configuration.

3. Issue classification and root cause:

  • a. Classify the issue as an environmental problem, also related to configuration management.
  • b. The root cause was a server crash, after which a snapshot was taken and attached to a different IP. The services were not stopped appropriately during this process, so the Nomad node displayed a cloned status for the server.
  • c. This mismanagement during the crash and snapshot restoration led to the cluster-leadership issue.

4. These steps resolved the cluster-leadership problem, allowing the service to query jobs successfully. The ticket was closed as an environmental issue with configuration implications, underscoring the importance of proper service management during server crashes and snapshot restorations.

Cluster status verification: uptime, date, nomad server members, nomad node status and consul members showing nodes alive/ready