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

Fixes #36940 - Add necessary migration for host_config tftp directory #949

Merged
merged 1 commit into from
Dec 2, 2024

Conversation

sbernhard
Copy link
Contributor

@sbernhard sbernhard commented May 31, 2024

The migration is necessary as part of the puppet_foreman_proxy change in theforeman/puppet-foreman_proxy#821

Belongs to the SecureBoot story: theforeman/foreman#9864

@ehelms
Copy link
Member

ehelms commented May 31, 2024

A migration spec for this would be great to have. Example: https://github.com/theforeman/foreman-installer/blob/develop/spec/migrations/20240328125552_reset_puppetserver_ciphers_spec.rb

@sbernhard sbernhard force-pushed the fix_36940 branch 2 times, most recently from c3e3495 to f115512 Compare May 31, 2024 14:14
@goarsna
Copy link
Contributor

goarsna commented Jul 16, 2024

FYI: @nofaralfasi and I had a discussion last week that resulted in some changes we want to implement on the Smart Proxy side which are summarized in the Smart Proxy PR. These changes also will affect this PR. Further updates will follow soonish / in the upcoming weeks (as soon as I have time to work on this again).

@goarsna
Copy link
Contributor

goarsna commented Aug 5, 2024

One outcome of the above mentioned discussion was that the Bootloader Universe should not be configurable. Instead it will be a fixed folder inside the TFTP root that is created automatically during installation / upgrade. The other agreement was, that the Host Config directory will be written with a dash. Both have now been applied to this PR.

@nofaralfasi
Copy link

/packit build

Copy link

Account nofaralfasi has no write access nor is author of PR!

@ehelms
Copy link
Member

ehelms commented Oct 28, 2024

/packit build

@ehelms
Copy link
Member

ehelms commented Oct 28, 2024

I think this will need a rebase to pass tests.

Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

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

Why are there multiple migrations, one adding host-config and another adding bootloader-universe?

@goarsna
Copy link
Contributor

goarsna commented Nov 7, 2024

Why are there multiple migrations, one adding host-config and another adding bootloader-universe?

There is no specific reason for that despite that the directories are independent of each other from a file system POV and that at the point I added the migration for the bootloader-universe directory to the migrations it looked cleaner to me to add it in a separate migration. But on the other hand the directories belong to each other as the one does not make sense without the other.

My current POV: We sould merge the migrations into one.

What do you think about it @nofaralfasi?

@nofaralfasi
Copy link

My current POV: We sould merge the migrations into one.

What do you think about it @nofaralfasi?

I also think that we should merge them into one.

@nofaralfasi
Copy link

Hi, when testing this PR, we're getting the following error: /usr/share/gems/gems/kafo-7.5.1/lib/kafo/puppet_command.rb:53:in format_command': wrong number of arguments (given 2, expected 1) (ArgumentError).
Any idea why this is happening?

@goarsna
Copy link
Contributor

goarsna commented Nov 12, 2024

Hi, when testing this PR, we're getting the following error: /usr/share/gems/gems/kafo-7.5.1/lib/kafo/puppet_command.rb:53:in format_command': wrong number of arguments (given 2, expected 1) (ArgumentError). Any idea why this is happening?

Hey Nofar, that is strange... I do not encounter this error (or any other errors) on my test system I just rolled out. But I have to mention that my test setup is based on Foreman 3.11 with the changes from the Secure Boot PRs applied on top.
When exactly does the error occur? Could you share the complete log output?

@nofaralfasi
Copy link

Hey Nofar, that is strange... I do not encounter this error (or any other errors) on my test system I just rolled out. But I have to mention that my test setup is based on Foreman 3.11 with the changes from the Secure Boot PRs applied on top. When exactly does the error occur? Could you share the complete log output?

When we run the foreman-installer command:

