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 #30120 - Added check-update option in foreman-maintain #355

Merged

Conversation

patilsuraj767
Copy link
Contributor

$ yum check-update
Loaded plugins: foreman-protector, product-id, search-disabled-repos, subscription-manager

WARNING: Excluding 12529 packages due to foreman-protector. 
Use foreman-maintain packages install/update <package> 
to safely install packages without restrictions.
Use foreman-maintain upgrade run for full upgrade.
$ ./bin/foreman-maintain packages check-update
Running Check for available package updates
================================================================================
Check for available package updates: 
Loaded plugins: product-id, search-disabled-repos, subscription-manager

microcode_ctl.x86_64                 2:2.1-61.6.el7_8         rhel-7-server-rpms
tomcat.noarch                        7.0.76-12.el7_8          rhel-7-server-rpms
tomcat-el-2.2-api.noarch             7.0.76-12.el7_8          rhel-7-server-rpms
tomcat-jsp-2.2-api.noarch            7.0.76-12.el7_8          rhel-7-server-rpms
tomcat-lib.noarch                    7.0.76-12.el7_8          rhel-7-server-rpms
tomcat-servlet-3.0-api.noarch        7.0.76-12.el7_8          rhel-7-server-rpms
                                                                      [OK]
--------------------------------------------------------------------------------

@theforeman-bot
Copy link
Member

Issues: #30120

Copy link
Member

@kgaikwad kgaikwad left a comment

Choose a reason for hiding this comment

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

Thank you @patilsuraj767
Looks good to me! Added small inline comment.

yum_options = []
packages = [packages].flatten(1)
yum_options << '-y' if assumeyes
yum_options << '--disableplugin=foreman-protector'
Copy link
Member

Choose a reason for hiding this comment

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

Will this option be only for check_update?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, this option will for all the yum related task.
With "--disableplugin=foreman-protector" in place there is no need to unlock package while performing yum related task.
We will need to revisit all the commands/scenarios where we are doing yum related task and will need to remove the step Procedures::Packages::UnlockVersions For example - While installing package - code.
I think we should do above refactoring in separate PR.

Copy link
Member

Choose a reason for hiding this comment

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

I think we should do above refactoring in separate PR.

Could you please create one refactoring issue for tracking this change?

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 have opened the issue for refactoring - #30393

Copy link
Contributor

Choose a reason for hiding this comment

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

It works as expected. I am not liking the idea of hardcoding --disableplugin=foreman-protector in yum_options. I still prefer the method to unlock packages and lock it again; as this feels like hack.
Maybe if we want to save the extra logic of disable and enable plugin which has written in setup_protector ? you can override yum_options in setup_protector itself ?
With this we should change the description of check-update command to,

check-update    Check for available package updates in unlocked session

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 am not sure how we can override the yum_options in setup_protector, because currently yum_option variable is scoped for def yum_action.

Let me tell you why I think '--disableplugin=foreman-protector' is better option.

a) I did not found any scenario where we do yum action without unlocking packages(disabling foreman-protector) plugin.
b) In the current code, I think there are two scenarios where foreman-maintain can leave packages in the unlocked state.

  1. If you see the implementation here -
    add_step_with_context(Procedures::Packages::UnlockVersions)
    (or any other scenario). So we are unlocking the packages but there can be the times that foreman-maintain fails or user can force terminate the process (ctrl +c). In this case, foreman-maintain will leave packages in unlocked state.
  2. We are not explicitly locking the packages in any scenario, rather we are relying on foreman-installer, thinking that it will do the job of locking the packages but what if the installer fails in between? then the package will still stay in the unlocked state.

Using the --disableplugin=foreman-protector will make sure that the package will not be in unlock state ever.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, with this fix, we can get rid of this kind of issues - #30414.

@kgaikwad
Copy link
Member

No additional comments from my side.
@upadhyeammit, do you have any additional comments?
@jameerpathan111, it would be good to have testing around this new command.

@kgaikwad
Copy link
Member

As per offline discussion, I have tested by passing invalid plugin name.
Example - yum install mlocate --disableplugin=xyz
It gives output with a message No plugin match for: xyz. But command returns exit code based on package action,

[foreman_maintain]# yum install mlocate --disableplugin=xyz
Loaded plugins: product-id, search-disabled-repos, subscription-manager
No plugin match for: xyz
Package mlocate-0.26-8.el7.x86_64 already installed and latest version
Nothing to do
[foreman_maintain]# echo $?
0

[foreman_maintain]# yum install fhfh --disableplugin=xyz
Loaded plugins: product-id, search-disabled-repos, subscription-manager
No plugin match for: xyz
No package fhfh available.
Error: Nothing to do
[foreman_maintain]# echo $?
1

@upadhyeammit
Copy link
Contributor

@jameerpathan111 or @vsedmik can you help to test this change ? Most important is, with this change packages wont be unlocked while doing packages actions from foreman-maintain.

@jameerpathan111
Copy link
Contributor

@jameerpathan111 or @vsedmik can you help to test this change ?

yeah, sure. will take a look at it this week.

@upadhyeammit
Copy link
Contributor

Tested on latest versions and works without any problem. Merging!

@upadhyeammit upadhyeammit merged commit c03fa70 into theforeman:master Jul 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants