Skip to content

Commit 4d920a8

Browse files
committed
kt vm: Pin Rocky repos to vault to prevent minor version drift
Without this, dnf resolves packages from the latest minor release instead of the one the image was built with. - Disable mirrorlist to stop dnf from redirecting to the latest minor version - Point baseurl to the Rocky vault where old minor versions are permanently hosted - Replace $releasever with the actual VERSION_ID from /etc/os-release to pin to the exact minor version - Clear dnf cache to force metadata refresh from the new vault URLs All of these were added in kt/data/cloud-init.yaml that is the base for all vms. When kt vm is run the first time for a kernel workspace, a copy of cloud-init.yaml is created. Use ruamel instead so that comments and the original formatting stays the same when the yaml file is read and then dump in python. Signed-off-by: Roxana Nicolescu <rnicolescu@ciq.com> add to a8edde3
1 parent b22273b commit 4d920a8

3 files changed

Lines changed: 21 additions & 7 deletions

File tree

‎kt/data/cloud_init.yaml‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,14 @@ ssh_pwauth: true
1515
package_upgrade: False
1616

1717
mounts:
18-
- ["mount_tag_mock_scratch", "SHARED_DIR_PLACEHOLDER", "virtiofs", "rw,relatime,context=unconfined_u:object_r:mock_var_lib_t:s0"]
19-
- ["SHARED_DIR_PLACEHOLDER", "/var/lib/mock", "bind", "defaults,bind"]
18+
- - mount_tag_mock_scratch
19+
- SHARED_DIR_PLACEHOLDER
20+
- virtiofs
21+
- rw,relatime,context=unconfined_u:object_r:mock_var_lib_t:s0
22+
- - SHARED_DIR_PLACEHOLDER
23+
- /var/lib/mock
24+
- bind
25+
- defaults,bind
2026

2127
# Change working directory after boot
2228
# Setting up homedir does not work without tricks, because
@@ -32,7 +38,9 @@ write_files:
3238
# and then root is the owner
3339
# workaround to change the owner to user
3440
runcmd:
35-
- [chown, USER_PLACEHOLDER:USER_PLACEHOLDER, HOMEDIR_PLACEHOLDER]
41+
- - chown
42+
- USER_PLACEHOLDER:USER_PLACEHOLDER
43+
- HOMEDIR_PLACEHOLDER
3644

3745
power_state:
3846
mode: reboot

‎kt/ktlib/vm.py‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
import time
66
from dataclasses import dataclass
77

8-
import oyaml as yaml
98
import wget
109
from git import Repo
1110
from pathlib3x import Path
11+
from ruamel.yaml import YAML
1212

1313
from urllib.parse import urlparse
1414

@@ -187,9 +187,15 @@ def _download_source_image(self, override_base: bool = False):
187187
wget.download(self._get_vm_url(), out=str(self.qcow2_source_path))
188188

189189
def _setup_cloud_init(self, config: Config):
190+
yaml = YAML()
191+
yaml.preserve_quotes = True
192+
yaml.width = 4096
193+
yaml.default_flow_style = False
194+
yaml.best_sequence_indent = 2
195+
190196
data = None
191197
with open(CLOUD_INIT_BASE_PATH) as f:
192-
data = yaml.safe_load(f)
198+
data = yaml.load(f)
193199

194200
# replace placeholders with user data
195201
data["users"][0]["name"] = config.user
@@ -238,7 +244,6 @@ def _setup_cloud_init(self, config: Config):
238244
data["runcmd"].append([str(config.base_path / Path("kernel-src-tree-tools") / Path("kernel_install_dep.sh"))])
239245
# Write this to image cloud_init
240246
with open(self.cloud_init_path, "w") as f:
241-
f.write("#cloud-config\n")
242247
yaml.dump(data, f)
243248

244249
def _create_image(self, config: Config, vcpus: int = 12, memory: int = 32768):

‎pyproject.toml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ dependencies = [
99
"click",
1010
"pathlib3x",
1111
"python3-wget",
12-
"oyaml",
12+
"ruamel.yaml",
13+
"pyyaml",
1314
"pexpect",
1415
"jira",
1516
"requests",

0 commit comments

Comments
 (0)