# foreman-installer
/usr/share/gems/gems/kafo-7.5.1/lib/kafo/puppet_command.rb:53:in `format_command': wrong number of arguments (given 2, expected 1) (ArgumentError)
	from /usr/share/foreman-installer/hooks/boot/01-kafo-hook-extensions.rb:132:in `execute_command'
	from /usr/share/foreman-installer/hooks/boot/01-kafo-hook-extensions.rb:124:in `execute'
	from /usr/share/foreman-installer/hooks/boot/03-foreman-maintain-extensions.rb:4:in `foreman_maintain'
	from /usr/share/foreman-installer/hooks/boot/09-version_locking.rb:2:in `package_lock_feature?'
	from /usr/share/foreman-installer/hooks/boot/09-version_locking.rb:5:in `block (4 levels) in load'
	from /usr/share/gems/gems/kafo-7.5.1/lib/kafo/hooking.rb:36:in `instance_eval'
	from /usr/share/gems/gems/kafo-7.5.1/lib/kafo/hooking.rb:36:in `block (4 levels) in load'
	from /usr/share/gems/gems/kafo-7.5.1/lib/kafo/hook_context.rb:19:in `instance_eval'
	from /usr/share/gems/gems/kafo-7.5.1/lib/kafo/hook_context.rb:19:in `execute'
	from /usr/share/gems/gems/kafo-7.5.1/lib/kafo/hooking.rb:67:in `block in execute'
	from /usr/share/gems/gems/kafo-7.5.1/lib/kafo/hooking.rb:65:in `each'
	from /usr/share/gems/gems/kafo-7.5.1/lib/kafo/hooking.rb:65:in `execute'
	from /usr/share/gems/gems/kafo-7.5.1/lib/kafo/kafo_configure.rb:144:in `initialize'
	from /usr/share/gems/gems/clamp-1.3.2/lib/clamp/command.rb:140:in `new'
	from /usr/share/gems/gems/clamp-1.3.2/lib/clamp/command.rb:140:in `run'
	from /usr/share/gems/gems/kafo-7.5.1/lib/kafo/kafo_configure.rb:54:in `run'
	from /usr/sbin/foreman-installer:8:in `<main>'

@goarsna
Copy link
Contributor

goarsna commented Nov 12, 2024

Thanks for the log! I assume the error is not related to the changes in the PR. But I do not know what is causing the error... :/

@goarsna
Copy link
Contributor

goarsna commented Nov 12, 2024

@nofar Rebased as discussed in DM. Maybe this solves the errors you encounter :)

@goarsna
Copy link
Contributor

goarsna commented Nov 12, 2024

I squashed the migrations as discussed :)

@stejskalleos
Copy link
Contributor

theforeman/smart-proxy#877 and theforeman/foreman#9864 have been merged

Copy link
Member

@ehelms ehelms left a comment

Choose a reason for hiding this comment

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

Good to go once we merge theforeman/puppet-foreman_proxy#821

@nofaralfasi
Copy link

theforeman/puppet-foreman_proxy#821 has been merged. Could we have this included as well?

@@ -0,0 +1,10 @@
if answers['foreman_proxy']
Copy link
Member

Choose a reason for hiding this comment

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

I always like to think about the data types and this is a Variant[Boolean, Hash]. In other words, this can be true as well and cause the later code to crash. true means use all defaults and you don't need a migration. That's why most migrations use .is_a?(Hash)

Suggested change
if answers['foreman_proxy']
if answers['foreman_proxy'].is_a?(Hash)

Copy link
Contributor

Choose a reason for hiding this comment

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

Done

Comment on lines 2 to 3
root = answers['foreman_proxy']['tftp_root']
if answers['foreman_proxy']['tftp_dirs']
Copy link
Member

Choose a reason for hiding this comment

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

This can fail because the data type of tftp_root is Optional[Stdlib::Absolutepath] (https://github.com/theforeman/puppet-foreman_proxy/blob/b73685cebc4efad1c23844843c0f98e1e6454138/manifests/init.pp#L340). It's usually set and I think it's safe enough to not migrate if it's not set.

Suggested change
root = answers['foreman_proxy']['tftp_root']
if answers['foreman_proxy']['tftp_dirs']
root = answers['foreman_proxy']['tftp_root']
if root && answers['foreman_proxy']['tftp_dirs']

Copy link
Contributor

Choose a reason for hiding this comment

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

And done. Thanks @ekohl!

Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

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

I didn't explicitly say it, but please keep all migrations the same.

@goarsna
Copy link
Contributor

goarsna commented Dec 2, 2024

🙈 Is there a face palm emoji on GitHub? 😅 Fixed it

@ekohl ekohl merged commit 57e5af7 into theforeman:develop Dec 2, 2024
7 of 8 checks passed
@goarsna
Copy link
Contributor

goarsna commented Dec 2, 2024

Thanks a lot @ekohl for merging this! And thanks to everyone who was involved in getting this done 🎉

@goarsna goarsna deleted the fix_36940 branch December 2, 2024 15:22
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.

6 participants