-
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 #50 - Clean all Qpid queues to zero #52
Conversation
definitions/features/qpid_queues.rb
Outdated
queues_cleared << qname | ||
end | ||
ensure | ||
queues_cleared |
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.
why the ensure block here?
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.
Oh..my bad.
I was thought of adding rescue..ensure block here as in clear(qname) method I am triggering a command.
I missed to add rescue block.
I will modify the code and update the 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.
The ensure
block doesn't probably work as you expect, try:
def foo
raise "Error"
rescue => e
"rescue"
ensure
"ensure"
end
foo
returns "rescue" not "ensure" - the ensure block doesn't have effect on return value
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.
Yes, your right.
Removed ensure block and added return value in rescue itself.
For return statement in ensure block, it was giving rubocop warning - 'Do not return from an ensure block'
6496532
to
6b01b9a
Compare
After real work testing, I would suggest to:
It seems we should delete only the persisted ones:
Since this is more a migration step, rather than pre-upgrade check, I suggest doing the updates above, but still not merging, until we distinguish between pre_upgrade checks and upgrade steps. |
def run | ||
with_spinner('clear qpid queues') do |spinner| | ||
total_queues_cleared = feature(:qpid_queues).clear_all | ||
spinner.update "[#{total_queues_cleared.length}] queues cleared.\ |
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.
the [14] queues cleared
would look better without []
, so it would be 14 queues cleared
71db180
to
9731a97
Compare
@iNecas , Due to this, on service start it is creating queues again and executing rerun check. |
definitions/features/qpid_queues.rb
Outdated
def available_qpid_queues | ||
output = qpid_config("list queue --show-property=name \ | ||
--show-property=autoDelete | awk '$2 ~ /False/{ print $1 }'") | ||
output ? output.split(' ') : [] |
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.
qpid_config(...).to_s.split(' ')
|
||
def run | ||
with_spinner('clear qpid queues') do |spinner| | ||
feature(:katello_service).make_stop(spinner, '--exclude qpidd') |
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.
We should remember the original state of the service, and start only if it was running before at the end. What about having something like this:
def make_stop(spinner, args) do
originally_runner_services = running_services
execute!("katello-service stop #{args}")
yield
ensure
execute!("katello-service start --only #{originally_running_services}")
end
definitions/features/qpid_queues.rb
Outdated
@@ -0,0 +1,47 @@ | |||
class Features::QpidQueues < ForemanMaintain::Feature |
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 think we could generalize this to qpid
feature, and collect mutliple functionalities around this feature in the future
@@ -92,6 +92,10 @@ def execute(command, options = {}) | |||
def shellescape(string) | |||
Shellwords.escape(string) | |||
end | |||
|
|||
def qpid_tools_installed? |
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.
Any reason not to put it into the qpid feature? The SystemHelpers
should contain only the more generic commands, usable across the definitions.
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.
No specific reason.
I have given QpidQueues
as a name of feature that's why I thought this might be needed for other features specific to qpid.
As per your above comment, I will change feature name as qpid
and will move this method to feature itself.
Yes, after https://github.com/iNecas/foreman_maintain/pull/67, this should go into |
9731a97
to
a64f022
Compare
def make_stop(spinner, args = '') | ||
originally_running_services = running_services | ||
spinner.update 'Stopping katello running services..' | ||
execute!("katello-service stop #{args}") |
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.
the args
could be called services
, so that we can work with it a bit better. After doing so, we can compare the running_services
with services
and:
- stop only
running_serivces & services
- skip this completely, if the services to be stopped are actually running.
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.
@iNecas ,
Could you please elaborate 2nd point as I am bit confuse here.
As you mentioned firstly I need to rename args as services
then
- Instead of passing exclude list of services, I have to pass services which needs to be stop.
- After that I need to compare
running_services
withservices
,
stop only services which are common in both list.
Please correct me.
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.
Oh, I'm missed there is the except
word used. In that case, what about having options
with possible keys :only
and :exclude
, but since we would have the list of currently running services, we would use only --only
option for the actual katello-service
and only in case we don't have an empty list.
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.
@iNecas ,
Yes, it will be better. As we have running_services
list value, we can include :only
and :exclude
option keys.
I will modify and update the PR.
a64f022
to
8dfcf1c
Compare
@iNecas , |
3827558
to
ae6d1bf
Compare
Modified success-info message to - |
I've raised some questions on mailing list if we want to make this step part of the upgrade scenario, as it can affect negatively the clients connected to the system. Perhaps we will need to do some additional queue restore, as described in https://access.redhat.com/solutions/3148641in "ONLY if you end up with broken content under /var/lib/qpidd and dont have a working backup" scenario. |
def make_stop(spinner, options = {}) | ||
services = find_services_for_only_filter(running_services, options) | ||
if services.empty? | ||
spinner.update 'No any running katello service..' |
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.
nitpick: no katello service running
def make_start(spinner, options = {}) | ||
services = find_services_for_only_filter(stopped_services, options) | ||
if services.empty? | ||
spinner.update 'No any katello service to start.' |
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.
ditto
#83 got merged. Please rebased. Basd on scrum call discussion, it would be good looking into queue re-creation part of the https://access.redhat.com/solutions/3148641 |
On top of https://access.redhat.com/solutions/3148641, we could perhaps just dump the list of queues before the cleanup and re-create the queues based on the list after deleting the queues. Thoughts @pmoravec ? |
Yes it makes sense - though IMHO only for upgrades where 2 possible ways how to identify the queues (just the
|
ae6d1bf
to
9e268de
Compare
@upadhyeammit, |
Closing this PR as the changes are not required now |
No description provided.