Uploaded image for project: 'CFEngine Community'
  1. CFEngine Community
  2. CFE-1301

standard_services invoking repairs, when it is not repairing anything

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Done
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.6.0
    • Component/s: Evaluation
    • Labels:
      None
    • Platform:
      Any

      Description

      I have the following bundle:

      <pre>
      194 bundle agent enable_runit_service(runit_service)
      195

      { 196 classes: 197 "no_state_administration" expression => fileexists("/etc/cfe.d/no_cfe_state_administration"); 198 199 files: 200 "/etc/runit/service/$(runit_service)/." 201 handle => "runit_services_administration_etc_runit_service_runit_services", 202 create => "true", 203 perms => mog("0755","root","root"), 204 classes => if_repaired("$(runit_service)_service_modified"); 205 206 "/etc/runit/service/$(runit_service)/log/." 207 handle => "runit_services_administration_etc_runit_service_runit_services_log", 208 create => "true", 209 perms => mog("0755","root","root"), 210 classes => if_repaired("$(runit_service)_service_modified"); 211 212 "/etc/runit/service/$(runit_service)/log/main/." 213 handle => "runit_services_administration_etc_runit_service_runit_services_log_main", 214 create => "true", 215 perms => mog("0755","logger","logger"), 216 classes => if_repaired("$(runit_service)_service_modified"); 217 218 "/etc/runit/service/$(runit_service)/log/main/current" 219 handle => "runit_services_administration_etc_runit_service_runit_services_log_main_current", 220 create => "true", 221 perms => mog("0644","logger","logger"), 222 classes => if_repaired("$(runit_service)_service_modified"); 223 224 "/export/service/$(runit_service)" 225 handle => "link_export_service_runit_services_administration", 226 link_from => ln_s("/etc/runit/service/$(runit_service)"), 227 classes => if_repaired("$(runit_service)_service_modified"); 228 229 "/etc/runit/service/$(runit_service)/run" 230 handle => "runit_services_administration_etc_runit_service_runit_services_run", 231 perms => mog("0755","root","root"), 232 copy_from => backup_cp_md5_compare("/var/cfengine/inputs/config-general/runit_services_administration/$(runit_service)_run"), 233 classes => if_repaired("$(runit_service)_service_modified"); 234 235 "/etc/runit/service/$(runit_service)/log/run" 236 handle => "_etc_runit_service_runit_services_log_run", 237 perms => mog("0755","root","root"), 238 copy_from => backup_cp_md5_compare("/var/cfengine/inputs/config-general/runit_services_administration/$(runit_service)_log_run"), 239 classes => if_repaired("$(runit_service)_service_modified"); 240 241 services: 242 !no_state_administration:: 243 "$(runit_service)" 244 handle => "runit_services_administration_start_runit_service", 245 service_policy => "start", 246 classes => if_repaired("$(runit_service)_service_modified"); 247 248 reports: 249 cfengine_3:: 250 "cf3: The service /export/service/$(runit_service) was modified on $(sys.host)" 251 ifvarclass => "$(runit_service)_service_modified"; 252 253 }

      </pre>

      This invokes standard_services.cf via the services promise. Here's an example of a single service, bittorrent_tracker.

      <pre>
      bundle agent standard_services(service, state)
      {
      vars:
      any::
      "cm_conf" string => "/etc/cm.conf";
      "sv" string => "/sbin/sv";
      "servicedir" string => "/export/service";

      linux::
      "initdir" string => "/etc/init.d/";
      "chkconfig" string => "/sbin/chkconfig";

      "startcommand[bittorrent_tracker]" string => "$(sv) up $(servicedir)/bittorrent_tracker";
      "stopcommand[bittorrent_tracker]" string => "$(sv) down $(servicedir)/bittorrent_tracker";
      "processname[bittorrent_tracker]" string => "bttrack.py --dfile /export/content/bittorrent/bittorrent_tracker/data --port 6889 --logfile -";

      classes:
      any::
      "start" expression => strcmp("start","$(state)");
      "stop" expression => strcmp("stop","$(state)");

      linux.start::
      "$(service)_chkconfig_on" expression =>
      returnszero("$(chkconfig) $(chkconfig_name[$(service)]) --list | cut -f5 | grep off > /dev/null 2>&1","useshell");

      linux.stop::
      "$(service)_chkconfig_off" expression =>
      returnszero("$(chkconfig) $(chkconfig_name[$(service)]) --list | cut -f5 | grep on > /dev/null 2>&1","useshell");

      redhat_6::
      "mcelogd_lock_file_exists" expression => fileexists("/var/lock/subsys/mcelogd");

      processes:
      start::
      ".$(processname[$(service)])."
      comment => "standard_services.cf Verify that the service appears in the process table",
      restart_class => "restart_$(service)";
      stop::
      ".$(processname[$(service)])."
      comment => "standard_services.cf Verify that the service does not appear in the process table",
      process_stop => "$(stopcommand[$(service)])",
      signals =>

      { "term", "kill"}

      ;
      commands:
      any::
      "$(startcommand[$(service)])"
      comment => "standard_services.cf Execute command to restart the $(service) service",
      ifvarclass => "restart_$(service)";

      linux::
      "$(chkconfig) $(chkconfig_name[$(service)]) on"
      comment => "standard_services.cf Execute chkconfig on to enable service on bootstart",
      ifvarclass => "$(service)_chkconfig_on";

      linux::
      "$(chkconfig) $(chkconfig_name[$(service)]) off"
      comment => "standard_services.cf Execute chkconfig off to disable service on bootstart",
      ifvarclass => "$(service)_chkconfig_off";

      files:
      any::
      "$(cm_conf)"
      handle => "insert_service_started_cm_conf",
      edit_line => append_if_no_line("$(sys.cdate):$(service) offline. Cfengine starting process."),
      ifvarclass => "restart_$(service)";

      any::
      "$(cm_conf)"
      handle => "insert_chkconfig_enabled_cm_conf",
      edit_line => append_if_no_line("$(sys.cdate):$(service) disabled on bootstart. Cfengine enabling."),
      ifvarclass => "$(service)_chkconfig_on";
      any::
      "$(cm_conf)"
      handle => "insert_chkconfig_disabled_cm_conf",
      edit_line => append_if_no_line("$(sys.cdate):$(service) enabled on bootstart. Cfengine disabling."),
      ifvarclass => "$(service)_chkconfig_off";

      1. mcelogd doesn't clean up its lock file very well. If we see that we have to restart the daemon because its not running
      2. but the lock file exists, then clean up the file. This will allow mcelog to actually start.
        restart_mcelog.mcelogd_lock_file_exists::
        "/var/lock/subsys/mcelogd"
        handle => "purge_mcelogd_lock_file",
        delete => tidy;

      reports:
      cfengine_3::
      "cf3: Service $(service) started on $(sys.host)"
      ifvarclass => "restart_$(service)";

      cfengine_3::
      "cf3: Service $(service) found disabled on bootstart when it should be enabled. Executing $(chkconfig) $(chkconfig_name[$(service)]) on"
      ifvarclass => "$(service)_chkconfig_on";

      cfengine_3::
      "cf3: Service $(service) found enabled on bootstart when it should be disabled. Executing $(chkconfig) $(chkconfig_name[$(service)]) off"
      ifvarclass => "$(service)_chkconfig_off";
      }

      </pre>

      Every time this policy fires, its raising the class "bittorrent_tracker_service_modified" on line 251 in the policy enable_runit_services. This causes the service to be restarted every execution.

      <pre>
      [root@esv4-cfe-test msvoboda]# /var/cfengine/bin/cf-agent -I -K -b mps_bittorrent_tracker
      2014-03-27T08:25:35-0700 info: Using command line specified bundlesequence
      R: cf3: The service /export/service/bittorrent_tracker was modified on esv4-cfe-test.corp
      R: cf3: The service /export/service/bittorrent_solaris_seeder was modified on esv4-cfe-test.corp
      R: cf3: The service /export/service/bittorrent_linux_seeder was modified on esv4-cfe-test.corp
      2014-03-27T08:25:45-0700 info: /default/mps_bittorrent_tracker/commands/'/sbin/sv restart /export/service/bittorrent_tracker'[0]: Executing 'no timeout' ... '/sbin/sv restart /export/service/bittorrent_tracker'
      2014-03-27T08:25:47-0700 notice: /default/mps_bittorrent_tracker/commands/'/sbin/sv restart /export/service/bittorrent_tracker'[0]: Q: ".../sbin/sv restar": ok: run: /export/service/bittorrent_tracker: (pid 11328) 0s

      2014-03-27T08:25:47-0700 info: /default/mps_bittorrent_tracker/commands/'/sbin/sv restart /export/service/bittorrent_tracker'[0]: Last 1 quoted lines were generated by promiser '/sbin/sv restart /export/service/bittorrent_tracker'
      2014-03-27T08:25:47-0700 info: /default/mps_bittorrent_tracker/commands/'/sbin/sv restart /export/service/bittorrent_tracker'[0]: Completed execution of '/sbin/sv restart /export/service/bittorrent_tracker'
      2014-03-27T08:25:47-0700 info: /default/mps_bittorrent_tracker/commands/'/var/cfengine/modules/master_policy_servers/mps_usr_local_linkedin_crawler.py'[0]: Executing 'no timeout' ... '/var/cfengine/modules/master_policy_servers/mps_usr_local_linkedin_crawler.py'
      2014-03-27T08:25:48-0700 info: /default/mps_bittorrent_tracker/commands/'/var/cfengine/modules/master_policy_servers/mps_usr_local_linkedin_crawler.py'[0]: Completed execution of '/var/cfengine/modules/master_policy_servers/mps_usr_local_linkedin_crawler.py'
      [root@esv4-cfe-test msvoboda]#
      [root@esv4-cfe-test msvoboda]#
      [root@esv4-cfe-test msvoboda]#
      [root@esv4-cfe-test msvoboda]#
      [root@esv4-cfe-test msvoboda]#
      [root@esv4-cfe-test msvoboda]#
      [root@esv4-cfe-test msvoboda]# /var/cfengine/bin/cf-agent -I -K -b mps_bittorrent_tracker
      2014-03-27T08:25:53-0700 info: Using command line specified bundlesequence
      R: cf3: The service /export/service/bittorrent_tracker was modified on esv4-cfe-test.corp
      R: cf3: The service /export/service/bittorrent_solaris_seeder was modified on esv4-cfe-test.corp
      R: cf3: The service /export/service/bittorrent_linux_seeder was modified on esv4-cfe-test.corp
      2014-03-27T08:26:02-0700 info: /default/mps_bittorrent_tracker/commands/'/sbin/sv restart /export/service/bittorrent_tracker'[0]: Executing 'no timeout' ... '/sbin/sv restart /export/service/bittorrent_tracker'
      2014-03-27T08:26:04-0700 notice: /default/mps_bittorrent_tracker/commands/'/sbin/sv restart /export/service/bittorrent_tracker'[0]: Q: ".../sbin/sv restar": ok: run: /export/service/bittorrent_tracker: (pid 11588) 0s

      2014-03-27T08:26:04-0700 info: /default/mps_bittorrent_tracker/commands/'/sbin/sv restart /export/service/bittorrent_tracker'[0]: Last 1 quoted lines were generated by promiser '/sbin/sv restart /export/service/bittorrent_tracker'
      2014-03-27T08:26:04-0700 info: /default/mps_bittorrent_tracker/commands/'/sbin/sv restart /export/service/bittorrent_tracker'[0]: Completed execution of '/sbin/sv restart /export/service/bittorrent_tracker'
      2014-03-27T08:26:04-0700 info: /default/mps_bittorrent_tracker/commands/'/var/cfengine/modules/master_policy_servers/mps_usr_local_linkedin_crawler.py'[0]: Executing 'no timeout' ... '/var/cfengine/modules/master_policy_servers/mps_usr_local_linkedin_crawler.py'
      2014-03-27T08:26:06-0700 info: /default/mps_bittorrent_tracker/commands/'/var/cfengine/modules/master_policy_servers/mps_usr_local_linkedin_crawler.py'[0]: Completed execution of '/var/cfengine/modules/master_policy_servers/mps_usr_local_linkedin_crawler.py'

      </pre>

      Putting this into verbose mode:

      <pre>
      Evaluating promise 'cf3: Service $(service) started on $(sys.host)'
      Service bittorrent_tracker started on esv4-cfe-test.corp'[0]: . . . . . . . . . . . . . . . . . . . . . . . . . . . .
      Service bittorrent_tracker started on esv4-cfe-test.corp'[0]: Skipping whole next promise (cf3: Service $(service) started on $(sys#host)), as ifvarclass restart_bittorrent_tracker is not relevant
      Service bittorrent_tracker started on esv4-cfe-test.corp'[0]: . . . . . . . . . . . . . . . . . . . . . . . . . . . .
      Evaluating promise 'cf3: Service $(service) found disabled on bootstart when it should be enabled. Executing $(chkconfig) $(chkconfig_name[$(service)]) on'
      Service bittorrent_tracker found disabled on bootstart when it should be enabled. Executing /sbin/chkconfig $(chkconfig_name[bittorrent_tracker]) on'[0]: . . . . . . . . . . . . . . . . . . . . . . . . . . . .
      Service bittorrent_tracker found disabled on bootstart when it should be enabled. Executing /sbin/chkconfig $(chkconfig_name[bittorrent_tracker]) on'[0]: Skipping whole next promise (cf3: Service $(service) found disabled on bootstart when it should be enabled. Executing $(chkconfig) $(chkconfig_name[$(service)]) on), as ifvarclass bittorrent_tracker_chkconfig_on is not relevant
      Service bittorrent_tracker found disabled on bootstart when it should be enabled. Executing /sbin/chkconfig $(chkconfig_name[bittorrent_tracker]) on'[0]: . . . . . . . . . . . . . . . . . . . . . . . . . . . .
      Evaluating promise 'cf3: Service $(service) found enabled on bootstart when it should be disabled. Executing $(chkconfig) $(chkconfig_name[$(service)]) off'
      Service bittorrent_tracker found enabled on bootstart when it should be disabled. Executing /sbin/chkconfig $(chkconfig_name[bittorrent_tracker]) off'[0]: . . . . . . . . . . . . . . . . . . . . . . . . . . . .
      Service bittorrent_tracker found enabled on bootstart when it should be disabled. Executing /sbin/chkconfig $(chkconfig_name[bittorrent_tracker]) off'[0]: Skipping whole next promise (cf3: Service $(service) found enabled on bootstart when it should be disabled. Executing $(chkconfig) $(chkconfig_name[$(service)]) off), as ifvarclass bittorrent_tracker_chkconfig_off is not relevant
      Service bittorrent_tracker found enabled on bootstart when it should be disabled. Executing /sbin/chkconfig $(chkconfig_name[bittorrent_tracker]) off'[0]: . . . . . . . . . . . . . . . . . . . . . . . . . . . .
      Bundle Accounting Summary for 'standard_services'
      Promises kept in 'standard_services' = 1
      Promises not kept in 'standard_services' = 0
      Promises repaired in 'standard_services' = 0
      Aggregate compliance (promises kept/repaired) for bundle 'standard_services' = 100.0%
      Additional promise info: handle 'runit_services_administration_start_runit_service' source path '/var/cfengine/inputs/runit_services_administration.cf' at line 243
      Method 'standard_services' invoked repairs
      Defining promise result class 'bittorrent_tracker_service_modified'
      </pre>

        Attachments

          Activity

            People

            • Assignee:
              a10025 Volker Hilsheimer (Inactive)
              Reporter:
              msvoboda@linkedin.com mike svoboda
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Summary Panel