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 #26050 - yum exclude list #244

Merged
merged 6 commits into from
May 22, 2019

Conversation

upadhyeammit
Copy link
Contributor

This adds check for yum exclude list, if its configured then user gets error with message. The message includes which file has configured it and what is value of same.

@theforeman-bot
Copy link
Member

Issues: #25939

@mbacovsky
Copy link
Member

@upadhyeammit is the right issue linked to the PR. Shouldn't it be https://projects.theforeman.org/issues/26050?

@upadhyeammit upadhyeammit changed the title Fixes #25939 - yum exclude list Fixes #26050 - yum exclude list Feb 14, 2019
@upadhyeammit
Copy link
Contributor Author

@mbacovsky my mistake :( changed it ! Thank You !

@jameerpathan111
Copy link
Contributor

@upadhyeammit I have tested this pr and found below issue.

  • I have added exclude=kernel* abc* in /etc/yum.conf,
    the check fails as expected but the issue is that it doesn't show complete list.
    I think we should change grep -w exclude in such a way that we can get complete list.
--------------------------------------------------------------------------------
Check if yum exclude list is configured:                              [FAIL]
The /etc/yum.conf has exclude list configured as below,
  exclude = kernel*,
Unset this as it can cause yum update or upgrade failures !
--------------------------------------------------------------------------------

@upadhyeammit
Copy link
Contributor Author

@jameerpathan111 I switched to yum.conf which is fixing your concern. Request to check.
Thank You !

@upadhyeammit
Copy link
Contributor Author

@jameerpathan111 I can see one more issue with this pr, if yum.conf not having exclude defined it will fail ! The yum-config-manager use to help with this situation, I am checking this one further.

@iNecas
Copy link
Member

iNecas commented May 2, 2019

What is the status here?

@upadhyeammit
Copy link
Contributor Author

What is the status here?

From my side work is complete, when we had last meeting @mbacovsky mentioned that this may need changes because of version lock PR .

@iNecas
Copy link
Member

iNecas commented May 17, 2019

@mbacovsky mind having a look?

Copy link
Member

@mbacovsky mbacovsky left a comment

Choose a reason for hiding this comment

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

@upadhyeammit I did some more testing and it behaves almost as expected. However I took me quite some time to understand why. I've suggested some changes inside.

As for our discussion on using the package manager layer - I don't think we need to do that now. The functionality is nicely bundled in one file and I have no idea how excluding of packages works in Debian world so I guess it would slip this for too long. What do you think?

end

def run
assert(exclude_set?, 'The /etc/yum.conf has exclude list configured as below,'\
Copy link
Member

Choose a reason for hiding this comment

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

I assumed from the exclude_set? name that it would return true if exclude is set in yum but it does the opposite. That confused me a lot. How about exclude_unset? or !exclude_used? or similar? Or did I miss something?

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 changed it to return true when exclude is set, sorry for confusion !

end

def exclude_set?
yum_exclude == 'exclude=' || yum_exclude == 'exclude ='
Copy link
Member

Choose a reason for hiding this comment

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

This call the grep twice in many cases and misses e.g. '# exclude=kernel*'. Could we use regexp instead like

yum_exclude =~ /^exclude\s*=\s*\S+/

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 changed this to regular expression, miss from my side about commented exclude line.

def yum_exclude
execute!('grep -w exclude /etc/yum.conf')
rescue ForemanMaintain::Error::ExecutionError
'exclude='
Copy link
Member

Choose a reason for hiding this comment

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

This feels quite hacky, could we return empty string here?
Perhaps we could call the method grep_yum_exclude to see better what it does.

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 changed the method name and now using execute_with_status which returns empty string when exclude is not set.

@upadhyeammit
Copy link
Contributor Author

@upadhyeammit I did some more testing and it behaves almost as expected. However I took me quite some time to understand why. I've suggested some changes inside.

As for our discussion on using the package manager layer - I don't think we need to do that now. The functionality is nicely bundled in one file and I have no idea how excluding of packages works in Debian world so I guess it would slip this for too long. What do you think?

I am also not familiar with how Debian handles excluding packages, I would explore on it but now what I feel is we should merge this for yum after taking care of suggestions added by you. I will check for Debian side and would be including it next.

@theforeman-bot
Copy link
Member

There were the following issues with the commit message:

  • bfc0cf1 must be in the format fixes #redmine_number - brief description

If you don't have a ticket number, please create an issue in Redmine.

More guidelines are available in Coding Standards or on the Foreman wiki.


This message was auto-generated by Foreman's prprocessor

@upadhyeammit
Copy link
Contributor Author

@mbacovsky with recent commit only thing is we call grep twice when exclude is set, I was trying to avoid it but it was unnecessarily adding more lines to check and I feel one extra grep command call should not be that expensive. Request to review once ! thank you !

@mbacovsky
Copy link
Member

@upadhyeammit thank you for the update and incorporating my comments. I checked on the PR and it looks good. However I'm still not very convinced about the unnecessary double grep call in the check (the execution is logged twice, new subshell is executed etc) so I'm sorry but I'd appreciate if we can get rid of it. Could you please reconsider it?

@upadhyeammit
Copy link
Contributor Author

@upadhyeammit thank you for the update and incorporating my comments. I checked on the PR and it looks good. However I'm still not very convinced about the unnecessary double grep call in the check (the execution is logged twice, new subshell is executed etc) so I'm sorry but I'd appreciate if we can get rid of it. Could you please reconsider it?

No problem at all, will send fix for same ! thank you for review

@upadhyeammit
Copy link
Contributor Author

@mbacovsky did changes as requested, thank you for help ! Request to have a look

@mbacovsky
Copy link
Member

@upadhyeammit thank you for the update, I really appreciate it. I'll merge this once the tests finish and are green.

@upadhyeammit
Copy link
Contributor Author

@upadhyeammit thank you for the update, I really appreciate it. I'll merge this once the tests finish and are green.

ack! Travis was failing due to freeze for regex, I removed it and it should be green now!

@mbacovsky
Copy link
Member

Thanks again @upadhyeammit!

@mbacovsky mbacovsky merged commit 4ed4592 into theforeman:master May 22, 2019
@upadhyeammit upadhyeammit deleted the 26050-yum_exclude branch December 3, 2021 12:05
This pull request was closed.
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.

5 participants