Skip to content

Commit

Permalink
fix(storage): recover config if needed (#1848)
Browse files Browse the repository at this point in the history
## Problem

In autoinstallation, the storage config could be set before probing
storage. If so, the probing action overwrites the config that was set
from the autoinstall profile.

https://bugzilla.suse.com/show_bug.cgi?id=1234711

## Solution

Hotfix for ensuring the storage config is preserved when doing probing
for first time. A better solution should be provided for a correct
management of the services and precedences.

## Testing

Manually tested.
  • Loading branch information
joseivanlopez authored Dec 20, 2024
2 parents a103f54 + 427873a commit cf131a8
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 16 deletions.
17 changes: 17 additions & 0 deletions service/lib/agama/dbus/clients/storage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
require "agama/dbus/clients/with_locale"
require "agama/dbus/clients/with_progress"
require "agama/dbus/clients/with_issues"
require "json"

module Agama
module DBus
Expand Down Expand Up @@ -62,6 +63,22 @@ def finish
dbus_object.Finish
end

# Gets the current storage config.
#
# @return [Hash]
def config
serialized_config = dbus_object.GetConfig
JSON.parse(serialized_config, symbolize_names: true)
end

# Sets the storage config.
#
# @param config [Hash]
def config=(config)
serialized_config = JSON.pretty_generate(config)
dbus_object.SetConfig(serialized_config)
end

private

# @return [::DBus::Object]
Expand Down
43 changes: 27 additions & 16 deletions service/lib/agama/manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,30 +83,19 @@ def startup_phase
service_status.idle
end

def locale=(locale)
service_status.busy
change_process_locale(locale)
users.update_issues
start_progress_with_descriptions(
_("Load software translations"),
_("Load storage translations")
)
progress.step { software.locale = locale }
progress.step { storage.locale = locale }
ensure
service_status.idle
finish_progress
end

# Runs the config phase
def config_phase
service_status.busy
first_time = installation_phase.startup?
installation_phase.config

start_progress_with_descriptions(
_("Analyze disks"), _("Configure software")
)
progress.step { storage.probe }
# FIXME: hot-fix for bsc#1234711, see {#probe_and_recover_storage}. In autoinstallation, the
# storage config could be applied before probing. In that case, the config has to be
# recovered.
progress.step { first_time ? probe_and_recover_storage : storage.probe }
progress.step { software.probe }

logger.info("Config phase done")
Expand Down Expand Up @@ -159,6 +148,21 @@ def install_phase
end
# rubocop:enable Metrics/AbcSize

def locale=(locale)
service_status.busy
change_process_locale(locale)
users.update_issues
start_progress_with_descriptions(
_("Load software translations"),
_("Load storage translations")
)
progress.step { software.locale = locale }
progress.step { storage.locale = locale }
ensure
service_status.idle
finish_progress
end

# Software client
#
# @return [DBus::Clients::Software]
Expand Down Expand Up @@ -273,5 +277,12 @@ def iguana?

# @return [ServiceStatusRecorder]
attr_reader :service_status_recorder

# Probes storage and recover the current config, if any.
def probe_and_recover_storage
storage_config = storage.config
storage.probe
storage.config = storage_config unless storage_config.empty?
end
end
end
6 changes: 6 additions & 0 deletions service/package/rubygem-agama-yast.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Fri Dec 20 15:05:11 UTC 2024 - José Iván López González <[email protected]>

- Hotfix to avoid losing the storage config with auto installation
(bsc#1234711).

-------------------------------------------------------------------
Fri Dec 20 12:18:56 UTC 2024 - Josef Reidinger <[email protected]>

Expand Down

0 comments on commit cf131a8

Please sign in to comment.