Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(PUP-11985) correctly enable module:stream without default profile with dnfmodule #9138

Merged
merged 1 commit into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading