Skip to content

Commit eb31d75

Browse files
committed
Make dpu operator repo / branch configurable
Allow users to specify the repo/branch they want to build and deploy from in the CDA config file. i.e. - name: "dpu_operator_dpu" dpu_operator_repo: "https://github.com/SalDaniele/cluster-deployment-automation.git" dpu_operator_branch: "my_branch" Signed-off-by: Salvatore Daniele <[email protected]>
1 parent e123e8e commit eb31d75

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

clustersConfig.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ class ExtraConfigArgs:
5757
rebuild_dpu_operators_images: bool = True
5858

5959
dpu_net_interface: Optional[str] = "ens2f0"
60+
dpu_operator_repo: str = "https://github.com/openshift/dpu-operator.git"
61+
dpu_operator_branch: str = "main"
6062

6163
def pre_check(self) -> None:
6264
if self.sriov_network_operator_local:

extraConfigDpu.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,10 @@ def copy_local_registry_certs(host: host.Host, path: str) -> None:
185185
host.copy_to(f"{directory}/{file}", f"{path}/{file}")
186186

187187

188-
def build_dpu_operator_images() -> str:
188+
def build_dpu_operator_images(repo: str, branch: str) -> str:
189189
logger.info("Building dpu operator images")
190190
lh = host.LocalHost()
191-
git_repo_setup(REPO_DIR, repo_wipe=True, url=DPU_OPERATOR_REPO, branch="main")
191+
git_repo_setup(REPO_DIR, repo_wipe=True, url=repo, branch=branch)
192192
update_dockerfiles_with_ose_images(REPO_DIR)
193193

194194
# Start a local registry to store dpu-operator images
@@ -201,26 +201,24 @@ def build_dpu_operator_images() -> str:
201201
return registry
202202

203203

204-
def start_dpu_operator(h: host.Host, client: K8sClient, repo_wipe: bool = False) -> None:
204+
def start_dpu_operator(h: host.Host, client: K8sClient, repo_wipe: bool = False, repo: str = DPU_OPERATOR_REPO, branch: str = "main") -> None:
205205
logger.info(f"Deploying dpu operator containers on {h.hostname()}")
206206
if repo_wipe:
207207
h.run(f"rm -rf {REPO_DIR}")
208-
h.run_or_die(f"git clone {DPU_OPERATOR_REPO}")
208+
h.run_or_die(f"git clone --branch {branch} {repo} {REPO_DIR}")
209209

210-
REGISTRY = host.LocalHost().hostname()
211210
h.run("dnf install -y pip")
212211
h.run_or_die("pip install yq")
213212
ensure_go_installed(h)
214213
if h.is_localhost():
215214
env = os.environ.copy()
216215
env["KUBECONFIG"] = client._kc
217-
env["REGISTRY"] = REGISTRY
218216
h.run(f"make -C {REPO_DIR} undeploy", env=env)
219217
ret = h.run(f"make -C {REPO_DIR} local-deploy", env=env)
220218
if not ret.success():
221219
logger.error_and_exit("Failed to deploy dpu operator")
222220
else:
223-
env_cmds = f"export KUBECONFIG={client._kc} && export REGISTRY={REGISTRY}"
221+
env_cmds = f"export KUBECONFIG={client._kc} && export REGISTRY={host.LocalHost().hostname()}"
224222
h.run(f"cd {REPO_DIR} && {env_cmds} && make undeploy")
225223
h.run_or_die(f"cd {REPO_DIR} && {env_cmds} && make local-deploy")
226224
logger.info("Waiting for all dpu operator pods to become ready")
@@ -240,7 +238,7 @@ def ExtraConfigDpu(cc: ClustersConfig, cfg: ExtraConfigArgs, futures: dict[str,
240238
client = K8sClient(MICROSHIFT_KUBECONFIG, acc)
241239

242240
if cfg.rebuild_dpu_operators_images:
243-
registry = build_dpu_operator_images()
241+
registry = build_dpu_operator_images(repo=cfg.dpu_operator_repo, branch=cfg.dpu_operator_branch)
244242
else:
245243
logger.info("Will not rebuild dpu-operator images")
246244
registry = _ensure_local_registry_running(lh, delete_all=False)
@@ -257,7 +255,7 @@ def ExtraConfigDpu(cc: ClustersConfig, cfg: ExtraConfigArgs, futures: dict[str,
257255
acc.run_or_die(cmd)
258256
vendor_plugin.build_and_start(acc, client, registry)
259257

260-
start_dpu_operator(acc, client, repo_wipe=True)
258+
start_dpu_operator(acc, client, repo_wipe=True, repo=cfg.dpu_operator_repo, branch=cfg.dpu_operator_branch)
261259

262260
# Disable firewall to ensure host-side can reach dpu
263261
acc.run("systemctl stop firewalld")
@@ -293,7 +291,7 @@ def ExtraConfigDpuHost(cc: ClustersConfig, cfg: ExtraConfigArgs, futures: dict[s
293291
client = K8sClient(cc.kubeconfig)
294292

295293
if cfg.rebuild_dpu_operators_images:
296-
registry = build_dpu_operator_images()
294+
registry = build_dpu_operator_images(repo=cfg.dpu_operator_repo, branch=cfg.dpu_operator_branch)
297295
else:
298296
logger.info("Will not rebuild dpu-operator images")
299297
registry = _ensure_local_registry_running(lh, delete_all=False)
@@ -306,7 +304,7 @@ def ExtraConfigDpuHost(cc: ClustersConfig, cfg: ExtraConfigArgs, futures: dict[s
306304
vendor_plugin = init_vendor_plugin(h)
307305
vendor_plugin.build_and_start(lh, client, registry)
308306

309-
start_dpu_operator(lh, client)
307+
start_dpu_operator(lh, client, repo_wipe=False, repo=cfg.dpu_operator_repo, branch=cfg.dpu_operator_branch)
310308

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

0 commit comments

Comments
 (0)