Skip to content

Commit bc46f82

Browse files
committed
Resolve conflicts
1 parent 0a6c9e2 commit bc46f82

File tree

5 files changed

+37
-34
lines changed

5 files changed

+37
-34
lines changed

src/xpk/commands/cluster.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
from ..utils.templates import get_templates_absolute_path
8585
import shutil
8686
import os
87-
from . import managed_ml_diagnostics
87+
from .managed_ml_diagnostics import install_mldiagnostics_prerequisites
8888

8989
CLUSTER_PREHEAT_JINJA_FILE = 'cluster_preheat.yaml.j2'
9090

@@ -424,8 +424,8 @@ def cluster_create(args) -> None:
424424
f' https://console.cloud.google.com/kubernetes/clusters/details/{get_cluster_location(args.project, args.cluster, args.zone)}/{args.cluster}/details?project={args.project}'
425425
)
426426

427-
if args.managed_ml_diagnostics:
428-
return_code = managed_ml_diagnostics.install_mldiagnostics_prerequisites()
427+
if args.managed_mldiagnostics:
428+
return_code = install_mldiagnostics_prerequisites()
429429
if return_code != 0:
430430
xpk_print('Installation of MLDiagnostics failed.')
431431
xpk_exit(return_code)

src/xpk/commands/cluster_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def construct_args(**kwargs: Any) -> Namespace:
124124
cluster_cpu_machine_type='',
125125
create_vertex_tensorboard=False,
126126
enable_autoprovisioning=False,
127-
managed_ml_diagnostics=False,
127+
managed_mldiagnostics=False,
128128
)
129129
args_dict.update(kwargs)
130130
return Namespace(**args_dict)

src/xpk/commands/managed_ml_diagnostics.py

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,16 @@
2424
_KUEUE_NAMESPACE_NAME = 'kueue-system'
2525
_CERT_WEBHOOK_DEPLOYMENT_NAME = 'cert-manager-webhook'
2626
_CERT_WEBHOOK_NAMESPACE_NAME = 'cert-manager'
27+
_WEBHOOK_PACKAGE = 'mldiagnostics-injection-webhook'
28+
_WEBHOOK_VERSION = Version('v0.5.0')
29+
_WEBHOOK_FILENAME = f'{_WEBHOOK_PACKAGE}-v{_WEBHOOK_VERSION}.yaml'
30+
_OPERATOR_PACKAGE = 'mldiagnostics-connection-operator'
31+
_OPERATOR_VERSION = Version('v0.5.0')
32+
_OPERATOR_FILENAME = f'{_OPERATOR_PACKAGE}-v{_OPERATOR_VERSION}.yaml'
33+
_CERT_MANAGER_VERSION = Version('v1.13.0')
2734

2835

29-
def _install_cert_manager(version: Version = Version('v1.13.0')) -> int:
36+
def _install_cert_manager(version: Version = _CERT_MANAGER_VERSION) -> int:
3037
"""
3138
Apply the cert-manager manifest.
3239
@@ -111,13 +118,11 @@ def _install_mldiagnostics_yaml(artifact_filename: str) -> int:
111118

112119
command = f'kubectl apply -f {full_artifact_path} -n gke-mldiagnostics'
113120

114-
return_code = run_command_with_updates(
121+
return run_command_with_updates(
115122
command,
116123
f'Install {full_artifact_path}...',
117124
)
118125

119-
return return_code
120-
121126

122127
def _label_default_namespace_mldiagnostics() -> int:
123128
"""
@@ -129,13 +134,11 @@ def _label_default_namespace_mldiagnostics() -> int:
129134

130135
command = 'kubectl label namespace default managed-mldiagnostics-gke=true'
131136

