Puppet: System Administration Automated

Support

Ticket #974 (closed defect: fixed)

Opened 8 months ago

Last modified 7 months ago

filenames with opening bracket characters generate exceptions

Reported by: mnagel Assigned to: luke
Priority: normal Milestone: 0.24.2
Component: server Version: 0.24.1
Severity: normal Keywords: file resource exception
Cc: Triage Stage: Ready for checkin
Attached Patches: Tests Complexity: Medium

Description (Last modified by luke)

From a simple file resource rule:

define colby_docsdir($group) {
    file { "/docs/$name":
        ensure => directory,
        group => $group,
        recurse => true,
        mode => 660
    }
}

class colby {
    colby_docsdir {
        "Backup":       group => wm-backup;
        "Clients":      group => clients;
        "General":      group => docs;
        "Internal":     group => internal;
        "Marketing":    group => marketing;
        "Members":      group => members;
    }
    ...

we are seeing this result, always when the filename contains regex special characters:

Got an uncaught exception of type ArgumentError: Resource File[/docs/Internal/Invoices/ValleyCrest/Valley Crest New Vendor Setup Form[1].doc] is already defined

The particular file differs from run to run, but the exception always has [] in the filename.

Regards, Mark

Change History

01/22/08 01:33:25 changed by plathrop

  • complexity changed from Unknown to Medium.
  • stage changed from Unreviewed to Accepted.

I've been able to duplicate this problem. It seems to only occur when a filename inside of one of the specified directories contains an opening square bracket character '['. If there is only a closing bracket, the problem does not occur.

I was unable to track down exactly where in the code this is coming from. My suspicion is this definition from type.rb :

    def ref
        "%s[%s]" % [self.class.name.to_s.capitalize, self.title]
    end

01/22/08 18:41:41 changed by plathrop

  • owner changed from community to plathrop.
  • status changed from new to assigned.

01/25/08 23:42:14 changed by plathrop

  • owner changed from plathrop to community.
  • status changed from assigned to new.

Hrm,

I think I jumped the gun accepting this one - I don't understand Puppet internals enough at this point to really track this down...

All I've been able to figure out is that the resource is actually managed - specified changes are actually applied (in this case, group and permissions changes). However, the Argument Error? exception is still raised.

Reassigning to community until I learn more about internals.

01/26/08 00:09:14 changed by plathrop

Looks like the problem is occuring in the Relationships phase...

01/26/08 00:10:34 changed by plathrop

Oops. I meant the Relationships phase...

01/26/08 00:41:34 changed by plathrop

Here's the problem spot, in puppet/lib/puppet/resource_reference.rb:

    # If the title has square brackets, treat it like a reference and
    # set things appropriately; else, just set it.
    def title=(value)
        if value =~ /^(.+)\[(.+)\]$/
            self.type = $1
            @title = $2
        else
            @title = value
        end
    end

Still not sure how to fix it - looks like a regex issue...

01/26/08 00:43:55 changed by plathrop

  • summary changed from filenames with special characters generate exceptions to filenames with opening bracket characters generate exceptions.

01/28/08 04:21:30 changed by luke

  • description changed.

01/28/08 04:21:38 changed by luke

  • milestone set to 0.24.2.

02/02/08 09:40:03 changed by plathrop

Luke,

Is there ever a situation in which a Resource Reference? would be created with a non-nil "type" *and* a "title" which contains a type specifier?

If not, we can fix this bug by having the title= method only use the bracket regex if "type" is nil.

02/02/08 10:17:02 changed by plathrop

  • owner changed from community to luke.
  • stage changed from Accepted to Ready for checkin.

I feel kinda dumb. This was actually a really easy fix.

fixed in commit [39c119ac2ef11b52d671f7cfbd33fc194759d9e8] of branch 0.24.x in my repository.

02/05/08 07:01:59 changed by luke

This causes two failures in the spec/unit/resource_reference.rb test.

Please include in your diff a test demonstrating the failure, such that it works once you've made the fix, and then make sure at least all of the tests for that class also pass.

Thanks, Luke

02/05/08 07:13:18 changed by luke

  • stage changed from Ready for checkin to Accepted.
  • patch changed from None to Insufficient.

02/05/08 23:40:40 changed by plathrop

  • owner changed from luke to plathrop.
  • status changed from new to assigned.

02/06/08 00:12:55 changed by plathrop

  • owner changed from plathrop to luke.
  • status changed from assigned to new.
  • stage changed from Accepted to Ready for checkin.
  • patch changed from Insufficient to Tests.

commit b3f67ec4017940a7eb47f3a044fd77c8d32a74cf on branch fix-974 of my repository not only *actually* fixes the issue, it also adds an appropriate test. All tests pass.

02/07/08 20:00:49 changed by luke

  • status changed from new to closed.
  • resolution set to fixed.

Pushed; thanks!