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 #7192: Rewrite the service_* methods #544

Conversation

amousset
Copy link
Member

@amousset
Copy link
Member Author

amousset commented Feb 28, 2017

Still being tested, but the implementation should be complete now.

classes:
# This method can be called as a substitution if service_ensure_running is called directly, with service_path=service_name
# In this case, we don't need to call service_check_running_ps but can use better OS-specific methods if available
"real_path" not => strcmp("${service_name}", "${service_path}");
Copy link
Member Author

@amousset amousset Feb 28, 2017

Choose a reason for hiding this comment

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

This is an incompatible change, but I see previous behavior like a bug more than a feature...

@amousset amousset force-pushed the arch_7192/rewrite_the_service_methods_to_benefit_from_the_power_of_the_new_aggregation_methods_from_7171 branch from ecceed9 to f8082a1 Compare February 28, 2017 12:02
@amousset
Copy link
Member Author

Commit modified

1 similar comment
@amousset
Copy link
Member Author

Commit modified

@amousset amousset force-pushed the arch_7192/rewrite_the_service_methods_to_benefit_from_the_power_of_the_new_aggregation_methods_from_7171 branch from f8082a1 to ee82423 Compare February 28, 2017 13:29
debian_8::
# This is to workaround a bug in Debian Jessie, that makes systemctl is-enabled
# fail if run against a service that still uses SysV style scripts
# See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760616
Copy link
Member

Choose a reason for hiding this comment

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

This bug was marked as fixed on 29/05/2015, is it still relevant to keep this exception ?

Copy link
Member Author

Choose a reason for hiding this comment

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

It seems it was only fixed in unstable, and not in stable (by a systemd upgrade).

@@ -62,14 +63,17 @@ bundle agent service_ensure_stopped(service_name)
usebundle => _classes_copy("${class_prefix}_stop_if_running", "${class_prefix}"),
ifvarclass => "has_promiser_stack.${class_prefix}_check_running_kept";

