I was working on this bug and...
First, I was able to reproduce it:
- on a Wheezy, with multi arch activated (dpkg --add-architecture i386), the package installed will need the use of aptitude each time:
root@debian-7-64:~# /var/rudder/cfengine-community/bin/cf-agent -KIb check_apt_package_installation
[...]
Installing openjdk-6-jre...
Q:env DEBIAN_FRONTEND= ...:Reading package lists...
Q:env DEBIAN_FRONTEND= ...:Building dependency tree...
Q:env DEBIAN_FRONTEND= ...:Reading state information...
Q:env DEBIAN_FRONTEND= ...:Reading extended state information...
Q:env DEBIAN_FRONTEND= ...:Initializing package states...
Q:env DEBIAN_FRONTEND= ...:Reading task descriptions...
Q:env DEBIAN_FRONTEND= ...:No packages will be installed, upgraded, or removed.
Q:env DEBIAN_FRONTEND= ...:0 packages upgraded, 0 newly installed, 0 to remove and 35 not upgraded.
Q:env DEBIAN_FRONTEND= ...:Need to get 0 B of archives. After unpacking 0 B will be used.
Q:env DEBIAN_FRONTEND= ...:Writing extended state information...
Q:env DEBIAN_FRONTEND= ...:Reading package lists...
Q:env DEBIAN_FRONTEND= ...:Building dependency tree...
Q:env DEBIAN_FRONTEND= ...:Reading state information...
Q:env DEBIAN_FRONTEND= ...:Reading extended state information...
Q:env DEBIAN_FRONTEND= ...:Initializing package states...
Q:env DEBIAN_FRONTEND= ...:Reading task descriptions...
Q:env DEBIAN_FRONTEND= ...:
-> Command related to promiser "openjdk-6-jre" returned code defined as promise kept (0)
R: @@packageInstallation@@result_success@@b3d33690-89f6-46ab-982b-8365bfd6cfd7@@bacb72ee-6a0a-4228-b32d-040d172251de@@1@@Debian/Ubuntu packages@@openjdk-6-jre@@2013-08-13 15:57:12+02:00##5ee53fbe-ff96-4606-a78b-5e408cbf77c9@#No action required for deb package openjdk-6-jre with policy: add
And the content in the
software_packages.csv file is different on the first and the second case:
- On Squeeze:
root@debian-6-64:~# grep openjdk-6 /var/rudder/cfengine-community/state/software_packages.csv
openjdk-6-jre-lib,6b27-1.12.6-1~deb6u1,default,dpkg
openjdk-6-jre-headless,6b27-1.12.6-1~deb6u1,default,dpkg
openjdk-6-jre,6b27-1.12.6-1~deb6u1,default,dpkg
- On Wheezy multi arch:
root@debian-7-64:~# grep openjdk-6 /var/rudder/cfengine-community/state/software_packages.csv
openjdk-6-jre-lib,6b27-1.12.6-1~deb7u1,default,dpkg
openjdk-6-jre-headless:amd64,6b27-1.12.6-1~deb7u1,default,dpkg
openjdk-6-jre:amd64,6b27-1.12.6-1~deb7u1,default,dpkg
Secondly, i've found that an option was missing into the package_method body used into the promise: package_default_arch_command (cf https://cfengine.com/archive/manuals/cf3-Reference#package_005fmethod-in-packages)
This command allows CFEngine to detect default architecture of packages managed by package manager. As an example, multiarch-enabled dpkg only lists architectures explicitly for multiarch-enabled packages.
In case this command is not provided, CFEngine treats all packages without explicit architecture set as belonging to implicit “default” architecture.
Then I've added it to the generated promise but the problem was still there. With the verbose mode I was able to know that the problem is really from the file software_packages.csv (which contains the packages installed on the machine...this is a cache file):
- On Squeeze:
[...]
rudder> =========================================================
rudder> packages in bundle check_apt_package_installation (1)
rudder> =========================================================
rudder>
rudder>
rudder> .........................................................
rudder> Promise's handle:
rudder> Promise made by: "openjdk-6-jre"
rudder>
rudder> Comment: Handling openjdk-6-jre using apt_nobulk, policy : add
rudder> .........................................................
rudder>
rudder> Obtaining default architecture for package manager: /usr/bin/dpkg --print-architecture
rudder> Default architecture for package manager is 'amd64'
rudder> -> Cache file exists and is sufficiently fresh according to (package_list_update_ifelapsed)
rudder> -> Package (zlib1g-dev,1:1.2.3.4.dfsg-3,amd64) found
[...]
rudder> -> Package (openjdk-6-jre-lib,6b27-1.12.6-1~deb6u1,amd64) found
rudder> -> Package (openjdk-6-jre-headless,6b27-1.12.6-1~deb6u1,amd64) found
rudder> -> Package (openjdk-6-jre,6b27-1.12.6-1~deb6u1,amd64) found
[...]
rudder> -> Package version was not specified
rudder> -> Looking for (openjdk-6-jre,*,*)
rudder> -> Matched name openjdk-6-jre
rudder> -> Matched version *
rudder> -> Looking for (openjdk-6-jre,*,*)
rudder> -> Matched name openjdk-6-jre
rudder> -> Matched version *
rudder> Checking if package (openjdk-6-jre,*,*) is at the desired state (installed=1,matched=1)
rudder> -> Package promises to refer to itself as "openjdk-6-jre" to the manager
rudder> -> Package version seems to match criteria
rudder> -> Package "openjdk-6-jre" already installed, so we never add it again
rudder> ?> defining promise result class debian_install_kept_openjdk_6_jre
[...]
- On Wheezy multiarch:
[...]
rudder> =========================================================
rudder> packages in bundle check_apt_package_installation (1)
rudder> =========================================================
rudder>
rudder>
rudder> .........................................................
rudder> Promise's handle:
rudder> Promise made by: "openjdk-6-jre"
rudder>
rudder> Comment: Handling openjdk-6-jre using apt_nobulk, policy : add
rudder> .........................................................
rudder>
rudder> Obtaining default architecture for package manager: /usr/bin/dpkg --print-architecture
rudder> Default architecture for package manager is 'amd64'
rudder> -> Cache file exists and is sufficiently fresh according to (package_list_update_ifelapsed)
rudder> -> Package (zlib1g:amd64,1:1.2.7.dfsg-13,amd64) found
[...]
rudder> -> Package (openjdk-6-jre-lib,6b27-1.12.6-1~deb7u1,amd64) found
rudder> -> Package (openjdk-6-jre-headless:amd64,6b27-1.12.6-1~deb7u1,amd64) found
rudder> -> Package (openjdk-6-jre:amd64,6b27-1.12.6-1~deb7u1,amd64) found
[...]
rudder> -> Package version was not specified
rudder> -> Looking for (openjdk-6-jre,*,*)
rudder> No installed packages matched (openjdk-6-jre,*,*)
rudder> -> Looking for (openjdk-6-jre,*,*)
rudder> No installed packages matched (openjdk-6-jre,*,*)
rudder> Checking if package (openjdk-6-jre,*,*) is at the desired state (installed=0,matched=0)
rudder> -> Package promises to refer to itself as "openjdk-6-jre" to the manager
rudder> -> Package version seems to match criteria
rudder> -> Schedule package for addition
rudder> -> Package (openjdk-6-jre,any,any) found
[...]
The most important part is that to know if the package is installed, the regex used is wrong:
rudder> -> Looking for (openjdk-6-jre,*,*)
rudder> No installed packages matched (openjdk-6-jre,*,*)
Because since the multiarch is activated the installed package is described as:
Package (openjdk-6-jre:amd64,6b27-1.12.6-1~deb7u1,amd64) found
Finally, I suppose this is a CFEngine bug. Do you agree with me Matthieu ?