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

_not_repaired in *classes_generic is a misnomer

    XMLWordPrintable

    Details

      Description

      A promise have multiple outcomes. For example a promise could be both kept and repaired at the same time if you are making a compound promise. (I just made the "compound promise" part up, Dunno what else to call it).

      In this output you will see the policy run and what is reported are the classes defined using scoped_classes_generic. Note how test_file_not_repaired is listed when the file is in fact repaired.
      <pre>
      > $ cf-agent -KIf ./multiple_outcome.cf -b example
      2015-02-26T22:34:00-0600 info: Using command line specified bundlesequence
      2015-02-26T22:34:00-0600 info: /default/example/files/'/tmp/test'[0]: Edit file '/tmp/test'
      R: test_file_reached
      R: test_file_kept
      R: test_file_repaired
      R: test_file_not_repaired
      R: test_file_ok

      nickanderson@nickanderson-ThinkPad-W520 ~/proto [22:34:00]
      > $ cat /tmp/test
      Its Thu Feb 26 22:33:50 2015
      Its Thu Feb 26 22:34:00 2015

      nickanderson@nickanderson-ThinkPad-W520 ~/proto [22:34:06]
      > $ cf-agent -KIf ./multiple_outcome.cf -b example
      2015-02-26T22:34:09-0600 info: Using command line specified bundlesequence
      2015-02-26T22:34:09-0600 info: /default/example/files/'/tmp/test'[0]: Edit file '/tmp/test'
      R: test_file_reached
      R: test_file_kept
      R: test_file_repaired
      R: test_file_not_repaired
      R: test_file_ok

      nickanderson@nickanderson-ThinkPad-W520 ~/proto [22:34:09]
      > $ cat /tmp/test
      Its Thu Feb 26 22:33:50 2015
      Its Thu Feb 26 22:34:00 2015
      Its Thu Feb 26 22:34:09 2015
      </pre>

      In case your wondering why it has both outcomes, its because in the policy (attached) both create, and edit_line were used. The promise that the file existed was kept. The promise to insert a line with the current run time is repaired as it inserts a new line. Thus multiple outcomes.

      <pre>
      files:
      "/tmp/test"
      create => "true",
      edit_line => insert_lines("Its $(sys.date)"),
      classes => scoped_classes_generic("bundle", "test_file");
      </pre>

      Supporting an additional outcome of not_repaired would be nice, but that is a separate feature request.
      Right now I believe it can be accomplished by classing on @test_file_reached.!test_file_repaired@

        Attachments

          Activity

            People

            Assignee:
            a10003 Eystein Maloy Stenberg
            Reporter:
            a10042 Nick Anderson
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: