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 #4323 - Fix wrong result classes of service_ensure_stopped which are based on service_check_running() #26

Closed
wants to merge 19 commits into from
Closed

Fixes #4323 - Fix wrong result classes of service_ensure_stopped which are based on service_check_running() #26

wants to merge 19 commits into from

Conversation

nperron
Copy link
Contributor

@nperron nperron commented Jan 2, 2014

Fixes #4323 - Fix wrong result classes of service_ensure_stopped which are based on service_check_running()
cf http://www.rudder-project.org/redmine/issues/4323

@@ -42,10 +41,10 @@ bundle agent service_ensure_stopped(service_name)
ifvarclass => "service_check_running_${canonified_service_name}_ok";

"placeholder"
usebundle => _classes_copy("service_check_running_${canonified_service_name}", "service_ensure_stopped_${canonified_service_name}");
usebundle => _classes_inverted_copy("service_check_running_${canonified_service_name}", "service_ensure_stopped_${canonified_service_name}");
Copy link
Member

Choose a reason for hiding this comment

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

Note to self: we can't merge this unil the _classes_inverted_copy PR is merged (see #23).

Then, we will have to adapt this for the new name for that bundle.

@nperron
Copy link
Contributor Author

nperron commented Jan 9, 2014

Rebased from master and renamed from "_classes_inverted_copy" to ''_classes_copy_invert_kept_repaired"

@@ -42,10 +42,10 @@ bundle agent service_ensure_stopped(service_name)
ifvarclass => "service_check_running_${canonified_service_name}_ok";

"class copy check"
usebundle => _classes_copy("service_check_running_${canonified_service_name}", "${class_prefix}");
usebundle => _classes_copy_invert_kept_repaired("service_check_running_${canonified_service_name}", "${class_prefix");
Copy link
Member

Choose a reason for hiding this comment

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

I realize this was a pre-existing bug, but I want to discuss it now as I just saw it, and this may compromise this bundle: surely we should only do this _classes_copy if we have !service_check_running_${canonified_service_name}_ok?

Otherwise, in the case that !service_check_running_${canonified_service_name}_ok, there are two _classes_copy to the same destination class_prefix... That's got to be messed up, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After thinking about all of this, it appears to me that:

  • service_stop will only create repaired classes and never kept
  • the conditions service_check_running_${canonified_service_name}_ok are wrong as it will call class copy twice as you noticed and this is no good.

The logic should also be:

  • ifservice_check_running_${canonified_service_name}_repaired then no process exist, then we need to invert result class from repaired to kept
  • Otherwise if service_check_running_${canonified_service_name}_kept so some process(es) exist, and we will need to call service_stop. Then we will have to copy its result class repaired
    Do you agree ?

Copy link
Member

Choose a reason for hiding this comment

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

I agree with your logic.

I had never seen the service_check_running implementation, and am rather surprised that it only returns $(prefix)_{kept,repaired}. It doesn't seem right to me that "check running not ok" equates to "repaired", since no actions were taken. I suggest that we change this behaviour (probably to use {kept,error} instead, and hopefully to have all appropriate classes included prefixed ones, etc).

Therefore, I suggest that you change the current PR using only the service_check_running_${canonified_service_name}_ok class (and of course !service_check_running_${canonified_service_name}_ok when necessary).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Therefore, I suggest that you change the current PR using only the service_check_running_${canonified_service_name}ok class (and of course !service_check_running${canonified_service_name}_ok when necessary).

Ok, so if I understand well, I'll have to make a new PR to change the behavior of service_check_running in order to have an error instead of repaired after this PR ?

Copy link
Member

Choose a reason for hiding this comment

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

It would be good to open a bug at least, yes please.
Also I now realise I gave you the wrong class suffix in my previous comment, it should be _kept, not _Ok of course. Your acceptance tests should detect this.

@jooooooon
Copy link
Member

Aside from that one comment, this looks great.

@jooooooon
Copy link
Member

Actually, I just noticed that your commit also fixes http://www.rudder-project.org/redmine/issues/4322. Could you please include that in the commit? (Fixes #4322)

Nicolas Perron added 19 commits January 10, 2014 09:48
…change bundle _classes_inverted_copy() to handle error classes
…o '_classes_copy_invert_kept_repaired.cf', fix some comments, enhance tests and factorize code for class inversion
…reate_symlink_enforce' and add two wrapper bundles 'file_create_symlink' and 'file_create_symlink_force'
…d which are based on service_check_running() and remove useless variable about init.d command
…ist and copy class of 'service_stop' if process was detected.
@nperron
Copy link
Contributor Author

nperron commented Jan 10, 2014

Argg..i wanted to rebase the PR but i've completly broken it.

@nperron
Copy link
Contributor Author

nperron commented Jan 10, 2014

This PR is broken, i've opened another one: #29

@nperron nperron closed this Jan 10, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants