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

misleading error message when using `edit_template` together with `create => "false"`

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Done
    • Priority: (None)
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.6.0
    • Labels:
      None

      Description

      Hi *,

      I'm using code similar to the following to instanciate a template.
      The template should replace the destination file only if it already
      exists, hence `create => "false"`.

      body common control
      {
      inputs => { };
      bundlesequence =>

      { "test" }

      ;
      }

      bundle agent test

      { files: "/tmp/test.txt" create => "false", edit_defaults => empty, edit_template => "/tmp/test.tmpl"; }

      The `/tmp/test.tmpl` file containts just three lines:

      one
      two
      three

      When running the code in CFEngine 3.5 (with "-v"), I get the following
      log, which ends with a completely misleading error message ("Cano no
      longer access file ..."). A similar error happens with 3.4 in verbose
      mode.

      2013-10-21T23:01:44+0200 verbose: Using bundlesequence =>

      {'test'}

      2013-10-21T23:01:44+0200 verbose: Using literal pathtype for /tmp/test.txt
      2013-10-21T23:01:44+0200 verbose: Build file model from a blank slate (emptying)
      2013-10-21T23:01:44+0200 verbose: ?? Private class context
      2013-10-21T23:01:44+0200 verbose:

      2013-10-21T23:01:44+0200 verbose: /test/files/'/tmp/test.txt'/temp:temp_cf_bundle__tmp_test_tmpl/insert_lines/'one': Inserting the promised line "one" into /tmp/test.txt after locator
      2013-10-21T23:01:44+0200 verbose: /test/files/'/tmp/test.txt'/temp:temp_cf_bundle__tmp_test_tmpl/insert_lines/'two': Inserting the promised line "two" into /tmp/test.txt after locator
      2013-10-21T23:01:44+0200 verbose: /test/files/'/tmp/test.txt'/temp:temp_cf_bundle__tmp_test_tmpl/insert_lines/'three': Inserting the promised line "three" into /tmp/test.txt after locator
      2013-10-21T23:01:44+0200 verbose: ?? Private class context
      2013-10-21T23:01:44+0200 verbose:

      2013-10-21T23:01:44+0200 verbose: This promise has already been verified
      2013-10-21T23:01:44+0200 verbose: This promise has already been verified
      2013-10-21T23:01:44+0200 verbose: This promise has already been verified
      2013-10-21T23:01:44+0200 verbose: ?? Private class context
      2013-10-21T23:01:44+0200 verbose:

      2013-10-21T23:01:44+0200 verbose: This promise has already been verified
      2013-10-21T23:01:44+0200 verbose: This promise has already been verified
      2013-10-21T23:01:44+0200 verbose: This promise has already been verified
      2013-10-21T23:01:44+0200 error: Can no longer access file '/tmp/test.txt', which needed editing. (stat: No such file or directory)

      IMHO, there are actually two bugs here:

      1- CFEngine should not even start instanciating the template if
      `create => "false"` and the promised file does not exist;

      2- Anyway, the error message should be sensible, e.g., "Not writing
      template because edited file does not exist".

        Attachments

          Activity

            People

            • Assignee:
              a10025 Volker Hilsheimer (Inactive)
              Reporter:
              riccardomurri Riccardo Murri
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: