This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch v2-8-test
in repository https://gitbox.apache.org/repos/asf/airflow.git

commit 48d79b933f7ca5041a4c84d51a86f2381fb16240
Author: Jarek Potiuk <ja...@potiuk.com>
AuthorDate: Tue Feb 13 02:14:18 2024 +0100

    Fallback to locally installed k9s on ARM architecture (#37371)
    
    * Fallback to locally installed k8s on ARM architecture
    
    The docker image for k9s available from creator does not support ARM
    architecture so we used to use emulated version. Hoever recently for
    some reason when kind cluster is running, rosetta is disabled and
    the AMD images cannot be run. Therefore on MacOS / ARM we fallback
    to k9s locally installed (for example with brew).
    
    * Update dev/breeze/src/airflow_breeze/commands/kubernetes_commands.py
    
    Co-authored-by: Andrey Anshin <andrey.ans...@taragol.is>
    
    ---------
    
    Co-authored-by: Andrey Anshin <andrey.ans...@taragol.is>
    (cherry picked from commit 6754e9d83b89e9701c1b96bdc807a14e8c826d72)
---
 .../airflow_breeze/commands/kubernetes_commands.py | 72 ++++++++++++++--------
 1 file changed, 48 insertions(+), 24 deletions(-)

diff --git a/dev/breeze/src/airflow_breeze/commands/kubernetes_commands.py 
b/dev/breeze/src/airflow_breeze/commands/kubernetes_commands.py
index ad199bb04b..5ca010c8ac 100644
--- a/dev/breeze/src/airflow_breeze/commands/kubernetes_commands.py
+++ b/dev/breeze/src/airflow_breeze/commands/kubernetes_commands.py
@@ -46,6 +46,7 @@ from airflow_breeze.utils.ci_group import ci_group
 from airflow_breeze.utils.click_utils import BreezeGroup
 from airflow_breeze.utils.console import Output, get_console
 from airflow_breeze.utils.custom_param_types import CacheableChoice, 
CacheableDefault
+from airflow_breeze.utils.host_info_utils import Architecture, 
get_host_architecture
 from airflow_breeze.utils.kubernetes_utils import (
     CHART_PATH,
     K8S_CLUSTERS_PATH,
@@ -1223,30 +1224,53 @@ def k9s(python: str, kubernetes_version: str, k9s_args: 
tuple[str, ...]):
     if not k9s_editor:
         env["K9S_EDITOR"] = env["EDITOR"]
     kubeconfig_file = get_kubeconfig_file(python=python, 
kubernetes_version=kubernetes_version)
-    result = run_command(
-        [
-            "docker",
-            "run",
-            "--rm",
-            "-it",
-            "--network",
-            "host",
-            "-e",
-            "EDITOR",
-            "-e",
-            "K9S_EDITOR",
-            "-v",
-            f"{kubeconfig_file}:/root/.kube/config",
-            "quay.io/derailed/k9s",
-            "--namespace",
-            HELM_AIRFLOW_NAMESPACE,
-            *k9s_args,
-        ],
-        env=env,
-        check=False,
-    )
-    if result.returncode != 0:
-        sys.exit(result.returncode)
+    # Until https://github.com/kubernetes-sigs/kind/pull/3511 is merged and 
released, running AMD images
+    # on ARM is broken with kind cluster running, so we need to run k9s 
directly on the host
+    arch, _ = get_host_architecture()
+    if arch != Architecture.ARM:
+        result = run_command(
+            [
+                "docker",
+                "run",
+                "--rm",
+                "-it",
+                "--network",
+                "host",
+                "-e",
+                "EDITOR",
+                "-e",
+                "K9S_EDITOR",
+                "-v",
+                f"{kubeconfig_file}:/root/.kube/config",
+                "derailed/k9s",
+                "--namespace",
+                HELM_AIRFLOW_NAMESPACE,
+                *k9s_args,
+            ],
+            env=env,
+            check=False,
+        )
+        if result.returncode != 0:
+            sys.exit(result.returncode)
+    else:
+        if shutil.which("k9s") is None:
+            get_console().print(
+                "[error]k9s is not installed. Please install it first "
+                "(for example with `brew install k9s`)."
+            )
+            sys.exit(1)
+        result = run_command(
+            [
+                "k9s",
+                "--namespace",
+                HELM_AIRFLOW_NAMESPACE,
+                *k9s_args,
+            ],
+            env=env,
+            check=False,
+        )
+        if result.returncode != 0:
+            sys.exit(result.returncode)
 
 
 def _logs(python: str, kubernetes_version: str):

Reply via email to