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

grub: de-hardcode firstboot network configuration #1373

Merged
merged 1 commit into from
May 26, 2020

Conversation

lucab
Copy link
Contributor

@lucab lucab commented Apr 20, 2020

This removes the hardcoded network configuration kargs from grub,
moving them into handling within initramfs by dracut-cmdline.service.

Ref: coreos/fedora-coreos-tracker#460
Ref: coreos/fedora-coreos-config#427

@lucab
Copy link
Contributor Author

lucab commented Apr 20, 2020

/hold

@jlebon
Copy link
Member

jlebon commented Apr 20, 2020

See #1298 for the other spots we need to tweak too.

Worth noting in the commit message also that the eventual goal is to remove rd.neednet=1 as well as we move towards on-request network enablement.

@dustymabe
Copy link
Member

we need to be real careful with this because it will change it for all streams. We need to make sure when we merge this and do our first testing release that we also tag coreos-assembler so we can use the same one for the subsequent stable release (this is related to https://github.com/coreos/fedora-coreos-streams/issues/64)

@jlebon
Copy link
Member

jlebon commented Apr 21, 2020

we need to be real careful with this because it will change it for all streams

Yeah, good point. Tagging cosa would work, though another approach is to just add a new image.yaml knob which cosa keys off of. That way it naturally gets promoted together with content. I think we should do that anyway so that it's easier to ratchet all of this into FCOS/RHCOS atomically.

@darkmuggle
Copy link
Contributor

There is a potential way to deal with N streams: embed the kargs into the ignition.firstboot and have grub read them in and then set the defaults on a per distro/stream. The advantage here is decoupling the builder from the configuration. I also think we could take it further, and just have the grub.cfg provided by the stream itself and COSA place it.

That said, I don't have a strong opinion either way. The change seems sensible to me.

Copy link
Member

@ashcrow ashcrow left a comment

Choose a reason for hiding this comment

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

I'm OK with this move but let's be careful to ensure all required updates make it into RHCOS as well here (IE: updated afterburn and the referenced service).

src/cmd-buildextend-metal Outdated Show resolved Hide resolved
jlebon added a commit to jlebon/fedora-coreos-config that referenced this pull request May 25, 2020
This is part of moving to conditional networking
(coreos/fedora-coreos-tracker#443).

Let's move the firstboot kargs here as prep for dropping them entirely.
See also: coreos/coreos-assembler#1373
Copy link
Member

@jlebon jlebon left a comment

Choose a reason for hiding this comment

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

Some comments, but LGTM overall! I've tested this as part of coreos/fedora-coreos-config#426.


# source in the `ignition.firstboot` file which could override the
# above $ignition_network_kcmdline with static networking config.
# This override feature is primarily used by coreos-installer to
# persist static networking config provided during install to the
# first boot of the machine.
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, I think this comment is still true, no?

@@ -143,6 +143,17 @@ if [ "${image_type}" = dasd ] || [ "${image_type}" = metal4k ]; then
ignition_platform_id=metal
fi

# Firstboot kernel arguments.
firstboot_kargs="$(python3 -c '
import sys, yaml;
Copy link
Member

Choose a reason for hiding this comment

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

Minor/optional: I think we can drop the semicolons here and below since this is a proper multiline string now?

import sys, yaml;
LEGACY_DEFAULT = [ "rd.neednet=1", "ip=dhcp,dhcp6" ];
args = yaml.safe_load(sys.stdin).get("firstboot-kargs", LEGACY_DEFAULT);
if not args:
Copy link
Member

Choose a reason for hiding this comment

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

One subtlety here that I missed at first (which contributed to why I originally wanted something more explicit than this) is that it appears like this can never be false since we provide a default. Maybe a comment here like: # firstboot-kargs provided, but is empty ?

Copy link
Contributor Author

@lucab lucab May 26, 2020

Choose a reason for hiding this comment

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

(I blame PEP8 for convincing a generation of programmers that a list and a boolean are isomorphic)

This removes the hardcoded network configuration kargs from grub,
moving them into handling within initramfs by `dracut-cmdline.service`.
@lucab
Copy link
Contributor Author

lucab commented May 26, 2020

Rebased. There was actually a bug in the logic writing /boot/ignition.firstboot. I also adjusted the parameter name to match what GRUB and coreos-installer use.
coreos/fedora-coreos-config#427 shows how to configure this logic.

This PR can land as soon review-stamped, as it internally preserve the previously-GRUB-hardcoded defaults.

I manually tested that this works with the logic in Afterburn 4.4.0 in F32.

@lucab
Copy link
Contributor Author

lucab commented May 26, 2020

/hold cancel

@ashcrow
Copy link
Member

ashcrow commented May 26, 2020

This PR can land as soon review-stamped, as it internally preserve the previously-GRUB-hardcoded defaults.

Perfect 👍

/lgtm

@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ashcrow, jlebon, lucab

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [ashcrow,jlebon,lucab]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-robot openshift-merge-robot merged commit 5f2e11e into coreos:master May 26, 2020
@@ -392,7 +395,7 @@ s390x)
# stage on s390x, either through zipl->grub2-emu or zipl standalone.
# See https://github.com/coreos/ignition-dracut/issues/84
# A similar hack is present in https://github.com/coreos/coreos-assembler/blob/master/src/gf-platformid#L55
echo "$(grep options $blsfile) ignition.firstboot rd.neednet=1 ip=dhcp,dhcp6" > $tmpfile
Copy link
Member

Choose a reason for hiding this comment

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

Hmm actually, I think we need to add ${firstboot_kargs} here, right? Because s390x doesn't use the GRUB config yet. And in gf_platformid too.

Or... we just sprint to coreos/fedora-coreos-config#426.

Copy link
Contributor Author

@lucab lucab May 26, 2020

Choose a reason for hiding this comment

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

This will also affect RHCOS and slower FCOS streams, so let's fix it.

I'm unsure however how to wire this new variable content to gf_platformid. Do we actually need to have it there, if that is only injecting the platform ID?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Meh, my current attempt is at #1479.

@lucab lucab deleted the ups/grub-ipless branch May 26, 2020 13:46
jlebon added a commit to jlebon/coreos-assembler that referenced this pull request Aug 21, 2020
We've now reached the end of the conditional networking 🌈 rainbow 🌈.
We can rip out the legacy default network firstboot kargs from cosa.
These now live in the config repo. E.g.:

https://github.com/coreos/fedora-coreos-config/blob/be456c437d4181435022ce47079b587f5bcb0319/overlay.d/05core/usr/lib/dracut/modules.d/15coreos-network/50-afterburn-network-kargs-default.conf

For more details, see:
coreos#1373
coreos/fedora-coreos-config#426
openshift-merge-robot pushed a commit that referenced this pull request Oct 28, 2020
We've now reached the end of the conditional networking 🌈 rainbow 🌈.
We can rip out the legacy default network firstboot kargs from cosa.
These now live in the config repo. E.g.:

https://github.com/coreos/fedora-coreos-config/blob/be456c437d4181435022ce47079b587f5bcb0319/overlay.d/05core/usr/lib/dracut/modules.d/15coreos-network/50-afterburn-network-kargs-default.conf

For more details, see:
#1373
coreos/fedora-coreos-config#426
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants