Skip to content

base-host-check: expand to cover more (COMPOSER-2498) - #1432

Merged
supakeen merged 12 commits into
osbuild:mainfrom
supakeen:additional-base-host-checks
Apr 25, 2025
Merged

supakeen merged 12 commits into
osbuild:mainfrom
supakeen:additional-base-host-checks

Conversation

@supakeen

@supakeen supakeen commented Apr 15, 2025 •

Copy link
Copy Markdown
Member

TBD, includes the checks from #1419 plus more.

@supakeen

supakeen commented Apr 17, 2025 •

Copy link
Copy Markdown
Member Author

TODO:

  • Properties of users (authorized_keys).
  • Check masked systemd services.
  • Check ports in the firewall as well.

@supakeen

Copy link
Copy Markdown
Member Author

@lucasgarfield / @croissanne, when using the hostname customization for an AMI, and booted on EC2 the hostname gets overwritten by cloud-init when the machine is brought online.

How do we want to handle this. This seems like a behavioral issue (we need to not allow hostname customizations when cloud-init will take care of it, or we need to disable cloud-init's hostname stuff when it is customized)?

@supakeen

Copy link
Copy Markdown
Member Author

Looking at the results here it seems like masked services are not actually being masked; see example output:

+ echo '📗 Checking masked services'
++ jq -rc '.blueprint.customizations.services.masked[]' all-customizations.json
+ services_expected='nfs-server
rpcbind
nftables'
+ echo 'nfs-server
rpcbind
nftables'
+ read -r service_expected
++ systemctl list-unit-files --state=masked
+ states='UNIT FILE STATE PRESET
0 unit files listed.'

@achilleas-k

Copy link
Copy Markdown
Member

This seems like a behavioral issue (we need to not allow hostname customizations when cloud-init will take care of it, or we need to disable cloud-init's hostname stuff when it is customized)?

I think it might be more reasonable to modify the cloud-init config to set preserve_hostname: true when a user sets a hostname. I'm not sure though. Maybe people would want to set a base hostname in their golden image but also override it on boot for some images.

@supakeen

Copy link
Copy Markdown
Member Author

Rebased on #1456 to make masked services work.

@lucasgarfield

Copy link
Copy Markdown

@lucasgarfield / @croissanne, when using the hostname customization for an AMI, and booted on EC2 the hostname gets overwritten by cloud-init when the machine is brought online.

How do we want to handle this. This seems like a behavioral issue (we need to not allow hostname customizations when cloud-init will take care of it, or we need to disable cloud-init's hostname stuff when it is customized)?

For now, it seems like testing this in AWS is impractical. And of course, it also seems pointless to expose this to users for AWS. We'll handle all of that in the front end.

In the future, we'll probably need to extend these boot tests for all targets. Maybe we can just disable the hostname test for targets that are initialized with cloud-init.

@supakeen
supakeen marked this pull request as ready for review April 24, 2025 10:22
@supakeen
supakeen requested review from a team, achilleas-k and thozza as code owners April 24, 2025 10:22

@thozza thozza left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you for extending the test coverage, much appreciated.

I've added a few comments.

On a general note, we should consider not failing fast in checks that are checking multiple values in a loop, but failing after all values are checked.

Comment thread test/scripts/base-host-check.sh Resolved
Comment thread test/scripts/base-host-check.sh Resolved
Comment thread test/scripts/base-host-check.sh Resolved
Comment on lines +135 to +141
# we only emit a warning here since the hostname gets reset by cloud-init and we're not
# entirely sure how to deal with it yet on the service level
if [[ $actual_hostname != "${expected_hostname}" ]]; then
echo "🟡 Hostname was not set: hostname=${actual_hostname} expected=${expected_hostname}"
else
echo "Hostname was set"
fi

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could the check warn only if cloud-init service is enabled and fail in case there is no cloud-init?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Only if the service is enabled, if the package is installed, or if it is configured in a certain way? There were a lot of ways and since we don't currently test in any ways where cloud-init isn't being used I felt it wasn't necessary.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

My idea was to warn only if the cloud-init service is enabled, which implies that it is installed. It could be configured not to set the hostname, but let's not complicate it with this option.

You are, of course, right that the effect in our current testing matrix is none. I was thinking more in the context of us not having to remember to fix this test case when we ever end up boot-testing image types without cloud-init.

FWIW, I'm OK with keeping the test as is for now.

supakeen added 12 commits April 25, 2025 13:32
Verifies the hostname configuration, if set.

Signed-off-by: Simon de Vlieger <[email protected]>
Initial smoke test to see if a user exists. More details to be tested in
follow ups.

Signed-off-by: Simon de Vlieger <[email protected]>
`hostname` is currently failing kinda expectedly so (since `cloud-init`
overwrites whatever customization we set when booted in AWS). Let's run
it last so we can also fix that expected failure last.

Signed-off-by: Simon de Vlieger <[email protected]>
Add firewall rules to the all-customizations so they can be boot-tested.

Signed-off-by: Simon de Vlieger <[email protected]>
Signed-off-by: Simon de Vlieger <[email protected]>
Let's make the hostname check emit a yellow circle as a warning, it's
currently kinda expected in the image types that we boot test to have
this fail due to cloud-init setting the host name on boot.

When we start boot testing more image types this can be conditionalized
on that.

Signed-off-by: Simon de Vlieger <[email protected]>
Images need to be generated newly so the additional testcases will run
in CI.

Signed-off-by: Simon de Vlieger <[email protected]>

@thozza thozza left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@supakeen
supakeen enabled auto-merge April 25, 2025 12:06
@supakeen
supakeen added this pull request to the merge queue Apr 25, 2025
Merged via the queue into osbuild:main with commit 8999b0d Apr 25, 2025
@supakeen
supakeen deleted the additional-base-host-checks branch April 25, 2025 13:43
achilleas-k added a commit to achilleas-k/osbuild-composer that referenced this pull request Apr 29, 2025
tag v0.140.0
Tagger: imagebuilder-bot <[email protected]>

Changes with 0.140.0

----------------
  * Loader part override followups (osbuild/image-builder#1466)
    * Author: Michael Vogt, Reviewers: Tomáš Hozza
  * RHEL-10/gce: install cloud-utils-growpart by default (osbuild/image-builder#1463)
    * Author: Tomáš Hozza, Reviewers: Michael Vogt, Simon de Vlieger
  * base-host-check: expand to cover more (COMPOSER-2498) (osbuild/image-builder#1432)
    * Author: Simon de Vlieger, Reviewers: Tomáš Hozza
  * rhel8,9: move partitioning into YAML (osbuild/image-builder#1390)
    * Author: Michael Vogt, Reviewers: Tomáš Hozza

— Somewhere on the Internet, 2025-04-28

---

tag v0.141.0
Tagger: imagebuilder-bot <[email protected]>

Changes with 0.141.0

----------------
  * Shrink the current installer images a bit (osbuild/image-builder#1423)
    * Author: Brian C. Lane, Reviewers: Achilleas Koutsou, Simon de Vlieger, Tomáš Hozza
  * Update EL10 Azure images with changes made in RHEL 9.6 (osbuild/image-builder#1472)
    * Author: Achilleas Koutsou, Reviewers: Michael Vogt, Tomáš Hozza
  * distro: add DNFSetReleaseVerVar to ImageConfig (osbuild/image-builder#1465)
    * Author: Michael Vogt, Reviewers: Achilleas Koutsou, Tomáš Hozza
  * test/base-host-check.sh: fix disabled firewall services check (osbuild/image-builder#1471)
    * Author: Sanne Raymaekers, Reviewers: Achilleas Koutsou, Tomáš Hozza

— Somewhere on the Internet, 2025-04-29

---
thozza pushed a commit to osbuild/osbuild-composer that referenced this pull request Apr 29, 2025
tag v0.140.0
Tagger: imagebuilder-bot <[email protected]>

Changes with 0.140.0

----------------
  * Loader part override followups (osbuild/image-builder#1466)
    * Author: Michael Vogt, Reviewers: Tomáš Hozza
  * RHEL-10/gce: install cloud-utils-growpart by default (osbuild/image-builder#1463)
    * Author: Tomáš Hozza, Reviewers: Michael Vogt, Simon de Vlieger
  * base-host-check: expand to cover more (COMPOSER-2498) (osbuild/image-builder#1432)
    * Author: Simon de Vlieger, Reviewers: Tomáš Hozza
  * rhel8,9: move partitioning into YAML (osbuild/image-builder#1390)
    * Author: Michael Vogt, Reviewers: Tomáš Hozza

— Somewhere on the Internet, 2025-04-28

---

tag v0.141.0
Tagger: imagebuilder-bot <[email protected]>

Changes with 0.141.0

----------------
  * Shrink the current installer images a bit (osbuild/image-builder#1423)
    * Author: Brian C. Lane, Reviewers: Achilleas Koutsou, Simon de Vlieger, Tomáš Hozza
  * Update EL10 Azure images with changes made in RHEL 9.6 (osbuild/image-builder#1472)
    * Author: Achilleas Koutsou, Reviewers: Michael Vogt, Tomáš Hozza
  * distro: add DNFSetReleaseVerVar to ImageConfig (osbuild/image-builder#1465)
    * Author: Michael Vogt, Reviewers: Achilleas Koutsou, Tomáš Hozza
  * test/base-host-check.sh: fix disabled firewall services check (osbuild/image-builder#1471)
    * Author: Sanne Raymaekers, Reviewers: Achilleas Koutsou, Tomáš Hozza

— Somewhere on the Internet, 2025-04-29

---
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.

4 participants