Details
-
Type:
Task
-
Status: Open
-
Priority:
High
-
Resolution: Unresolved
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: Promise type: packages
-
Labels:None
Description
A few cases where logging should be improved (tested on CentOS 6 64-bit):
1. Changes (promises repaired) should be logged at the inform level, but is currently logged at verbose.
Example policy:
<pre>
packages:
"rarian"
policy => "present", # same result for "absent"
package_module => yum;
</pre>
If CFEngine changes the system with this promise (i.e. removes or adds a package), it currently logs it as verbose.
2. When using "absent" and the package is already removed, it still outputs "Successfully removed package..." (this is working correctly for present).
To reproduce, run the following policy twice (e.g. cf-agent -Kv -btest):
<pre>
bundle agent test
{
packages:
"rarian"
policy => "absent",
package_module => yum;
}
</pre>
On the second run, it will still output:
<pre>
verbose: Additional promise info: version 'CFEngine Promises.cf 3.7.0' source path '/var/cfengine/inputs/test.cf' at line 4
verbose: Successfully removed package 'rarian'
verbose: A: Promise was KEPT
verbose: P: END packages promise (rarian...)
</pre>
Note that the promise outcome is correct (KEPT).
3. When a package operation fails, more diagnostics information should be output. E.g. when trying to install a package that does not exist (either name or version is not available):
Given the following policy:
<pre>
bundle agent test
{
packages:
"rarian"
policy => "present",
version => "1.2.3", # no such version
package_module => yum;
}
</pre>
The error output is:
<pre>
- cf-agent -K ./promises.cf -btest
Error: Nothing to do
error: Error installing package 'rarian'
</pre>
Even the verbose output does not explain what happened:
<pre>
verbose: B: *****************************************************************
verbose: B: BEGIN bundle test
verbose: B: *****************************************************************
verbose: P: .........................................................
verbose: P: BEGIN promise 'promise_test_cf_4' of type "packages" (pass 1)
verbose: P: Promiser/affected object: 'rarian'
verbose: P: Part of bundle: test
verbose: P: Base context class: any
verbose: P: Container path : '/default/test/packages/'rarian'[0]'
verbose: P: .........................................................
verbose:
Error: Nothing to do
verbose: Package module returned with non zero return code: 1
info: Some error occurred while communicating with package module while installing package.
error: Error installing package 'rarian'
verbose: A: Promise NOT KEPT!
verbose: P: END packages promise (rarian...)
</pre>
This would be expected:
- The command the package module ran, e.g. "yum install rarian-1.2.3"
- The full output from the command, e.g.
<pre>
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
- base: centos.vianett.no
- extras: centos.uib.no
- updates: centos.uib.no
Setting up Install Process
No package rarian-1.2.3 available.
Error: Nothing to do
</pre>