windows::
"action" usebundle => service_stop("${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.

why not keeping the windows service code there ?

@amousset
Copy link
Member Author

Commit modified

@amousset amousset force-pushed the arch_7192/rewrite_the_service_methods_to_benefit_from_the_power_of_the_new_aggregation_methods_from_7171 branch from ee82423 to 40b05e8 Compare February 28, 2017 13:53
@amousset
Copy link
Member Author

Replaced command_execution and commands promise by returnszero. Allows:

  • Avoiding useless or misleading reports from log_default
  • Avoiding the systemd workaround

# Set variables with the error
# Test behavior with unkown action
# is-active not implemented for service/init.d
bundle agent ncf_services(service, action)
Copy link
Member

Choose a reason for hiding this comment

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

If i understand correctly, it will mostly return "repair" outcome, am I right ?

"${configuration.error} The ${action} action is not supported on Windows (use 'start', 'stop' or 'restart')";

pass3.info.method_found.(!windows|is_valid_action)::
"${configuration.info} Executing ${action} on ${service} using the ${method} method";
Copy link
Member

Choose a reason for hiding this comment

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

great

@@ -75,14 +67,17 @@ bundle agent service_ensure_running_path(service_name, service_path)
usebundle => _classes_success("${old_class_prefix}"),
ifvarclass => "(real_path.service_check_running_${canonified_service_path}_kept)|(!real_path.service_check_running_${canonified_service_name}_kept)";

windows::
Copy link
Member

Choose a reason for hiding this comment

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

Why not keeping this as a servies: promise type ?

ifvarclass => "service_check_started_at_boot_${canonified_service_name}_not_ok";

"copy classes"
usebundle => _classes_copy("${class_prefix}_define_at_boot", "${class_prefix}"),
ifvarclass => "${class_prefix}_check_at_boot_not_ok";

windows::
Copy link
Member

Choose a reason for hiding this comment

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

why not keeping this one also ?

@amousset
Copy link
Member Author

Commit modified

@amousset amousset force-pushed the arch_7192/rewrite_the_service_methods_to_benefit_from_the_power_of_the_new_aggregation_methods_from_7171 branch 2 times, most recently from cf762a1 to 8633500 Compare February 28, 2017 14:33
@amousset
Copy link
Member Author

Commit modified

1 similar comment
@amousset
Copy link
Member Author

Commit modified

@amousset amousset force-pushed the arch_7192/rewrite_the_service_methods_to_benefit_from_the_power_of_the_new_aggregation_methods_from_7171 branch from 8633500 to c9cda8f Compare February 28, 2017 14:45
@amousset
Copy link
Member Author

Commit modified

@amousset amousset force-pushed the arch_7192/rewrite_the_service_methods_to_benefit_from_the_power_of_the_new_aggregation_methods_from_7171 branch from c9cda8f to 7aafd2d Compare February 28, 2017 14:52
@amousset
Copy link
Member Author

Commit modified

@amousset amousset force-pushed the arch_7192/rewrite_the_service_methods_to_benefit_from_the_power_of_the_new_aggregation_methods_from_7171 branch from 7aafd2d to 6f01242 Compare February 28, 2017 14:55
@amousset
Copy link
Member Author

Commit modified

@amousset amousset force-pushed the arch_7192/rewrite_the_service_methods_to_benefit_from_the_power_of_the_new_aggregation_methods_from_7171 branch 2 times, most recently from 5a65e0a to bc9de88 Compare February 28, 2017 17:01
@amousset
Copy link
Member Author

Commit modified

#####
pass2.is_check_action.!windows.!is_process_action.method_found.action_ok::
"force_success_class" usebundle => _classes_success("${old_class_prefix}");
"force_success_class" usebundle => _classes_success("${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.

we should have _classes_success_two (or equivalent) (this is not the place of this PR thought)

@amousset
Copy link
Member Author

amousset commented Mar 1, 2017

Commit modified

@amousset amousset force-pushed the arch_7192/rewrite_the_service_methods_to_benefit_from_the_power_of_the_new_aggregation_methods_from_7171 branch from bd7e014 to d8cf46e Compare March 1, 2017 11:43
@amousset
Copy link
Member Author

amousset commented Mar 1, 2017

Changed the way to handle service ${service status as modifying the action breaks reporting.

@amousset
Copy link
Member Author

amousset commented Mar 1, 2017

Commit modified

@amousset amousset force-pushed the arch_7192/rewrite_the_service_methods_to_benefit_from_the_power_of_the_new_aggregation_methods_from_7171 branch from d8cf46e to f18cb97 Compare March 1, 2017 11:45
@amousset
Copy link
Member Author

amousset commented Mar 1, 2017

Failing tests:

  • ./30_generic_methods/service_check_started_at_boot.cf
  • ./30_generic_methods/unsafe/service_check_disabled_at_boot.cf

@amousset
Copy link
Member Author

amousset commented Mar 1, 2017

Commit modified

@amousset amousset force-pushed the arch_7192/rewrite_the_service_methods_to_benefit_from_the_power_of_the_new_aggregation_methods_from_7171 branch from f18cb97 to a148e98 Compare March 1, 2017 12:09
@amousset
Copy link
Member Author

amousset commented Mar 1, 2017

TODO:

  • Real tests that enforce state in init and check actual service status in test
  • Document the way services are handled, possible options, etc.
  • Document the (small) behavior changes

@amousset
Copy link
Member Author

amousset commented Mar 1, 2017

Also missing proper upstart support.

@amousset
Copy link
Member Author

amousset commented Mar 1, 2017

Commit modified

@amousset amousset force-pushed the arch_7192/rewrite_the_service_methods_to_benefit_from_the_power_of_the_new_aggregation_methods_from_7171 branch from a148e98 to 166364e Compare March 1, 2017 15:08
@amousset
Copy link
Member Author

amousset commented Mar 1, 2017

Commit modified

@amousset amousset force-pushed the arch_7192/rewrite_the_service_methods_to_benefit_from_the_power_of_the_new_aggregation_methods_from_7171 branch from 166364e to 76c2673 Compare March 1, 2017 15:12
@amousset
Copy link
Member Author

amousset commented Mar 1, 2017

Currently failing on Ubuntu 14.04:

  • ./30_generic_methods/service_check_started_at_boot.cf FAIL
  • ./30_generic_methods/unsafe/service_ensure_running_start.cf FAIL

@ncharles
Copy link
Member

ncharles commented Mar 1, 2017

I'd like to point out that on master branch, the tests

  • service_start,

  • service_check_disabled_at_boot.cf,

  • service_check_running_ps.cf

  • service_check_started_at_boot.cf
    are failing

@amousset
Copy link
Member Author

amousset commented Mar 1, 2017

Commit modified

@amousset amousset force-pushed the arch_7192/rewrite_the_service_methods_to_benefit_from_the_power_of_the_new_aggregation_methods_from_7171 branch from 76c2673 to bd57e32 Compare March 1, 2017 16:41
@amousset
Copy link
Member Author

amousset commented Mar 1, 2017

Added upstart support!

@amousset amousset force-pushed the arch_7192/rewrite_the_service_methods_to_benefit_from_the_power_of_the_new_aggregation_methods_from_7171 branch from bd57e32 to 3fbda7e Compare March 1, 2017 16:58
@amousset
Copy link
Member Author

amousset commented Mar 1, 2017

Commit modified

"upstart_action_cmd[reload]" string => "/sbin/initctl reload ${service}";
"upstart_action_cmd[is-active]" string => "/sbin/initctl status ${service} | grep -q ' start/'";
# boot
"upstart_action_cmd[enable]" string => "${paths.path[sed]} -i '/manual/d' /etc/init/${service}.override";
Copy link
Member

Choose a reason for hiding this comment

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

this sed is not anchored, would it be an issue ?

@amousset
Copy link
Member Author

amousset commented Mar 1, 2017

Commit modified

@amousset amousset force-pushed the arch_7192/rewrite_the_service_methods_to_benefit_from_the_power_of_the_new_aggregation_methods_from_7171 branch from 3fbda7e to 56ee829 Compare March 1, 2017 17:03
@amousset
Copy link
Member Author

amousset commented Mar 1, 2017

Commit modified

@amousset amousset force-pushed the arch_7192/rewrite_the_service_methods_to_benefit_from_the_power_of_the_new_aggregation_methods_from_7171 branch from 56ee829 to 86c2e96 Compare March 1, 2017 17:09
@Normation-Quality-Assistant
Copy link
Contributor

OK, merging this PR

@Normation-Quality-Assistant Normation-Quality-Assistant merged commit 86c2e96 into Normation:master Mar 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants