Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions clustersConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,16 @@ class ExtraConfigArgs:
kickstart: Optional[str] = None
remove_args: Optional[str] = None

registry: Optional[list[RegistryInfo]] = None

# Custom OVN repo URL
ovn_repo: Optional[str] = None
# Custom OVN ref, it should be existing commit hash or branch
ovn_ref: Optional[str] = None

registries: Optional[list[RegistryInfo]] = None
import_pull_secret: bool = False
import_pull_secret: bool = True
bootc_dir: str = "rhel-image-mode-4-dpu"
bootc_build_local: bool = True
iso_builder_auth_file: Optional[str] = None

def __post_init__(self) -> None:
if self.registries is not None:
Expand Down
17 changes: 14 additions & 3 deletions dpuVendor.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,25 @@ def setup(self, dpu: host.Host) -> None:
def download_p4_tar(self, rh: host.Host) -> None:
logger.info("Downloading p4.tar.gz")
rh.run_or_die(f"curl -L {self.P4_URL} -o /tmp/p4.tar.gz")
rh.run("rm -rf /opt/p4")
rh.run_or_die("tar -U -C /opt/ -xzf /tmp/p4.tar.gz")
rh.run("mv /opt/intel-ipu-acc-components-2.0.0.11126 /opt/p4")
rh.run("rm -rf /opt/p4/*")
rh.run_or_die("tar -U -C /tmp/ -xzf /tmp/p4.tar.gz")
rh.run("mv /tmp/intel-ipu-acc-components-2.0.0.11126/* /opt/p4/")
rh.run("mv /opt/p4/p4-cp /opt/p4/p4-cp-nws")
rh.run("mv /opt/p4/p4-sde /opt/p4/p4sde")
rh.run("rm -rf /tmp/intel-ipu-acc-components-2.0.0.11126")

def configure_p4_hugepages(self, rh: host.Host) -> None:
logger.info("Configuring hugepages for p4 pod")

# Check if the service already exists - skip if it does
try:
result = rh.run("systemctl list-unit-files hugepages-setup.service")
if "hugepages-setup.service" in result.out:
logger.info("hugepages-setup.service already exists, skipping configuration")
return
except Exception as e:
logger.debug(f"Could not check for existing service: {e}, proceeding with setup")

# The p4 container typically sets this up. If we are running the container as a daemonset in microshift, we need to
# ensure this resource is available prior to the pod starting to ensure dpdk is successful
hugepages_service = """[Unit]
Expand Down
42 changes: 18 additions & 24 deletions extraConfigHostRegistry.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from concurrent.futures import Future
from typing import Optional
from typing import Optional, Any
from auth import import_secret_path
from clustersConfig import ClustersConfig
from logger import logger
Expand All @@ -12,31 +12,25 @@
def ExtraConfigHostRegistry(cc: ClustersConfig, cfg: ExtraConfigArgs, futures: dict[str, Future[Optional[host.Result]]]) -> None:
[f.result() for (_, f) in futures.items()]

auth_path = "/run/user/0/containers/auth.json"

# Load existing data
if os.path.exists(auth_path):
with open(auth_path, "r") as f:
try:
auth_data = json.load(f)
except json.JSONDecodeError:
logger.warning(f"{auth_path} is invalid. Resetting.")
auth_data = {"auths": {}}
else:
auth_data = {"auths": {}}

# Merge pull secret
if cfg.import_pull_secret:
logger.info(f"Importing secrets_path: {cc.secrets_path}")
auth_data["auths"].update(import_secret_path(cc.secrets_path))

# Merge other user-defined registries
if cfg.registries:
logger.info(f"Preparing registries: {cfg.registries}")
for r in cfg.registries:
auth_data: dict[str, Any] = {"auths": {}}
if cfg.import_pull_secret:
logger.info(f"Importing secrets_path: {cc.secrets_path}")
auth_data["auths"].update(import_secret_path(cc.secrets_path))
if os.path.exists(r.auth_path):
with open(r.auth_path, "r") as f:
try:
auth_data = json.load(f)
except json.JSONDecodeError:
logger.warning(f"{r.auth_path} is invalid. Resetting.")
auth_data = {"auths": {}}
else:
auth_data = {"auths": {}}
auth_data["auths"].update(r.prep_auth())

# Write once
os.makedirs(os.path.dirname(auth_path), exist_ok=True)
with open(auth_path, "w") as f:
json.dump(auth_data, f, indent=2)
os.makedirs(os.path.dirname(r.auth_path), exist_ok=True)
with open(r.auth_path, "w") as f:
json.dump(auth_data, f, indent=2)
logger.info(f"Successfully wrote {len(auth_data['auths'])} registry auth entries to {r.auth_path}")
11 changes: 11 additions & 0 deletions extraConfigIsoBuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ def ExtraConfigIsoBuilder(
activation_key: str = cast(str, cfg.activation_key)
image_mode_url: str = cfg.image_mode_url
iso_builder_url: str = cfg.iso_builder_url
bootc_build_local: bool = cfg.bootc_build_local
bootc_dir: str = cfg.bootc_dir
iso_builder_auth_file: Optional[str] = cfg.iso_builder_auth_file

# Optional bootc iso build params
input_iso: Optional[str] = cfg.input_iso
Expand All @@ -52,6 +55,10 @@ def ExtraConfigIsoBuilder(
if dpu_flavor == "ipu":
extra_args = " ip=192.168.0.2:::255.255.255.0::enp0s1f0:off netroot=iscsi:192.168.0.1::::iqn.e2000:acc acpi=force"
kernel_args = (kernel_args or "") + extra_args
remove_args = "rd.live.check"
grub_replacements = [
"timeout=60|timeout=5",
]

# Build the ISO
BootcIsoBuilder(
Expand All @@ -67,4 +74,8 @@ def ExtraConfigIsoBuilder(
kernel_args=kernel_args,
remove_args=remove_args,
dpu_flavor=dpu_flavor,
auth_file_path=iso_builder_auth_file, # Use auth file from iso_builder config
bootc_build_local=bootc_build_local,
grub_replacements=grub_replacements,
bootc_dir=bootc_dir,
).build()
84 changes: 67 additions & 17 deletions extraConfigMicroshift.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,47 +88,97 @@ def ExtraConfigMicroshift(cc: ClustersConfig, cfg: ExtraConfigArgs, futures: dic

# Configure firewalld for microshift
logger.info("Configuring firewall for microshift")
acc.run("systemctl disable firewalld")
acc.run("systemctl stop firewalld")
fw_active = acc.run("systemctl is-active firewalld")
fw_enabled = acc.run("systemctl is-enabled firewalld")

if fw_active.success() and "active" in fw_active.out:
logger.info("Stopping firewalld service")
acc.run("systemctl stop firewalld")

if fw_enabled.success() and "enabled" in fw_enabled.out:
logger.info("Disabling firewalld service")
acc.run("systemctl disable firewalld")

# Adjust the timeout for microshift service to ensure it starts successfully
acc.run_or_die("mkdir -p /etc/systemd/system/microshift.service.d/")
acc.write("/etc/systemd/system/microshift.service.d/override.conf", "[Service]\nTimeoutStartSec=15m")
acc.run("mkdir -p /etc/systemd/system/microshift.service.d/")
override_content = "[Service]\nTimeoutStartSec=15m"
existing_override = acc.run("cat /etc/systemd/system/microshift.service.d/override.conf 2>/dev/null")
service_override_changed = False
if not existing_override.success() or override_content not in existing_override.out:
logger.info("Writing microshift service timeout override")
acc.write("/etc/systemd/system/microshift.service.d/override.conf", override_content)
acc.run("systemctl daemon-reload")
service_override_changed = True

# Check if microshift is already installed
ms_installed = acc.run("rpm -q microshift")
multus_installed = acc.run("rpm -q microshift-multus")
microshift_already_installed = ms_installed.success() and multus_installed.success()

# Only add early access repo if microshift is not already installed
if not microshift_already_installed:
repo_exists = acc.run("test -f /etc/yum.repos.d/microshift-canidate.repo")
if not repo_exists.success():
logger.info("Writing microshift candidate repository")
acc.write("/etc/yum.repos.d/microshift-canidate.repo", early_access_microshift())
else:
logger.info("Microshift already installed, skipping early access repository setup")

# Check on the status of the cluster
acc.write("/etc/yum.repos.d/microshift-canidate.repo", early_access_microshift())
time.sleep(1)
logger.info("Checking if time is set properly to avoid OCSR errors")
logger.info(acc.run("systemctl status chronyd --no-pager -l"))
lh_date = host.LocalHost().run("date").out.strip()
acc_date = host.LocalHost().run("date").out.strip()
acc_date = acc.run("date").out.strip()
logger.info(f"LocalHost date: {lh_date}")
logger.info(f"ACC date: {acc_date}")
logger.info("Manually synchronizing time")
host.sync_time(lh, acc)
lh_date = host.LocalHost().run("date").out.strip()
acc_date = host.LocalHost().run("date").out.strip()
acc_date = acc.run("date").out.strip()
logger.info(f"LocalHost date: {lh_date}")
logger.info(f"ACC date: {acc_date}")

logger.info("Installing microshift")
acc.run_or_die("dnf install -y microshift microshift-multus", retry=60)
# Install microshift packages (idempotent)
config_changed = service_override_changed

if not microshift_already_installed:
logger.info("Installing microshift")
acc.run_or_die("dnf install -y microshift microshift-multus", retry=60)
config_changed = True
else:
logger.info("Microshift packages already installed")

# Configure crio runtime (idempotent)
ret = acc.run(r"grep '\[crio.runtime.runtimes.crun\]' /etc/crio/crio.conf")
if not ret.success():
logger.info("Adding crun configuration to crio.conf")
crun_conf_lines = ['[crio.runtime.runtimes.crun]', 'runtime_path = "/usr/bin/crun"', 'runtime_type = "oci"', 'runtime_root = "/run/crun"']
for line in crun_conf_lines:
acc.run(f'echo \'{line}\' >> /etc/crio/crio.conf')
acc.run("systemctl restart crio.service")
logger.info("Starting microshift")
acc.run("systemctl restart microshift")
acc.run("systemctl enable microshift")
acc.run("systemctl restart crio.service")
config_changed = True
else:
logger.info("crun configuration already present in crio.conf")

# Start and enable microshift (idempotent)
logger.info("Managing microshift service")
ms_enabled = acc.run("systemctl is-enabled microshift")
if not ms_enabled.success() or "enabled" not in ms_enabled.out:
logger.info("Enabling microshift service")
acc.run("systemctl enable microshift")
config_changed = True

ms_active = acc.run("systemctl is-active microshift")
if not ms_active.success() or "active" not in ms_active.out:
logger.info("Starting microshift service")
acc.run("systemctl restart microshift")
elif config_changed:
logger.info("Configuration changed, restarting microshift service")
acc.run("systemctl restart microshift")

contents = read_prep_microshift_kubeconfig(acc)
kubeconfig = write_microshift_kubeconfig(contents, host.LocalHost())

acc.run("systemctl stop firewalld")
acc.run("systemctl disable firewalld")

def cb() -> None:
acc.run("ip r del default via 192.168.0.1")

Expand Down
7 changes: 3 additions & 4 deletions ipu.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ def _wait_for_acc_with_retry(self, acc: host.Host) -> None:
acc.ssh_connect("root", "redhat")
logger.info(acc.run("uname -a"))
logger.info("Connected to ACC")
if acc.exists("/cda-install"):
logger.error_and_exit("Found /cda-install file from a previous installation (install failed)")
acc.write("/cda-install", f"{time.time()}")
if acc.exists("/var/cda-install"):
logger.error_and_exit("Found /var/cda-install file from a previous installation (install failed)")
acc.write("/var/cda-install", f"{time.time()}")

def start(self, iso_or_image_path: str) -> bool:
assert self.config.bmc is not None
Expand Down Expand Up @@ -183,7 +183,6 @@ def helper(cmd: str) -> host.Result:
# after an IMC reboot (which occurs during the RHEL installation)
assert self.config.dpu_host is not None
logger.info(f"Reloading idpf on host side {self.config.dpu_host}")

ipu_host = host.RemoteHost(self.config.dpu_host)
ipu_host.ssh_connect("core")
ipu_host.run("sudo rmmod idpf")
Expand Down
1 change: 1 addition & 0 deletions iso-surgeon/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ You can optionally provide:
* `--input_iso`: use an existing RHEL boot ISO
* `--kickstart`: custom kickstart file
* `--kernel_args`: GRUB arguments to inject
* `--grub_replace`: GRUB replacements in format 'old_text:new_text' (can be used multiple times, splits on "|")
* `--output_iso`: destination path for the new ISO
* `--rhel_version`: the version of RHEL to generate if no input iso is given

Expand Down
Loading