132-
return_code = run_command_with_updates(
137+
return run_command_with_updates(
133138
command,
134139
'Label default namespace with managed-mldiagnostics-gke=true',
135140
)
136141

137-
return return_code
138-
139142

140143
def install_mldiagnostics_prerequisites() -> int:
141144
"""
@@ -166,12 +169,8 @@ def install_mldiagnostics_prerequisites() -> int:
166169
xpk_print('The cert-manager-webhook installation failed.')
167170
return 1
168171

169-
webhook_package = 'mldiagnostics-injection-webhook'
170-
webhook_version = Version('v0.5.0')
171-
webhook_filename = f'{webhook_package}-v{webhook_version}.yaml'
172-
173172
return_code = _download_mldiagnostics_yaml(
174-
package_name=webhook_package, version=webhook_version
173+
package_name=_WEBHOOK_PACKAGE, version=_WEBHOOK_VERSION
175174
)
176175
if return_code != 0:
177176
return return_code
@@ -180,25 +179,23 @@ def install_mldiagnostics_prerequisites() -> int:
180179
if return_code != 0:
181180
return return_code
182181

183-
return_code = _install_mldiagnostics_yaml(artifact_filename=webhook_filename)
182+
return_code = _install_mldiagnostics_yaml(artifact_filename=_WEBHOOK_FILENAME)
184183
if return_code != 0:
185184
return return_code
186185

187186
return_code = _label_default_namespace_mldiagnostics()
188187
if return_code != 0:
189188
return return_code
190189

191-
operator_package = 'mldiagnostics-connection-operator'
192-
operator_version = Version('v0.5.0')
193-
operator_filename = f'{operator_package}-v{operator_version}.yaml'
194-
195190
return_code = _download_mldiagnostics_yaml(
196-
package_name=operator_package, version=operator_version
191+
package_name=_OPERATOR_PACKAGE, version=_OPERATOR_VERSION
197192
)
198193
if return_code != 0:
199194
return return_code
200195

201-
return_code = _install_mldiagnostics_yaml(artifact_filename=operator_filename)
196+
return_code = _install_mldiagnostics_yaml(
197+
artifact_filename=_OPERATOR_FILENAME
198+
)
202199
if return_code != 0:
203200
return return_code
204201

src/xpk/commands/managed_ml_diagnostics_test.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,64 +51,64 @@ def mocks(mocker) -> _Mocks:
5151
commands_tester=CommandsTester(
5252
mocker,
5353
run_command_with_updates_path=(
54-
'xpk.commands.managed_ml_diagnostics.run_command_with_updates'
54+
'xpk.commands.cluster.run_command_with_updates'
5555
),
5656
run_command_for_value_path=(
57-
'xpk.commands.managed_ml_diagnostics.run_command_for_value'
57+
'xpk.commands.cluster.run_command_for_value'
5858
),
5959
),
6060
)
6161

6262

63-
def construct_args(**kwargs: Any) -> Namespace:
64-
args_dict = dict(
65-
managed_mldiagnostics=False,
66-
)
67-
args_dict.update(kwargs)
68-
return Namespace(**args_dict)
69-
70-
7163
def test_install_mldiagnostics_prerequisites_commands_executed(
7264
mocks: _Mocks,
7365
mocker,
7466
):
75-
7667
mocks.commands_tester.set_result_for_command(
68+
(0, ''),
7769
'kubectl',
7870
'rollout',
7971
'status',
8072
'deployment/kueue-controller-manager',
73+
'-n',
74+
'kueue-system',
75+
'--timeout=300s',
8176
)
8277

8378
mocks.commands_tester.set_result_for_command(
79+
(0, ''),
8480
'kubectl',
8581
'rollout',
8682
'status',
8783
'deployment/cert-manager-webhook',
8884
)
8985

9086
mocks.commands_tester.set_result_for_command(
87+
(0, ''),
9188
'kubectl',
9289
'apply',
9390
'-f',
9491
'https://github.com/cert-manager/cert-manager/releases/',
9592
)
9693

9794
mocks.commands_tester.set_result_for_command(
95+
(0, ''),
9896
'gcloud',
9997
'artifacts',
10098
'generic',
10199
'download',
102100
)
103101

104102
mocks.commands_tester.set_result_for_command(
103+
(0, ''),
105104
'kubectl',
106105
'create',
107106
'namespace',
108107
'gke-mldiagnostics',
109108
)
110109

111110
mocks.commands_tester.set_result_for_command(
111+
(0, ''),
112112
'kubectl',
113113
'apply',
114114
'-f',
@@ -117,6 +117,7 @@ def test_install_mldiagnostics_prerequisites_commands_executed(
117117
)
118118

119119
mocks.commands_tester.set_result_for_command(
120+
(0, ''),
120121
'kubectl',
121122
'label',
122123
'namespace',

src/xpk/parser/cluster.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,11 @@ def add_shared_cluster_create_optional_arguments(
692692
' regional clusters, all zones must support the machine type.'
693693
),
694694
)
695+
parser_or_group.add_argument(
696+
'--managed-mldiagnostics',
697+
action='store_true',
698+
help='Enables the installation of required ML Diagnostics components.',
699+
)
695700
parser_or_group.add_argument(
696701
'--cluster-cpu-machine-type',
697702
type=str,

0 commit comments

Comments
 (0)