Skip to content

Commit

Permalink
Master bsc 1110246 (#418)
Browse files Browse the repository at this point in the history
* Do not report an error when "silent-mode" is active

At the time to catch a 402 registration error, do not report it if the
`silent_reg_code_mismatch` was setted, no matter what contains the error
message received.

Related to bsc#1091825.

* Update version and changelog

* improved error handling (#407)

* improved error handling

* Sle 15 ga bsc 1110246 (#417)

* do not try to remove services which have already been deleted
  • Loading branch information
schubi2 committed Jan 25, 2019
1 parent eb4b294 commit a8f67e8
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 4 deletions.
7 changes: 7 additions & 0 deletions package/yast2-registration.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Fri Jan 25 10:52:15 CET 2019 - schubi@suse.de

- Do not try to remove services which have already been deleted.
(bsc#1110246)
- 4.1.15

-------------------------------------------------------------------
Thu Jan 17 15:08:40 UTC 2019 - lslezak@suse.cz

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-registration.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


Name: yast2-registration
Version: 4.1.14
Version: 4.1.15
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
3 changes: 2 additions & 1 deletion src/clients/scc_auto.rb
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ def repo_cleanup
# we cannot use pkg-bindings here because loading services would trigger
# service and repository refresh which we want to avoid (it might easily fail)
old = Dir[File.join(Installation.destdir, "/etc/zypp/repos.d/*")] +
Dir[File.join(Installation.destdir, "/etc/zypp/services.d/*")]
Dir[File.join(Installation.destdir, "/etc/zypp/services.d/*")] +
Dir[File.join(Installation.destdir, "/var/cache/zypp/*")]

log.info "Removing #{old}"
::FileUtils.rm_rf(old)
Expand Down
8 changes: 6 additions & 2 deletions src/lib/registration/registration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,12 @@ def update_services(product_service)
old_service = product_service.obsoleted_service_name
# sanity check
if old_service && !old_service.empty? && old_service != product_service.name
log.info "Found obsoleted service: #{old_service}"
::Registration::SwMgmt.remove_service(old_service)
# old_service comes from SCC. So it could be that we have already removed
# this service from the system meanwhile --> checking first.
if ::Registration::SwMgmt.service_installed?(old_service)
log.info "Found obsoleted service: #{old_service}"
::Registration::SwMgmt.remove_service(old_service)
end
end

# read the global credentials
Expand Down
8 changes: 8 additions & 0 deletions src/lib/registration/sw_mgmt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,14 @@ def self.remove_service(name)
end
end

# Check if a libzypp service is installed
# @param [String] name name of the service
def self.service_installed?(name)
ret = Pkg.ServiceAliases.include?(name)
log.info "Service #{name} is installed: #{ret}"
ret
end

# get list of repositories belonging to registered services
# @param product_service [SUSE::Connect::Remote::Service] added service
# @param only_updates [Boolean] return only update repositories
Expand Down
16 changes: 16 additions & 0 deletions test/sw_mgmt_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,22 @@
end
end

describe ".service_installed?" do
let(:service) { "service" }

it "returns true if the service is installed" do
expect(Yast::Pkg).to receive(:ServiceAliases).and_return(["service"])

expect(subject.service_installed?(service)).to eq true
end

it "returns false if the service is not installed" do
expect(Yast::Pkg).to receive(:ServiceAliases).and_return(["wrong_service"])

expect(subject.service_installed?(service)).to eq false
end
end

describe ".set_repos_state" do
it "sets the repository state and stores the original state" do
repos = [{ "SrcId" => 42, "enabled" => true }]
Expand Down

0 comments on commit a8f67e8

Please sign in to comment.