Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

buildextend-live: add coreos-installer config directives to feature map #3083

Merged
merged 2 commits into from
Sep 9, 2022
Merged
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
39 changes: 21 additions & 18 deletions src/cmd-buildextend-live
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import sys
import tarfile
import tempfile
import time
import yaml

sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from cosalib.builds import Builds
Expand Down Expand Up @@ -135,24 +136,26 @@ def align_initrd_for_uncompressed_append(destf):
# Return OS features table for features.json, which is read by
# coreos-installer {iso|pxe} customize
def get_os_features():
features = {}

f = runcmd(['/usr/bin/ostree', 'cat', '--repo', repo,
buildmeta_commit, '/usr/libexec/coreos-installer-service'],
capture_output=True).stdout.decode()
# eventually we can assume coreos-installer >= 0.12.0, delete this check,
# and hardcode the feature flag
if '--config-file' in f:
features['installer-config'] = True

f = runcmd(['/usr/bin/ostree', 'cat', '--repo', repo,
buildmeta_commit,
'/usr/lib/dracut/modules.d/35coreos-network/coreos-copy-firstboot-network.sh'],
capture_output=True).stdout.decode()
# eventually we can assume /etc/coreos-firstboot-network support and
# hardcode the feature flag
if 'etc_firstboot_network_dir' in f:
features['live-initrd-network'] = True
features = {
# coreos-installer >= 0.12.0
'installer-config': True,
# coreos/fedora-coreos-config@3edd2f28
'live-initrd-network': True,
}

# coreos-installer >= 0.16.0
try:
f = runcmd(['/usr/bin/ostree', 'cat', '--repo', repo, buildmeta_commit,
'/usr/share/coreos-installer/example-config.yaml'],
capture_output=True).stdout.decode()
features['installer-config-directives'] = {
k: True for k in yaml.safe_load(f)
}
except subprocess.CalledProcessError as e:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a blocker at all but I'd note with the ostree API we can actually more properly distinguish "ENOENT" from "something else went wrong". Kind of tempting to add cat --allow-noent which returns no output or something.

This is much like https://users.rust-lang.org/t/why-i-use-anyhow-error-even-in-libraries/68592

if e.returncode == 1:
print('coreos-installer example-config.yaml not found. Not setting feature.')
else:
raise

return features

Expand Down