From c7c1c35b633ef02e4867b13a410a97f885407803 Mon Sep 17 00:00:00 2001 From: Karan Sharma Date: Sat, 13 Jul 2024 09:55:14 +0530 Subject: [PATCH] feat: load bridge network manually fixes https://github.com/zerodha/nomad-cluster-setup/issues/20 --- .../scripts/setup_client.tftpl.sh | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/modules/nomad-clients/scripts/setup_client.tftpl.sh b/modules/nomad-clients/scripts/setup_client.tftpl.sh index 43bb587..f0cea12 100644 --- a/modules/nomad-clients/scripts/setup_client.tftpl.sh +++ b/modules/nomad-clients/scripts/setup_client.tftpl.sh @@ -94,6 +94,21 @@ modify_nomad_systemd_config() { fi } +# Function to check and load the bridge module +load_bridge() { + if ! lsmod | grep -q "^bridge"; then + log "INFO" "Bridge module not loaded. Attempting to load..." + if ! modprobe bridge; then + log "ERROR" "Failed to load bridge module. This might affect network functionality." + else + log "INFO" "Bridge module loaded successfully." + fi + else + log "INFO" "Bridge module is already loaded." + fi +} + + # Enables nomad systemd service start_nomad() { sudo systemctl daemon-reload @@ -133,7 +148,7 @@ $(for tag in "$${AWS_TAGS[@]}"; do "/lib64" = "/lib64" "/sbin" = "/sbin" "/usr" = "/usr" - + "/etc/ld.so.cache" = "/etc/ld.so.cache" "/etc/ld.so.conf" = "/etc/ld.so.conf" "/etc/ld.so.conf.d" = "/etc/ld.so.conf.d" @@ -219,6 +234,9 @@ set_hostname log "INFO" "Prepare DNS config for exec tasks" prepare_dns_config +log "INFO" "Checking and loading bridge module" +load_bridge + log "INFO" "Rendering client config for nomad" prepare_nomad_client_config