Skip to content

Commit

Permalink
Merge pull request #512 from ncharles/bug_5582/dev/remove_check_on_lock
Browse files Browse the repository at this point in the history
Fixes #5582: remove non working check on lock
  • Loading branch information
jooooooon committed Sep 28, 2014
2 parents dbccc52 + a9726af commit 4e44d9a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 89 deletions.
46 changes: 1 addition & 45 deletions initial-promises/node-server/failsafe.cf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
body common control

{
bundlesequence => { "check_lock_db_problem", "init_files", "update" };
bundlesequence => { "init_files", "update" };

inputs => { "common/1.0/update.cf" };
output_prefix => "rudder";
Expand Down Expand Up @@ -141,50 +141,6 @@ bundle agent init_files
"${sys.workdir}/bin/cf-key";
}

# This bundle will check the "last successful inputs update", and if it is older
# than 1 hour, remove cf_lock.db (and only this DB), to give CFEngine a chance
# to run properly again.
bundle agent check_lock_db_problem{
vars:

cfengine_3_0|cfengine_3_1|cfengine_3_2::
"cf_lock_filename" string => "cf_lock.db";

!(cfengine_3_0|cfengine_3_1|cfengine_3_2)::
"cf_lock_filename" string => "cf_lock.tcdb";

files:
# The aim of this promise is to create a class when this file is older
# than one hour. The class can not be created without touching but in
# order to not modifing the mtime we use warn_only.
"${sys.workdir}/last_successful_inputs_update"
file_select => over_an_hour,
touch => "true",
action => warn_only,
classes => success("last_successful_inputs_update_too_old", "last_successful_inputs_update_check_error", "last_successful_inputs_update_ok");

"${sys.workdir}/state/${cf_lock_filename}"
delete => tidy,
ifvarclass => "last_successful_inputs_update_too_old",
classes => success("cf_lock_removed", "cf_lock_error_removing", "cf_lock_not_deleted");

reports:
cf_lock_removed::
"@@Common@@log_repaired@@hasPolicyServer-root@@common-root@@00@@Update@@None@@${g.execRun}##${g.uuid}@#Promises had not been updated for over an hour, this could indicate a broken lockfile. cf_lock DB file was removed.";

cf_lock_error_removing::
"@@Common@@result_error@@hasPolicyServer-root@@common-root@@00@@Update@@None@@${g.execRun}##${g.uuid}@#Promises have not been updated for over an hour, this could indicate a broken lockfile, but an error occured when trying to remove it";
}

body file_select over_an_hour()
{
# Select file which are older than one hour
# Use of positive mtime instead of negative one
# In order to avoid corner effects
mtime => irange(ago(0,0,0,1,0,0), now);
file_result => "!mtime";
}

body depth_search recurse(d)
{
depth => "${d}";
Expand Down
45 changes: 1 addition & 44 deletions techniques/system/common/1.0/failsafe.st
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

body common control
{
bundlesequence => { "check_lock_db_problem", "init_files", "update" };
bundlesequence => { "init_files", "update" };

inputs => { "common/1.0/update.cf" };
output_prefix => "rudder";
Expand Down Expand Up @@ -141,49 +141,6 @@ bundle agent init_files
"${sys.workdir}/bin/cf-key";
}
# This bundle will check the "last successful inputs update", and if it is older
# than 1 hour, remove cf_lock.db (and only this DB), to give CFEngine a chance
# to run properly again.
bundle agent check_lock_db_problem{
vars:
cfengine_3_0|cfengine_3_1|cfengine_3_2::
"cf_lock_filename" string => "cf_lock.db";
!(cfengine_3_0|cfengine_3_1|cfengine_3_2)::
"cf_lock_filename" string => "cf_lock.tcdb";
files:
# The aim of this promise is to create a class when this file is older
# than one hour. The class can not be created without touching but in
# order to not modifing the mtime we use WarnOnly.
"${sys.workdir}/last_successful_inputs_update"
file_select => over_an_hour,
touch => "true",
action => WarnOnly,
classes => success("last_successful_inputs_update_too_old", "last_successful_inputs_update_check_error", "last_successful_inputs_update_ok");
"${sys.workdir}/state/${cf_lock_filename}"
delete => tidy,
ifvarclass => "last_successful_inputs_update_too_old",
classes => success("cf_lock_removed", "cf_lock_error_removing", "cf_lock_not_deleted");
reports:
cf_lock_removed::
"@@Common@@log_repaired@@&TRACKINGKEY&@@Update@@None@@${g.execRun}##${g.uuid}@#Promises had not been updated for over an hour, this could indicate a broken lockfile. cf_lock DB file was removed.";
cf_lock_error_removing::
"@@Common@@result_error@@&TRACKINGKEY&@@Update@@None@@${g.execRun}##${g.uuid}@#Promises have not been updated for over an hour, this could indicate a broken lockfile, but an error occured when trying to remove it";
}
body file_select over_an_hour()
{
# Select file which are older than one hour
# Use of positive mtime instead of negative one
# In order to avoid corner effects
mtime => irange(ago(0,0,0,1,0,0), now);
file_result => "!mtime";
}
body depth_search recurse(d)
{
Expand Down

0 comments on commit 4e44d9a

Please sign in to comment.