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 #36877 - Add a pre-upgrade check for katello-agent #782

Merged
merged 1 commit into from
Nov 1, 2023
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
41 changes: 41 additions & 0 deletions definitions/checks/katello_agent.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
require 'yaml'

class Checks::CheckKatelloAgentEnabled < ForemanMaintain::Check
metadata do
label :check_katello_agent_enabled
description 'Check whether the katello-agent feature is enabled before upgrading'
tags :pre_upgrade

confine do
!feature(:capsule)
end
end

def run
instance_name = feature(:instance).downstream ? "Satellite" : "Katello"
instance_version = feature(:instance).downstream ? "6.15" : "4.10"
installer_command = feature(:instance).downstream ? "satellite-installer" : "foreman-installer"
maintain_command = feature(:instance).downstream ? "satellite-maintain" : "foreman-maintain"

assert(
!katello_agent_enabled?,
"The katello-agent feature is enabled on this system. As of #{instance_name}"\
" #{instance_version}, katello-agent is removed and will no longer function."\
" Before proceeding with the upgrade, you should ensure that you have deployed"\
" and configured an alternative tool for remote package management and patching"\
" for content hosts, such as Remote Execution (REX) with pull-based transport."\
" See the Managing Hosts guide in the #{instance_name} documentation for more info."\
" Disable katello-agent with the command"\
" `#{installer_command} --foreman-proxy-content-enable-katello-agent false`"\
" before proceeding with the upgrade. Alternatively, you may skip this check and proceed by"\
" running #{maintain_command} again with the `--whitelist` option, which will automatically"\
" uninstall katello-agent."
Comment on lines +30 to +32

Choose a reason for hiding this comment

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

As someone new to foreman-maintain, I'm still not sure what command it's telling me to run here. I assume it's not just foreman-maintain --whitelist? Can it give me the exact command I would run?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I need to figure out how the name to pass to --whitelist is constructed from the label :check_katello_agent_enabled

Copy link
Contributor Author

@wbclark wbclark Oct 31, 2023

Choose a reason for hiding this comment

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

OK, so it would be --whitelist="check-katello-agent-enabled" but it turns out the exact language shouldn't be necessary here.

The reason why is that if ANY checks fail, there is general language explaining how to whitelist the failed step.

)
end

private

def katello_agent_enabled?
feature(:installer).answers['foreman_proxy_content']['enable_katello_agent']
end
end
Loading