(#22557) Raise an error providing a package resource with multiple names#1950
Closed
jpartlow wants to merge 1 commit intopuppetlabs:masterfrom
Closed
Conversation
|
CLA signed by all contributors. |
Redmine #22557 brought up a regression in package provider behavior (specifically dpkg). Previously it was possible, under some circumstances to supply a package resource with an array for the name attribute, and have puppet manage the set of packages. However, this was an accidental feature which could fail if some packages were in different states because the providers' query methods ultimately operate on the package property hash info of just one of the packages. This commit makes explicit that a package resource should not have its name attribute set to an array of more than one value, and will raise a ResourceError if this is attempted.
Contributor
There was a problem hiding this comment.
@jpartlow this change will work for package providers in core, but not modules, e.g. https://github.com/bjoernalbers/puppet-homebrew/blob/master/lib/puppet/provider/package/homebrew.rb#L47-L49. I'm not sure if we care?
From what I can tell the Puppet::Provider::Package#query method is only called by the #properties method in the same class. We could create a new query method that does the validate check:
def query_wrapper
validate_resource
query
end
def properties
if @property_hash.empty?
@property_hash = query_wrapper || {:ensure => :absent}
and then leave the core & custom package providers as they were?
Contributor
|
Superseded by GH-1980 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Redmine #22557 brought up a regression in package provider behavior
(specifically dpkg). Previously it was possible, under some
circumstances to supply a package resource with an array for the name
attribute, and have puppet manage the set of packages. However, this
was an accidental feature which could fail if some packages were in
different states because the providers' query methods ultimately operate
on the package property hash info of just one of the packages.
This commit makes explicit that a package resource should not have its
name attribute set to an array of more than one value, and will raise a
ResourceError if this is attempted.