Skip to content

Commit 2c18242

Browse files
authored
set cluster name via constructor to work around #dask/distributed/6485 (#523)
* set cluster name via constructor Fixes #516 * avoid capturing subprocess output when it's unused pytest should capture the output with capfd so we can see the log when interrupted by pytest-timeout
1 parent 0ccba32 commit 2c18242

File tree

4 files changed

+19
-14
lines changed

4 files changed

+19
-14
lines changed

dask_kubernetes/conftest.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def kopf_runner(k8s_cluster):
2424
@pytest.fixture(scope="session")
2525
def docker_image():
2626
image_name = "dask-kubernetes:dev"
27-
subprocess.check_output(["docker", "build", "-t", image_name, "./ci/"])
27+
subprocess.run(["docker", "build", "-t", image_name, "./ci/"], check=True)
2828
return image_name
2929

3030

@@ -40,7 +40,9 @@ def k8s_cluster(kind_cluster, docker_image):
4040
def install_istio(k8s_cluster):
4141
if bool(os.environ.get("TEST_ISTIO", False)):
4242
check_dependency("istioctl")
43-
subprocess.check_output(["istioctl", "install", "--set", "profile=demo", "-y"])
43+
subprocess.run(
44+
["istioctl", "install", "--set", "profile=demo", "-y"], check=True
45+
)
4446
k8s_cluster.kubectl(
4547
"label", "namespace", "default", "istio-injection=enabled", "--overwrite"
4648
)

dask_kubernetes/experimental/kubecluster.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ def __init__(
133133
shutdown_on_close=None,
134134
**kwargs,
135135
):
136-
self.name = name
137136
self.namespace = namespace or namespace_default()
138137
self.image = image
139138
self.n_workers = n_workers
@@ -146,7 +145,7 @@ def __init__(
146145

147146
self._instances.add(self)
148147

149-
super().__init__(**kwargs)
148+
super().__init__(name=name, **kwargs)
150149
if not self.asynchronous:
151150
self._loop_runner.start()
152151
self.sync(self._start)

dask_kubernetes/helm/helmcluster.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,13 @@ def __init__(
8989
worker_name="worker",
9090
node_host=None,
9191
node_port=None,
92+
name=None,
9293
**kwargs,
9394
):
9495
self.release_name = release_name
9596
self.namespace = namespace or namespace_default()
96-
self.name = self.release_name + "." + self.namespace
97+
if name is None:
98+
name = self.release_name + "." + self.namespace
9799
check_dependency("helm")
98100
check_dependency("kubectl")
99101
status = subprocess.run(
@@ -113,7 +115,7 @@ def __init__(
113115
self.node_host = node_host
114116
self.node_port = node_port
115117

116-
super().__init__(**kwargs)
118+
super().__init__(name=name, **kwargs)
117119
if not self.asynchronous:
118120
self._loop_runner.start()
119121
self.sync(self._start)

dask_kubernetes/helm/tests/test_helm.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
@pytest.fixture(scope="session")
2222
def chart_repo():
2323
repo_name = "dask"
24-
subprocess.check_output(
25-
["helm", "repo", "add", repo_name, "https://helm.dask.org/"]
24+
subprocess.run(
25+
["helm", "repo", "add", repo_name, "https://helm.dask.org/"], check=True
2626
)
27-
subprocess.check_output(["helm", "repo", "update"])
27+
subprocess.run(["helm", "repo", "update"], check=True)
2828
return repo_name
2929

3030

@@ -51,7 +51,7 @@ def test_namespace():
5151

5252
@pytest.fixture(scope="session") # Creating this fixture is slow so we should reuse it.
5353
def release(k8s_cluster, chart_name, test_namespace, release_name, config_path):
54-
subprocess.check_output(
54+
subprocess.run(
5555
[
5656
"helm",
5757
"install",
@@ -63,10 +63,11 @@ def release(k8s_cluster, chart_name, test_namespace, release_name, config_path):
6363
"--wait",
6464
"-f",
6565
config_path,
66-
]
66+
],
67+
check=True,
6768
)
6869
# Scale back the additional workers group for now
69-
subprocess.check_output(
70+
subprocess.run(
7071
[
7172
"kubectl",
7273
"scale",
@@ -75,10 +76,11 @@ def release(k8s_cluster, chart_name, test_namespace, release_name, config_path):
7576
"deployment",
7677
f"{release_name}-dask-worker-foo",
7778
"--replicas=0",
78-
]
79+
],
80+
check=True,
7981
)
8082
yield release_name
81-
subprocess.check_output(["helm", "delete", "-n", test_namespace, release_name])
83+
subprocess.run(["helm", "delete", "-n", test_namespace, release_name], check=True)
8284

8385

8486
@pytest_asyncio.fixture

0 commit comments

Comments
 (0)