Skip to content

Commit

Permalink
Merge pull request #9138 from evgeni/enable-right-stream
Browse files Browse the repository at this point in the history
(PUP-11985) correctly enable module:stream without default profile with dnfmodule
  • Loading branch information
joshcooper authored Nov 15, 2023
2 parents f739469 + 9fe028d commit 5ab8d48
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/puppet/provider/package/dnfmodule.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def install
# module has no default profile and no profile was requested, so just enable the stream
# DNF versions prior to 4.2.8 do not need this workaround
# see https://bugzilla.redhat.com/show_bug.cgi?id=1669527
if @resource[:flavor] == nil && e.message =~ /^(?:missing|broken) groups or modules: #{Regexp.quote(@resource[:name])}$/
if @resource[:flavor] == nil && e.message =~ /^(?:missing|broken) groups or modules: #{Regexp.quote(args)}$/
enable(args)
else
raise
Expand Down
24 changes: 22 additions & 2 deletions spec/unit/provider/package/dnfmodule_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
provider.install
end

it "should just enable the module if it has no default profile(missing groups or modules)" do
it "should just enable the module if it has no default profile (missing groups or modules)" do
dnf_exception = Puppet::ExecutionFailure.new("Error: Problems in request:\nmissing groups or modules: #{resource[:name]}")
allow(provider).to receive(:execute).with(array_including('install')).and_raise(dnf_exception)
resource[:ensure] = :present
Expand All @@ -132,7 +132,17 @@
provider.install
end

it "should just enable the module if it has no default profile(broken groups or modules)" do
it "should just enable the module with the right stream if it has no default profile (missing groups or modules)" do
stream = '12.3'
dnf_exception = Puppet::ExecutionFailure.new("Error: Problems in request:\nmissing groups or modules: #{resource[:name]}:#{stream}")
allow(provider).to receive(:execute).with(array_including('install')).and_raise(dnf_exception)
resource[:ensure] = stream
expect(provider).to receive(:execute).with(array_including('install')).ordered
expect(provider).to receive(:execute).with(array_including('enable')).ordered
provider.install
end

it "should just enable the module if it has no default profile (broken groups or modules)" do
dnf_exception = Puppet::ExecutionFailure.new("Error: Problems in request:\nbroken groups or modules: #{resource[:name]}")
allow(provider).to receive(:execute).with(array_including('install')).and_raise(dnf_exception)
resource[:ensure] = :present
Expand All @@ -141,6 +151,16 @@
provider.install
end

it "should just enable the module with the right stream if it has no default profile (broken groups or modules)" do
stream = '12.3'
dnf_exception = Puppet::ExecutionFailure.new("Error: Problems in request:\nbroken groups or modules: #{resource[:name]}:#{stream}")
allow(provider).to receive(:execute).with(array_including('install')).and_raise(dnf_exception)
resource[:ensure] = stream
expect(provider).to receive(:execute).with(array_including('install')).ordered
expect(provider).to receive(:execute).with(array_including('enable')).ordered
provider.install
end

it "should just enable the module if enable_only = true" do
resource[:ensure] = :present
resource[:enable_only] = true
Expand Down

0 comments on commit 5ab8d48

Please sign in to comment.