Dynamic scoping used in resource defaults in class nova sometimes causes a dependency cycle

Bug #1349765 reported by Risto Laurikainen
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
puppet-nova
Fix Released
Undecided
Risto Laurikainen

Bug Description

Class nova has the following resource defaults set for all file resources:

File {
  require => Package['nova-common'],
  owner => 'nova',
  group => 'nova',
}

This should of course only apply to file resources declared in nova, but sometimes dynamic scoping causes it to be applied elsewhere as well:

Error: Could not apply complete catalog: Found 1 dependency cycle:
(Anchor[mysql::server::end] => Class[Mysql::Server] => Mysql_grant[nova@10.100.20.1/nova.*] => Mysql::Db[nova] => Anchor[nova-start] => Package[nova-common] => File[/etc/mysql] => Class[Mysql::Server::Config] => Class[Mysql::Server::Service] => Class[Mysql::Server::Service] => Class[Mysql::Server::Root_password] => File[/root/.my.cnf] => Mysql_grant[nova@10.100.20.1/nova.*])

This looks like a Puppet bug, but avoiding dynamic scoping in puppet-nova should be an easy fix. I tried removing the resource defaults for file resources in init.pp and instead explicitly defined the parameters for each file resource and that fixed this for me. The functionality of the class remains the same - there are just a few more lines of code.

Avoiding dynamic scoping like this is the recommended way according to Puppet documentation:
http://docs.puppetlabs.com/guides/scope_and_puppet.html#declare-resource-defaults-per-file

Revision history for this message
Risto Laurikainen (risto-laurikainen) wrote :
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to puppet-nova (master)

Fix proposed to branch: master
Review: https://review.openstack.org/110253

Changed in puppet-nova:
assignee: nobody → Risto Laurikainen (risto-laurikainen)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to puppet-nova (master)

Reviewed: https://review.openstack.org/110253
Committed: https://git.openstack.org/cgit/stackforge/puppet-nova/commit/?id=089e5a1e4d10c2dda0f0c70267a8706977f274da
Submitter: Jenkins
Branch: master

commit 089e5a1e4d10c2dda0f0c70267a8706977f274da
Author: Risto Laurikainen <email address hidden>
Date: Tue Jul 29 13:07:57 2014 +0300

    Remove dynamic scoping with File from class nova.

    Resource defaults are applied to all file resources
    in class nova using File. In some circumstances the
    scope of these defaults becomes too wide, causing
    a dependency cycle. This commit removes the dynamic
    scoping and instead explicitly defines the parameters
    of each file resource to avoid creating dependency
    cycles. Functionality should otherwise be identical.

    Change-Id: I41d85e65ea73c54ce1a8be292ef3f781e17e48a7
    Closes-Bug: 1349765

Changed in puppet-nova:
status: In Progress → Fix Committed
Mathieu Gagné (mgagne)
Changed in puppet-nova:
milestone: none → 5.0.0
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.