Skip to content

Commit 3419138

Browse files
fix: Fixing namespaces (#125)
This fixes FIREWHEEL working in a cluster. There are a few places where the minimega namespace was hard-coded. I cannot figure out why this change is necessary now, but everything seemed to work in the past. Doesn't seem like the minimega API changed at all. Not sure it's necessarily important, but would love to know if anybody has comments. TODO: - [x] Check if minimega API version matters and fix dependency accordingly --------- Signed-off-by: gregjacobus <[email protected]> Co-authored-by: Mitch Negus <[email protected]>
1 parent 6b04ecd commit 3419138

File tree

4 files changed

+22
-4
lines changed

4 files changed

+22
-4
lines changed

src/firewheel/cli/helpers/start

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ MM_INSTALL_DIR="$("$FIREWHEEL_PYTHON" "$FIREWHEEL" config get minimega.install_d
3939
MM_BASE_DIR="$("$FIREWHEEL_PYTHON" "$FIREWHEEL" config get minimega.base_dir)"
4040
MINIMEGA_BIN="$MM_INSTALL_DIR/bin/minimega -base=$MM_BASE_DIR"
4141
$MINIMEGA_BIN -e clear all
42-
$MINIMEGA_BIN -e namespace firewheel
42+
$MINIMEGA_BIN -e namespace "$("$FIREWHEEL_PYTHON" "$FIREWHEEL" config get minimega.namespace)"
4343
$MINIMEGA_BIN -e ns add-hosts localhost
4444
$MINIMEGA_BIN -e ns queueing true
4545

@@ -66,6 +66,22 @@ fi
6666

6767
DONE
6868

69+
70+
RUN Shell ON compute
71+
MM_INSTALL_DIR="$("$FIREWHEEL_PYTHON" "$FIREWHEEL" config get minimega.install_dir)"
72+
MM_BASE_DIR="$("$FIREWHEEL_PYTHON" "$FIREWHEEL" config get minimega.base_dir)"
73+
MINIMEGA_BIN="$MM_INSTALL_DIR/bin/minimega -base=$MM_BASE_DIR"
74+
75+
# Ensure the specified namespace is created and that localhost is added
76+
namespace="$("$FIREWHEEL_PYTHON" "$FIREWHEEL" config get minimega.namespace)"
77+
if [ $($MINIMEGA_BIN -e .filter namespace="$namespace" .filter active=true .headers false namespace | wc -l) -eq 0 ]; then
78+
# We were not in the specified namespace yet
79+
$MINIMEGA_BIN -e namespace "$namespace"
80+
fi
81+
$MINIMEGA_BIN -e ns add-hosts localhost
82+
DONE
83+
84+
6985
RUN Python ON control
7086
#!/usr/bin/env python
7187
import sys

src/firewheel/cli/helpers/stop/hard

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ sudo systemctl restart minimega
161161
MM_INSTALL_DIR="$("$FIREWHEEL_PYTHON" "$FIREWHEEL" config get minimega.install_dir)"
162162
MM_BASE_DIR="$("$FIREWHEEL_PYTHON" "$FIREWHEEL" config get minimega.base_dir)"
163163
MINIMEGA_BIN="$MM_INSTALL_DIR/bin/minimega -base=$MM_BASE_DIR"
164-
$MINIMEGA_BIN -e clear namespace firewheel
164+
$MINIMEGA_BIN -e clear namespace "$("$FIREWHEEL_PYTHON" "$FIREWHEEL" config get minimega.namespace)"
165165
DONE
166166

167167
RUN Helpers ON control

src/firewheel/cli/helpers/stop/index

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ RUN Shell ON control
3333
MM_INSTALL_DIR="$("$FIREWHEEL_PYTHON" "$FIREWHEEL" config get minimega.install_dir)"
3434
MM_BASE_DIR="$("$FIREWHEEL_PYTHON" "$FIREWHEEL" config get minimega.base_dir)"
3535
MINIMEGA_BIN="$MM_INSTALL_DIR/bin/minimega -base=$MM_BASE_DIR"
36-
$MINIMEGA_BIN -e clear namespace firewheel
36+
$MINIMEGA_BIN -e clear namespace "$("$FIREWHEEL_PYTHON" "$FIREWHEEL" config get minimega.namespace)"
3737
DONE
3838

3939
RUN Helpers ON compute

src/firewheel/lib/minimega/api.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,13 @@ def __init__(self, mm_base=None, timeout=120, skip_retry=False):
4949
self.mm_base = mm_base
5050
self.mm_socket = os.path.join(self.mm_base, "minimega")
5151

52+
if (namespace := config["minimega"].get("namespace")) is None:
53+
self.log.warning("minimega namespace not set, using default")
5254
if not os.path.exists(self.mm_socket):
5355
self.log.error("minimega socket does not exist at: %s", self.mm_socket)
5456
raise RuntimeError(f"minimega socket does not exist at: {self.mm_socket}")
5557
try:
56-
self.mm = minimega.minimega(self.mm_socket, True, False, None)
58+
self.mm = minimega.minimega(self.mm_socket, True, False, namespace)
5759
except Exception as exp:
5860
self.log.error("minimega connection failed.")
5961
self.log.exception(exp)

0 commit comments

Comments
 (0)