Skip to content

Commit 2504039

Browse files
committed
Remove render_local_images_yaml
This commit removes rendering a file to specify the image / pull policy as this is now handled in the dpu operator developer tools - Rely on dpu operator Makefile to specify hardcoded image names - No longer rely on manually pulling images to the IPU, instead use pull-policy always Signed-off-by: Salvatore Daniele <[email protected]>
1 parent dbf3709 commit 2504039

File tree

2 files changed

+8
-59
lines changed

2 files changed

+8
-59
lines changed

extraConfigDpu.py

Lines changed: 8 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import host
33
from k8sClient import K8sClient
44
from concurrent.futures import Future, ThreadPoolExecutor
5-
import jinja2
65
import re
76
import os
87
import requests
@@ -18,8 +17,6 @@
1817
MICROSHIFT_KUBECONFIG = "/var/lib/microshift/resources/kubeadmin/kubeconfig"
1918
OSE_DOCKERFILE = "https://pkgs.devel.redhat.com/cgit/containers/dpu-operator/tree/Dockerfile?h=rhaos-4.17-rhel-9"
2019
REPO_DIR = "/root/dpu-operator"
21-
DAEMON_IMG = "dpu-daemon:dev"
22-
OPERATOR_IMG = "dpu-operator:dev"
2320

2421
KERNEL_RPMS = [
2522
"https://download-01.beak-001.prod.iad2.dc.redhat.com/brewroot/vol/rhel-9/packages/kernel/5.14.0/427.2.1.el9_4/x86_64/kernel-5.14.0-427.2.1.el9_4.x86_64.rpm",
@@ -198,56 +195,39 @@ def build_dpu_operator_images() -> str:
198195
registry = _ensure_local_registry_running(lh, delete_all=True)
199196
reglocal.local_trust(lh)
200197

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-
205198
lh.run_or_die(f"make -C {REPO_DIR} local-buildx")
206199
lh.run_or_die(f"make -C {REPO_DIR} local-pushx")
207200

208201
return registry
209202

210203

211-
def start_dpu_operator(h: host.Host, client: K8sClient, operator_image: str, daemon_image: str, repo_wipe: bool = False) -> None:
204+
def start_dpu_operator(h: host.Host, client: K8sClient, repo_wipe: bool = False) -> None:
212205
logger.info(f"Deploying dpu operator containers on {h.hostname()}")
213206
if repo_wipe:
214207
h.run(f"rm -rf {REPO_DIR}")
215208
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")
218209

210+
REGISTRY = host.LocalHost().hostname()
219211
h.run("dnf install -y pip")
220212
h.run_or_die("pip install yq")
221213
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}")
225214
if h.is_localhost():
226215
env = os.environ.copy()
227216
env["KUBECONFIG"] = client._kc
228-
env["REGISTRY"] = host.LocalHost().hostname()
217+
env["REGISTRY"] = REGISTRY
229218
h.run(f"make -C {REPO_DIR} undeploy", env=env)
230219
ret = h.run(f"make -C {REPO_DIR} local-deploy", env=env)
231220
if not ret.success():
232221
logger.error_and_exit("Failed to deploy dpu operator")
233222
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")
223+
env_cmds = f"export KUBECONFIG={client._kc} && export REGISTRY={REGISTRY}"
224+
h.run(f"cd {REPO_DIR} && {env_cmds} && make undeploy")
225+
h.run_or_die(f"cd {REPO_DIR} && {env_cmds} && make local-deploy")
236226
logger.info("Waiting for all dpu operator pods to become ready")
237227
time.sleep(30)
238228
client.oc_run_or_die("wait --for=condition=Ready pod --all -n openshift-dpu-operator --timeout=5m")
239229

240230

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-
251231
def ExtraConfigDpu(cc: ClustersConfig, cfg: ExtraConfigArgs, futures: dict[str, Future[Optional[host.Result]]]) -> None:
252232
[f.result() for (_, f) in futures.items()]
253233
logger.info("Running post config step to start DPU operator on IPU")
@@ -265,9 +245,6 @@ def ExtraConfigDpu(cc: ClustersConfig, cfg: ExtraConfigArgs, futures: dict[str,
265245
logger.info("Will not rebuild dpu-operator images")
266246
registry = _ensure_local_registry_running(lh, delete_all=False)
267247

268-
operator_image = f"{registry}/{OPERATOR_IMG}"
269-
daemon_image = f"{registry}/{DAEMON_IMG}"
270-
271248
# Build and start vsp on DPU
272249
vendor_plugin = init_vendor_plugin(acc)
273250
if isinstance(vendor_plugin, IpuPlugin):
@@ -280,7 +257,7 @@ def ExtraConfigDpu(cc: ClustersConfig, cfg: ExtraConfigArgs, futures: dict[str,
280257
acc.run_or_die(cmd)
281258
vendor_plugin.build_and_start(acc, client, registry)
282259

283-
start_dpu_operator(acc, client, operator_image, daemon_image, repo_wipe=True)
260+
start_dpu_operator(acc, client, repo_wipe=True)
284261

285262
# Disable firewall to ensure host-side can reach dpu
286263
acc.run("systemctl stop firewalld")
@@ -320,8 +297,6 @@ def ExtraConfigDpuHost(cc: ClustersConfig, cfg: ExtraConfigArgs, futures: dict[s
320297
else:
321298
logger.info("Will not rebuild dpu-operator images")
322299
registry = _ensure_local_registry_running(lh, delete_all=False)
323-
operator_image = f"{registry}/{OPERATOR_IMG}"
324-
daemon_image = f"{registry}/{DAEMON_IMG}"
325300

326301
# Need to trust the registry in OCP / Microshift
327302
logger.info("Ensuring local registry is trusted in OCP")
@@ -331,7 +306,7 @@ def ExtraConfigDpuHost(cc: ClustersConfig, cfg: ExtraConfigArgs, futures: dict[s
331306
vendor_plugin = init_vendor_plugin(h)
332307
vendor_plugin.build_and_start(lh, client, registry)
333308

334-
start_dpu_operator(lh, client, operator_image, daemon_image)
309+
start_dpu_operator(lh, client)
335310

336311
def helper(h: host.Host, node: NodeConfig) -> Optional[host.Result]:
337312
# Temporary workaround, remove once 4.16 installations are working

manifests/dpu/local-images-template.yaml.j2

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)