2
2
import host
3
3
from k8sClient import K8sClient
4
4
from concurrent .futures import Future , ThreadPoolExecutor
5
- import jinja2
6
5
import re
7
6
import os
8
7
import requests
@@ -198,56 +197,39 @@ def build_dpu_operator_images() -> str:
198
197
registry = _ensure_local_registry_running (lh , delete_all = True )
199
198
reglocal .local_trust (lh )
200
199
201
- operator_image = f"{ registry } /{ OPERATOR_IMG } "
202
- daemon_image = f"{ registry } /{ DAEMON_IMG } "
203
- render_local_images_yaml (operator_image = operator_image , daemon_image = daemon_image , outfilename = f"{ REPO_DIR } /config/dev/local-images-template.yaml" )
204
-
205
200
lh .run_or_die (f"make -C { REPO_DIR } local-buildx" )
206
201
lh .run_or_die (f"make -C { REPO_DIR } local-pushx" )
207
202
208
203
return registry
209
204
210
205
211
- def start_dpu_operator (h : host .Host , client : K8sClient , operator_image : str , daemon_image : str , repo_wipe : bool = False ) -> None :
206
+ def start_dpu_operator (h : host .Host , client : K8sClient , repo_wipe : bool = False ) -> None :
212
207
logger .info (f"Deploying dpu operator containers on { h .hostname ()} " )
213
208
if repo_wipe :
214
209
h .run (f"rm -rf { REPO_DIR } " )
215
210
h .run_or_die (f"git clone { DPU_OPERATOR_REPO } " )
216
- render_local_images_yaml (operator_image = operator_image , daemon_image = daemon_image , outfilename = "/tmp/dpu-local-images-template.yaml" , pull_policy = "IfNotPresent" )
217
- h .copy_to ("/tmp/dpu-local-images-template.yaml" , f"{ REPO_DIR } /config/dev/local-images-template.yaml" )
218
211
212
+ REGISTRY = host .LocalHost ().hostname ()
219
213
h .run ("dnf install -y pip" )
220
214
h .run_or_die ("pip install yq" )
221
215
ensure_go_installed (h )
222
- reglocal .local_trust (h )
223
- h .run_or_die (f"podman pull { operator_image } " )
224
- h .run_or_die (f"podman pull { daemon_image } " )
225
216
if h .is_localhost ():
226
217
env = os .environ .copy ()
227
218
env ["KUBECONFIG" ] = client ._kc
228
- env ["REGISTRY" ] = host . LocalHost (). hostname ()
219
+ env ["REGISTRY" ] = REGISTRY
229
220
h .run (f"make -C { REPO_DIR } undeploy" , env = env )
230
221
ret = h .run (f"make -C { REPO_DIR } local-deploy" , env = env )
231
222
if not ret .success ():
232
223
logger .error_and_exit ("Failed to deploy dpu operator" )
233
224
else :
234
- h .run (f"cd { REPO_DIR } && export KUBECONFIG={ client ._kc } && make undeploy" )
235
- h .run_or_die (f"cd { REPO_DIR } && export KUBECONFIG={ client ._kc } && make local-deploy" )
225
+ env_cmds = f"export KUBECONFIG={ client ._kc } && export REGISTRY={ REGISTRY } "
226
+ h .run (f"cd { REPO_DIR } && { env_cmds } && make undeploy" )
227
+ h .run_or_die (f"cd { REPO_DIR } && { env_cmds } && make local-deploy" )
236
228
logger .info ("Waiting for all dpu operator pods to become ready" )
237
229
time .sleep (30 )
238
230
client .oc_run_or_die ("wait --for=condition=Ready pod --all -n openshift-dpu-operator --timeout=5m" )
239
231
240
232
241
- def render_local_images_yaml (operator_image : str , daemon_image : str , outfilename : str , pull_policy : str = "Always" ) -> None :
242
- with open ('./manifests/dpu/local-images-template.yaml.j2' ) as f :
243
- j2_template = jinja2 .Template (f .read ())
244
- rendered = j2_template .render (operator_image = operator_image , daemon_image = daemon_image , pull_policy = pull_policy )
245
- logger .info (rendered )
246
-
247
- with open (outfilename , "w" ) as outFile :
248
- outFile .write (rendered )
249
-
250
-
251
233
def ExtraConfigDpu (cc : ClustersConfig , cfg : ExtraConfigArgs , futures : dict [str , Future [Optional [host .Result ]]]) -> None :
252
234
[f .result () for (_ , f ) in futures .items ()]
253
235
logger .info ("Running post config step to start DPU operator on IPU" )
@@ -265,9 +247,6 @@ def ExtraConfigDpu(cc: ClustersConfig, cfg: ExtraConfigArgs, futures: dict[str,
265
247
logger .info ("Will not rebuild dpu-operator images" )
266
248
registry = _ensure_local_registry_running (lh , delete_all = False )
267
249
268
- operator_image = f"{ registry } /{ OPERATOR_IMG } "
269
- daemon_image = f"{ registry } /{ DAEMON_IMG } "
270
-
271
250
# Build and start vsp on DPU
272
251
vendor_plugin = init_vendor_plugin (acc )
273
252
if isinstance (vendor_plugin , IpuPlugin ):
@@ -280,7 +259,7 @@ def ExtraConfigDpu(cc: ClustersConfig, cfg: ExtraConfigArgs, futures: dict[str,
280
259
acc .run_or_die (cmd )
281
260
vendor_plugin .build_and_start (acc , client , registry )
282
261
283
- start_dpu_operator (acc , client , operator_image , daemon_image , repo_wipe = True )
262
+ start_dpu_operator (acc , client , repo_wipe = True )
284
263
285
264
# Disable firewall to ensure host-side can reach dpu
286
265
acc .run ("systemctl stop firewalld" )
@@ -320,8 +299,6 @@ def ExtraConfigDpuHost(cc: ClustersConfig, cfg: ExtraConfigArgs, futures: dict[s
320
299
else :
321
300
logger .info ("Will not rebuild dpu-operator images" )
322
301
registry = _ensure_local_registry_running (lh , delete_all = False )
323
- operator_image = f"{ registry } /{ OPERATOR_IMG } "
324
- daemon_image = f"{ registry } /{ DAEMON_IMG } "
325
302
326
303
# Need to trust the registry in OCP / Microshift
327
304
logger .info ("Ensuring local registry is trusted in OCP" )
@@ -331,7 +308,7 @@ def ExtraConfigDpuHost(cc: ClustersConfig, cfg: ExtraConfigArgs, futures: dict[s
331
308
vendor_plugin = init_vendor_plugin (h )
332
309
vendor_plugin .build_and_start (lh , client , registry )
333
310
334
- start_dpu_operator (lh , client , operator_image , daemon_image )
311
+ start_dpu_operator (lh , client )
335
312
336
313
def helper (h : host .Host , node : NodeConfig ) -> Optional [host .Result ]:
337
314
# Temporary workaround, remove once 4.16 installations are working
0 commit comments