Skip to content

Commit 5e8d648

Browse files
authored
Merge pull request microsoft#62 from xlab-uiuc/remote-arch
Update arch check to use node arch and not local arch
2 parents aa0d4e0 + 317ffd9 commit 5e8d648

2 files changed

Lines changed: 25 additions & 11 deletions

File tree

aiopslab/service/apps/socialnet.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
"""Interface to the social network application from DeathStarBench"""
55

6-
import platform
7-
86
from aiopslab.service.helm import Helm
97
from aiopslab.service.kubectl import KubeCtl
108
from aiopslab.service.apps.base import Application
@@ -22,8 +20,6 @@ def __init__(self):
2220
)
2321
self.create_namespace()
2422
self.create_tls_secret()
25-
# Detect CPU architecture, we need to deploy media-frontend differently on arm
26-
self.is_arm = platform.machine().lower() in ["arm64", "aarch64"]
2723

2824
def load_app_json(self):
2925
super().load_app_json()
@@ -47,15 +43,22 @@ def create_tls_secret(self):
4743
print("TLS secret already exists. Skipping creation.")
4844

4945
def deploy(self):
50-
"""Deploy the Helm configurations."""
51-
if self.is_arm:
52-
# Update image to use arm build image
46+
"""Deploy the Helm configurations with architecture-aware image selection."""
47+
node_architectures = self.kubectl.get_node_architectures()
48+
is_arm = any(arch in ["arm64", "aarch64"] for arch in node_architectures)
49+
50+
if is_arm:
51+
# Use the ARM-compatible image for media-frontend
5352
if "extra_args" not in self.helm_configs:
5453
self.helm_configs["extra_args"] = []
55-
56-
self.helm_configs["extra_args"].append("--set media-frontend.container.image=jacksonarthurclark/media-frontend")
57-
self.helm_configs["extra_args"].append("--set media-frontend.container.imageVersion=latest")
58-
54+
55+
self.helm_configs["extra_args"].append(
56+
"--set media-frontend.container.image=jacksonarthurclark/media-frontend"
57+
)
58+
self.helm_configs["extra_args"].append(
59+
"--set media-frontend.container.imageVersion=latest"
60+
)
61+
5962
Helm.install(**self.helm_configs)
6063
Helm.assert_if_deployed(self.helm_configs["namespace"])
6164

aiopslab/service/kubectl.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,17 @@ def exec_command(self, command: str, input_data=None):
269269
# else:
270270
# return out.stdout.decode("utf-8")
271271

272+
def get_node_architectures(self):
273+
"""Return a set of CPU architectures from all nodes in the cluster."""
274+
architectures = set()
275+
try:
276+
nodes = self.core_v1_api.list_node()
277+
for node in nodes.items:
278+
arch = node.status.node_info.architecture
279+
architectures.add(arch)
280+
except ApiException as e:
281+
print(f"Exception when retrieving node architectures: {e}\n")
282+
return architectures
272283

273284
# Example usage:
274285
if __name__ == "__main__":

0 commit comments

Comments
 (0)