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

edit_line failure not re-evaluated.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Need more Info
    • Priority: (None)
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Labels:
      None

      Description

      In this scenario a file edit_line promise fails because the promise
      file is too large. So, there is another promise to delete file. I
      believe that if a promise fails, it should be tried again on the next
      pass. In this scenario this does not happen.

      <pre>
      body common control
      {
      bundlesequence =>

      { "main", }

      ;
      }

      bundle agent main
      {
      vars:
      "test_file" string => "${sys.workdir}/inputs/bug";

      methods:

      "any" usebundle => init;
      "any" usebundle => test;
      "any" usebundle => check;
      }

      bundle agent init
      {
      commands:
      "/bin/dd if=/dev/zero of=${main.test_file} bs=1k count=1000";
      }

      bundle agent test
      {
      files:
      "${main.test_file}"
      edit_defaults => empty,
      edit_line => append_if_no_line( "START" ),
      classes => if_notkept( "delete_file" );

      delete_file::
      "${main.test_files}"
      delete => tidy;
      }

      bundle agent check
      {
      classes:
      "PASS" expression => returnszero( "/bin/grep START ${main.test_file}", "noshell" );

      reports:
      PASS::
      "PASS";
      !PASS::
      "FAIL";
      }

      body classes if_notkept
      {
      repair_failed =>

      { "$(x)" };
      repair_denied => { "$(x)" }

      ;
      repair_timeout =>

      { "$(x)" }

      ;
      }

      body delete tidy
      {
      dirlinks => "delete";
      rmdirs => "true";
      }

      body edit_defaults empty
      {
      empty_file_before_editing => "true";
      edit_backup => "false";
      #max_file_size => "300000";
      }

      bundle edit_line append_if_no_line(str)
      {
      insert_lines:

      "$(str)"

      comment => "Append a line to the file if it doesn't already exist";
      }
      </pre>

      Now run the promise:

      <pre>
      $ cf-agent -Kf ./bug.cf
      2014-04-13T12:37:40-0400 notice: /default/main/methods/'any'/default/init/commands/'/bin/dd if=/dev/zero of=/home/neil/.cfagent/inputs/bug bs=1k count=1000'[0]: Q: ".../bin/dd if=/dev": 1000+0 records in
      Q: ".../bin/dd if=/dev": 1000+0 records out
      Q: ".../bin/dd if=/dev": 1024000 bytes (1.0 MB) copied, 0.00168531 s, 608 MB/s

      2014-04-13T12:37:40-0400 error: /default/main/methods/'any'/default/test/files/'/home/neil/.cfagent/inputs/bug'[0]: File '/home/neil/.cfagent/inputs/bug' was marked for editing but could not be opened
      2014-04-13T12:37:40-0400 error: /default/main/methods/'any'[0]: Method 'test' failed in some repairs
      R: FAIL
      </pre>

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              neilhwatson Neil Watson
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated: