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

Invalid storage device handling #488

Merged
merged 8 commits into from
Mar 22, 2023
Merged
Show file tree
Hide file tree
Changes from 6 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
4 changes: 4 additions & 0 deletions .yupdate.pre
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
# run the yupdate script several times
#

if [ "$YUPDATE_SKIP_FRONTEND" == "1" ]; then
exit 0
fi

# the needed packages for compiling the d-installer cockpit module
PACKAGES=(appstream-glib-devel make npm)

Expand Down
68 changes: 36 additions & 32 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -93,41 +93,45 @@ SERVICES_DIR = "/usr/share/dbus-1/d-installer-services"
if File.exist?("/.packages.initrd") || `mount`.match?(/^[\w]+ on \/ type overlay/)
Rake::Task["install"].clear
task :install do
destdir = ENV["DESTDIR"] || "/"

puts "Installing the DBus service..."
Dir.chdir("service") do
sh "gem build d-installer.gemspec"
sh "gem install --local --force --no-format-exec --no-doc --build-root #{destdir.shellescape} d-installer-*.gem"

# update the DBus configuration files
FileUtils.mkdir_p(SERVICES_DIR)
sh "cp share/org.opensuse.DInstaller*.service #{SERVICES_DIR}"
sh "cp share/dbus.conf /usr/share/dbus-1/d-installer.conf"

# update the systemd service file
source_file = "share/systemd.service"
target_file = "/usr/lib/systemd/system/d-installer.service"

unless FileUtils.identical?(source_file, target_file)
FileUtils.cp(source_file, target_file)
sh "systemctl daemon-reload"
if ENV["YUPDATE_SKIP_BACKEND"] != "1"
imobachgs marked this conversation as resolved.
Show resolved Hide resolved
destdir = ENV["DESTDIR"] || "/"

puts "Installing the DBus service..."
Dir.chdir("service") do
sh "gem build d-installer.gemspec"
sh "gem install --local --force --no-format-exec --no-doc --build-root #{destdir.shellescape} d-installer-*.gem"

# update the DBus configuration files
FileUtils.mkdir_p(SERVICES_DIR)
sh "cp share/org.opensuse.DInstaller*.service #{SERVICES_DIR}"
sh "cp share/dbus.conf /usr/share/dbus-1/d-installer.conf"

# update the systemd service file
source_file = "share/systemd.service"
target_file = "/usr/lib/systemd/system/d-installer.service"

unless FileUtils.identical?(source_file, target_file)
FileUtils.cp(source_file, target_file)
sh "systemctl daemon-reload"
end
end
end

puts "Installing the Web frontend..."
Dir.chdir("web") do
node_env = ENV["NODE_ENV"] || "production"
sh "NODE_ENV=#{node_env.shellescape} make install"

# clean up the extra files when switching the development/production mode
if node_env == "production"
# remove the uncompressed and development files
FileUtils.rm_f(Dir.glob("/usr/share/cockpit/d-installer/index.{css,html,js}"))
FileUtils.rm_f(Dir.glob("/usr/share/cockpit/d-installer/*.map"))
else
# remove the compressed files
FileUtils.rm_f(Dir.glob("/usr/share/cockpit/d-installer/*.gz"))
if ENV["YUPDATE_SKIP_FRONTEND"] != "1"
puts "Installing the Web frontend..."
Dir.chdir("web") do
node_env = ENV["NODE_ENV"] || "production"
sh "NODE_ENV=#{node_env.shellescape} make install"

# clean up the extra files when switching the development/production mode
if node_env == "production"
# remove the uncompressed and development files
FileUtils.rm_f(Dir.glob("/usr/share/cockpit/d-installer/index.{css,html,js}"))
FileUtils.rm_f(Dir.glob("/usr/share/cockpit/d-installer/*.map"))
else
# remove the compressed files
FileUtils.rm_f(Dir.glob("/usr/share/cockpit/d-installer/*.gz"))
end
end
end
end
Expand Down
6 changes: 6 additions & 0 deletions doc/yupdate.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ You can modify the update process with these environment variables:
mode. The files will not be minimized and additional `*.map` files will be
generated. This helps with debugging in the browser, you can get the locations
in the original source files.
- `YUPDATE_SKIP_FRONTEND=1` - Skip updating the web frontend. Use this option
when you use the webpack development server for running the web frontend.
In that case updating the web frontend does not make sense because it is
running in a different server. This saves some time and disk/RAM space.
- `YUPDATE_SKIP_BACKEND=1` - Skip updating the DBus service backend. This is the
lslezak marked this conversation as resolved.
Show resolved Hide resolved
opposite case for the previous option.
lslezak marked this conversation as resolved.
Show resolved Hide resolved

## Notes

Expand Down
5 changes: 2 additions & 3 deletions service/lib/dinstaller/dbus/with_service_status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,9 @@ def service_status
# @return [Object] the result of the given block
def busy_while(&block)
service_status.busy
result = block.call
block.call
ensure
service_status.idle

result
end
end
end
Expand Down
6 changes: 6 additions & 0 deletions service/package/rubygem-d-installer.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Tue Mar 21 16:44:27 UTC 2023 - Ladislav Slezák <[email protected]>

- Fixed exception handling so service always goes back to the
"idle" state when finishing a block (related to bsc#1209523)

-------------------------------------------------------------------
Tue Mar 21 16:28:26 UTC 2023 - Ancor Gonzalez Sosa <[email protected]>

Expand Down
12 changes: 12 additions & 0 deletions service/test/dinstaller/dbus/with_service_status_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,17 @@ class WithServiceStatusTest
result = subject.busy_while { "test" }
expect(result).to eq("test")
end

context "the passed block raises an exception" do
it "sets the idle status and passes the exception up" do
expect(subject.service_status).to receive(:busy)
expect(subject.service_status).to receive(:idle)

class TestException < RuntimeError; end

expect { subject.busy_while { raise TestException } }.to raise_error(TestException)
end
end

end
end
6 changes: 6 additions & 0 deletions web/package/cockpit-d-installer.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Tue Mar 21 16:41:06 UTC 2023 - Ladislav Slezák <[email protected]>

- Do not crash when setting an invalid target device using the
command line interface (bsc#1209523)

-------------------------------------------------------------------
Mon Mar 20 15:13:28 UTC 2023 - Imobach Gonzalez Sosa <[email protected]>

Expand Down
8 changes: 8 additions & 0 deletions web/src/components/storage/ProposalSummary.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ export default function ProposalSummary({ proposal }) {
const [candidateDevice] = result.candidateDevices;
const device = proposal.availableDevices.find(d => d.id === candidateDevice);

if (device === undefined) {
return (
<Text>
Required device <Em>{candidateDevice}</Em> not found
</Text>
);
}

return (
<Text>
Install using device <Em>{device.label}</Em> and deleting all its content
Expand Down