From 70253e09408857ffce9df10f6b6c8b814f6d0644 Mon Sep 17 00:00:00 2001 From: Ancor Gonzalez Sosa Date: Thu, 24 Oct 2024 15:52:59 +0200 Subject: [PATCH 1/3] storage: do not register issues when skipping entries at the config --- service/lib/agama/storage/config_checker.rb | 23 +++---------------- .../test/agama/storage/config_checker_test.rb | 20 ++++------------ .../y2storage/agama_proposal_search_test.rb | 7 ++---- service/test/y2storage/agama_proposal_test.rb | 16 ++++--------- 4 files changed, 15 insertions(+), 51 deletions(-) diff --git a/service/lib/agama/storage/config_checker.rb b/service/lib/agama/storage/config_checker.rb index cead5a632d..2d0b062db5 100644 --- a/service/lib/agama/storage/config_checker.rb +++ b/service/lib/agama/storage/config_checker.rb @@ -29,7 +29,7 @@ module Storage # Class for checking a storage config. # # TODO: Split in smaller checkers, for example: ConfigFilesystemChecker, etc. - class ConfigChecker # rubocop:disable Metrics/ClassLength + class ConfigChecker include Yast::I18n # @param config [Storage::Config] @@ -81,15 +81,10 @@ def drive_issues(config) # @return [Agama::Issue] def search_issue(config) return if !config.search || config.found_device + return if config.search.skip_device? if config.is_a?(Agama::Storage::Configs::Drive) - if config.search.skip_device? - warning(_("No device found for an optional drive")) - else - error(_("No device found for a mandatory drive")) - end - elsif config.search.skip_device? - warning(_("No device found for an optional partition")) + error(_("No device found for a mandatory drive")) else error(_("No device found for a mandatory partition")) end @@ -470,18 +465,6 @@ def volume_builder @volume_builder ||= VolumeTemplatesBuilder.new_from_config(product_config) end - # Creates a warning issue. - # - # @param message [String] - # @return [Issue] - def warning(message) - Agama::Issue.new( - message, - source: Agama::Issue::Source::CONFIG, - severity: Agama::Issue::Severity::WARN - ) - end - # Creates an error issue. # # @param message [String] diff --git a/service/test/agama/storage/config_checker_test.rb b/service/test/agama/storage/config_checker_test.rb index fa2da3bb52..6efdf161e3 100644 --- a/service/test/agama/storage/config_checker_test.rb +++ b/service/test/agama/storage/config_checker_test.rb @@ -21,7 +21,7 @@ require_relative "./storage_helpers" require "agama/config" -require "agama/storage/config_conversions/from_json" +require "agama/storage/config_conversions" require "agama/storage/config_checker" require "agama/storage/config_solver" require "y2storage" @@ -281,13 +281,8 @@ context "and the drive should be skipped" do let(:if_not_found) { "skip" } - it "includes the expected issue" do - issues = subject.issues - expect(issues.size).to eq(1) - - issue = issues.first - expect(issue.error?).to eq(false) - expect(issue.description).to eq("No device found for an optional drive") + it "does not include any issue" do + expect(subject.issues).to be_empty end end @@ -374,13 +369,8 @@ context "and the partition should be skipped" do let(:if_not_found) { "skip" } - it "includes the expected issue" do - issues = subject.issues - expect(issues.size).to eq(1) - - issue = issues.first - expect(issue.error?).to eq(false) - expect(issue.description).to eq("No device found for an optional partition") + it "does not include any issue" do + expect(subject.issues).to be_empty end end diff --git a/service/test/y2storage/agama_proposal_search_test.rb b/service/test/y2storage/agama_proposal_search_test.rb index 80a4dd670c..6344aca0c2 100644 --- a/service/test/y2storage/agama_proposal_search_test.rb +++ b/service/test/y2storage/agama_proposal_search_test.rb @@ -207,12 +207,9 @@ expect(disk.partitions.size).to eq 1 end - it "register a warning about non-existent partitions" do + it "register a no issues about non-existent partitions" do proposal.propose - expect(proposal.issues_list).to include an_object_having_attributes( - description: /optional partition/, - severity: Agama::Issue::Severity::WARN - ) + expect(proposal.issues_list).to be_empty end end end diff --git a/service/test/y2storage/agama_proposal_test.rb b/service/test/y2storage/agama_proposal_test.rb index d26db503d4..bc818c2e23 100644 --- a/service/test/y2storage/agama_proposal_test.rb +++ b/service/test/y2storage/agama_proposal_test.rb @@ -22,7 +22,7 @@ require_relative "../agama/storage/storage_helpers" require "agama/config" require "agama/storage/config" -require "agama/storage/config_conversions/from_json" +require "agama/storage/config_conversions" require "y2storage" require "y2storage/agama_proposal" @@ -484,12 +484,9 @@ def partition_config(name: nil, filesystem: nil, size: nil) expect(proposal.failed?).to eq false end - it "registers a non-critical issue" do + it "does not register any issue about missing disks" do proposal.propose - expect(proposal.issues_list).to include an_object_having_attributes( - description: /optional drive/, - severity: Agama::Issue::Severity::WARN - ) + expect(proposal.issues_list).to be_empty end end @@ -576,12 +573,9 @@ def partition_config(name: nil, filesystem: nil, size: nil) expect(proposal.failed?).to eq false end - it "registers a non-critical issue" do + it "does not register any issue about missing partitions" do proposal.propose - expect(proposal.issues_list).to include an_object_having_attributes( - description: /optional partition/, - severity: Agama::Issue::Severity::WARN - ) + expect(proposal.issues_list).to be_empty end end From 6e491c071d39f62762c2ee67a701f7683d55f2b8 Mon Sep 17 00:00:00 2001 From: Ancor Gonzalez Sosa Date: Thu, 24 Oct 2024 16:45:41 +0200 Subject: [PATCH 2/3] Changelog --- service/package/rubygem-agama-yast.changes | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/service/package/rubygem-agama-yast.changes b/service/package/rubygem-agama-yast.changes index a9924a79d8..e92f3ce3da 100644 --- a/service/package/rubygem-agama-yast.changes +++ b/service/package/rubygem-agama-yast.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Thu Oct 24 14:44:35 UTC 2024 - Ancor Gonzalez Sosa + +- Storage: do not report issues when intentionally skipping entries + at the storage config (gh#agama-project/agama#1696). + ------------------------------------------------------------------- Thu Oct 24 13:07:50 UTC 2024 - Ancor Gonzalez Sosa From 811ecb9e6d3bdbe1988e2f4594af2c4c43b506fa Mon Sep 17 00:00:00 2001 From: Ancor Gonzalez Sosa Date: Fri, 25 Oct 2024 10:46:48 +0200 Subject: [PATCH 3/3] Fix text in unit test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: José Iván López --- service/test/y2storage/agama_proposal_search_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/service/test/y2storage/agama_proposal_search_test.rb b/service/test/y2storage/agama_proposal_search_test.rb index 6344aca0c2..3073df83db 100644 --- a/service/test/y2storage/agama_proposal_search_test.rb +++ b/service/test/y2storage/agama_proposal_search_test.rb @@ -207,7 +207,7 @@ expect(disk.partitions.size).to eq 1 end - it "register a no issues about non-existent partitions" do + it "does not include any issue about non-existent partitions" do proposal.propose expect(proposal.issues_list).to be_empty end