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

Fix Rocky container sed formatting #61

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Alex-Welsh
Copy link
Contributor

Whitespace in the cloud.cfg file could previously cause the sed to fail, preventing the image from booting properly:

[   12.623671] cloud-init[966]: 2024-03-27 09:48:06,919 - util.py[WARNING]: Failed loading yaml blob. Invalid format at line 102 column 5: "while parsing a block mapping
[   12.626039] cloud-init[966]:   in "<unicode string>", line 102, column 5:
[   12.627229] cloud-init[966]:         renderers: ['network-manager']
[   12.628358] cloud-init[966]:         ^
[   12.629054] cloud-init[966]: expected <block end>, but found '<block mapping start>'
[   12.630460] cloud-init[966]:   in "<unicode string>", line 103, column 7:
[   12.631628] cloud-init[966]:           activators: ['network-manager']

@@ -6,7 +6,7 @@ RUN dnf group install -y 'Minimal Install' --allowerasing && \
dnf install -y findutils util-linux \
https://mirror.stream.centos.org/9-stream/AppStream/x86_64/os/Packages/cloud-init-23.4-7.el9.noarch.rpm

RUN sed -i "s/renderers:.*/renderers: ['network-manager']\n activators: ['network-manager']/" /etc/cloud/cloud.cfg
RUN sed -i "s/renderers:.*/{renderers: ['network-manager'], activators: ['network-manager'] }/" /etc/cloud/cloud.cfg

Choose a reason for hiding this comment

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

Can you provide an example of the rendered output with some context?

Copy link
Contributor Author

@Alex-Welsh Alex-Welsh Mar 27, 2024

Choose a reason for hiding this comment

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

What the line is meant to do is edit /etc/cloud/cloud.cfg from something like this

foo:
   network:
      renderers: ['network-manager', 'some-other-options', 'more-options']

to:

foo:
   network:
      renderers: ['network-manager']
      activators: ['network-manager']   

But for some reason it breaks with the above error. My theory was that the solution wasn't working because it has a precise amount of whitespace in the sed command, so if the formatting of the source file is slightly changed it no longer is valid yaml. For example:

foo:
  network:
    renderers: ['network-manager']
      activators: ['network-manager']   

My solution instead edits it like this:

foo:
   network:
      {renderers: ['network-manager'], activators: ['network-manager'] }   

Which is valid yaml that no longer relies on whitespace.

Now all that being sed, I've since discovered that this element is breaking the Rocky 8 builds, and there has been a change to the upstream version here so rather than making similar changes for rocky 8, I was just going to try switching back to that upstream one and dropping this element entirely.

Choose a reason for hiding this comment

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

Now all that being sed

Appreciate this hidden pun.

@Alex-Welsh Alex-Welsh requested a review from mnasiadka March 27, 2024 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants