Project

General

Profile

Actions

Bug #10712

closed

Bug #10711: Improve generated inventory checks when inventory is missing

cf-agent: filesexist returns true on empty slist

Added by Janos Mattyasovszky almost 7 years ago. Updated over 4 years ago.

Status:
Rejected
Priority:
N/A
Assignee:
-
Category:
Agent
Target version:
Severity:
Minor - inconvenience | misleading | easy workaround
UX impact:
User visibility:
Infrequent - complex configurations | third party integrations
Effort required:
Priority:
18
Name check:
Fix check:
Regression:

Description

As seen in the parent class, cfengine returns somehow true if you try to search a bunch of files "*.ocs" in an empty folder via findfiles and use filesexist on the resulting slist:

See rudder agent run -d proper part:

rudder    debug: Evaluating function: findfiles("${g.rudder_var_tmp}/inventory/*.ocs")
rudder    debug: Evaluating vars promise: inventory_file
rudder    debug: DeRefCopyPromise(): promiser:'perl_command'
rudder    debug: DeRefCopyPromise():     copying constraint: 'string'
rudder    debug: Evaluating vars promise: perl_command
rudder  verbose: V: .........................................................
rudder  verbose: V: BEGIN variables (pass 1)
rudder    debug: DeRefCopyPromise(): promiser:'inventory_file'
rudder    debug: DeRefCopyPromise():     copying constraint: 'slist'
rudder    debug: Evaluating function: findfiles("${g.rudder_var_tmp}/inventory/*.ocs")        <<========== This directory is empty
rudder  verbose: V:     Computing value of 'inventory_file'
rudder    debug: Evaluating vars promise: inventory_file
rudder    debug: V: 'inventory_file' => ''                   <<=========================================== The result is empty
rudder    debug: Evaluating vars promise: inventory_file
rudder    debug: DeRefCopyPromise(): promiser:'perl_command'
rudder    debug: DeRefCopyPromise():     copying constraint: 'string'
rudder  verbose: V:     Computing value of 'perl_command'
rudder    debug: Evaluating vars promise: perl_command
rudder    debug: V: 'perl_command' => '/usr/bin/perl'
rudder    debug: Evaluating vars promise: perl_command
rudder  verbose: C: .........................................................
rudder  verbose: C: BEGIN classes / conditions (pass 1)
rudder    debug: DeRefCopyPromise(): promiser:'inventory_file_exist'
rudder    debug: DeRefCopyPromise():     copying constraint: 'expression'
rudder    debug: Evaluating function: filesexist("@{inventory_file}")     <<============================== The check runs on the empty slist
rudder    debug: Evaluating classes promise: inventory_file_exist
rudder  verbose: C:     +  Private class: inventory_file_exist       <<=================================== Class is defined !!!
rudder    debug: Setting class: default:inventory_file_exist

But the directory is empty:

# ll /var/rudder/tmp/inventory
total 0

Here is an example code what I have copy-pasted together to demonstrate the behavior:

Run mkdir /tmp/empty before :-)

test.cf:

body common control
{
      bundlesequence  => { "example" };
}

bundle agent example
{

  vars:
      "tmpdir" string => "/tmp/empty";
      "mylist" slist  => findfiles("${tmpdir}/*.ocs");

  classes:
      "exists" expression => filesexist("@{mylist}");

  reports:
      "My list: @{mylist}";

    exists::
      "Case exist!";
    !exists::
      "Case does not exist!";

}

Output is basically a "true" class even if the files don't exist!

# cf-agent -f ./test.cf
R: My list: @{mylist}
R: Case exist!
Actions #2

Updated by François ARMAND almost 7 years ago

  • Severity changed from Critical - prevents main use of Rudder | no workaround | data loss | security to Minor - inconvenience | misleading | easy workaround
  • User visibility changed from Operational - other Techniques | Technique editor | Rudder settings to Infrequent - complex configurations | third party integrations
  • Priority changed from 0 to 6

Thanks for reporting.

For the level: we believe it is misleading, not blocking, because it can be avoid if/when you know the problem (and are able to code CFEngine), which lead us to the "infrequent" user visibility, because it is rare to have to do so for typical rudder users. Hope it help understanding these levels.

Actions #3

Updated by Janos Mattyasovszky almost 7 years ago

Yes, you are right, there is an easy workaround for this as seen in the parent.

Actions #4

Updated by Benoît PECCATTE almost 7 years ago

  • Priority changed from 6 to 21
Actions #5

Updated by Benoît PECCATTE over 6 years ago

  • Priority changed from 21 to 20
Actions #6

Updated by Alexis Mousset almost 5 years ago

  • Target version set to 4.1.22
  • Priority changed from 20 to 18
Actions #7

Updated by Vincent MEMBRÉ almost 5 years ago

  • Target version changed from 4.1.22 to 4.1.23
Actions #8

Updated by Vincent MEMBRÉ almost 5 years ago

  • Target version changed from 4.1.23 to 4.1.24
Actions #9

Updated by Vincent MEMBRÉ almost 5 years ago

  • Target version changed from 4.1.24 to 588
Actions #10

Updated by Alexis Mousset almost 5 years ago

  • Status changed from New to Rejected

This bug has been fixed in recent 4.1+ releases by updating the CFEngine agent to 3.10.5. Closing.

Actions #11

Updated by Alexis Mousset over 4 years ago

  • Target version changed from 588 to 4.1.24
Actions

Also available in: Atom PDF