-
Notifications
You must be signed in to change notification settings - Fork 71
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 #33620 - Command for upgrading foreman-maintain to major version #546
Conversation
Issues: #33620 |
This covers below use cases:
|
@stored_enabled_repos_ids = [] | ||
backup_dir = File.expand_path(ForemanMaintain.config.backup_dir) | ||
File.open(File.join(backup_dir, 'enabled_repos.yml'), 'r') do |repos_file| | ||
@stored_enabled_repos_ids = YAML.load(repos_file.read) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file doesn't have to exist. BackupEnabledRepos
only writes it if it's non-empty. I think this would fail then. It also won't be in older backups. You probably need to deal with that to prevent exceptions. You could also use File.read
instead of File.open
+ .read
, but that's a small nit.
@stored_enabled_repos_ids = [] | |
backup_dir = File.expand_path(ForemanMaintain.config.backup_dir) | |
File.open(File.join(backup_dir, 'enabled_repos.yml'), 'r') do |repos_file| | |
@stored_enabled_repos_ids = YAML.load(repos_file.read) | |
end | |
path = File.expand_path('enabled_repos.yml', ForemanMaintain.config.backup_dir) | |
@stored_enabled_repos_ids = File.file?(path) ? YAML.load(File.read(path)) : [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch, what I am expecting,
If system is not having any repositories enabled then not having the yml dump is fine. However this also let me thought the situation where yml file has old repositories which are not relevant to current state of the system and hence I feel I should clean up this file after successfully executing enable_repos(repos_ids_to_reenable)
.
Is there a mechanism by which, for testing purposes, the repository handling could be skipped or configured to test this without first having to have the new maintenance repository in existence? |
I am pushing a new change which has additional flag to skip enabling repository |
Thinking on testing, and ahead towards Foreman use case, if the repository could be made configurable either via a foreman-maintain configuration file or an ENV variable then the code becomes more usable and able to test by pointing it at whatever repository you want to get updates. Generally, trying to split the mechanism from the configuration (details) will allow flexibility. |
@ekohl @ehelms wish to know your thoughts on below use cases,
Technically I can just go and enable whatever the required repositories for the X.Y version of Satellite but then that wont work for disconnected setups and there can still be some repositories user has configured which we want to reenable. |
backup_dir = File.expand_path(ForemanMaintain.config.backup_dir) | ||
unless enabled_repos_ids.empty? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can only expand the path if there are any repos:
backup_dir = File.expand_path(ForemanMaintain.config.backup_dir) | |
unless enabled_repos_ids.empty? | |
unless enabled_repos_ids.empty? | |
backup_dir = File.expand_path(ForemanMaintain.config.backup_dir) |
class SelfUpgradeRescue < SelfUpgradeBase | ||
metadata do | ||
label :rescue_self_upgrade | ||
description 'Disables all version specific maintenance repo and,'\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
description 'Disables all version specific maintenance repo and,'\ | |
description 'Disables all version specific maintenance repos and,'\ |
option ['--target-version'], 'TARGET_VERSION', 'Major version of the Satellite or Capsule'\ | ||
', e.g 7.0', :required => true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if this is allowed coding style wise, but it avoids breaking up the string which I think makes it easier to read.
option ['--target-version'], 'TARGET_VERSION', 'Major version of the Satellite or Capsule'\ | |
', e.g 7.0', :required => true | |
option ['--target-version'], 'TARGET_VERSION', | |
'Major version of the Satellite or Capsule, e.g 7.0', :required => true |
Now you can export the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm unsure about the inline comment. Overall I think this looks good from reading it, though I didn't test it.
end | ||
|
||
def maintenance_repo_version | ||
return '6' if current_version == '6.10' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just wondering: would it technically be 6
for 6.*
? Do you want compatibility with that or is it irrelevant? So:
return '6' if current_version == '6.10' | |
return '6' if current_version.start_with?('6.') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought to keep it 6.10 as new package wont be available for older versions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will we already have a separate repo for 6.10 then? Or is this procedure in some other way guarded to be unavailable on 6.9 and older?
@@ -29,6 +33,10 @@ def disable_repos(repo_ids) | |||
execute!("yum-config-manager --disable #{repo_ids.join(',')}") | |||
end | |||
|
|||
def enable_repos(repo_ids) | |||
execute!("yum-config-manager --enable #{repo_ids.join(',')}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
at least on EL8 this is not present by default.
given this is also used in disable_repos
which is old code, I guess we should add this to "EL8" todos, as it's not strictly related to this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, this won't be a factor until upgrades to 7.1 or upstream makes use of this. I'm fine with leaving as is and tackling later if we have a EL8 tracker somewhere to add this to?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is https://projects.theforeman.org/issues/27511 and Amit already added https://projects.theforeman.org/issues/33788 to it :)
I do think this is a good idea. This allows you to distinguish offline setups from setups. That said, you should still deal with the file missing in a way that it doesn't hard crash foreman_maintain. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see a few comments to address or resolve, so I will leave those to also be tackled. I think this looks good at the moment and is good to merge until we have all the repositories in place to test.
@upadhyeammit looks good! I think this can be squashed and merged. |
@ehelms there were few things I have handled in latest commit. The confine block is not working for the scenario out of the box, need to check what is missing for that. Accordingly as of now this scenario is limited using if condition in compose. And I will raise another pr to change it for PuppetDisable command as well. |
… instead of match?
@ehelms changes have been pushed, if there are no more comments then I will squash and merge. |
No description provided.