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

feat(software): Reload repositories after failure #1894

Merged
merged 18 commits into from
Jan 20, 2025
Merged

Conversation

lslezak
Copy link
Contributor

@lslezak lslezak commented Jan 14, 2025

Problem

agama-repo-failed

  • When repository refresh fails there is no way how to retry the operation
  • The only workaround is to select a different product and then select back the original product
  • This obviously won't work if the installer contains only one product

Solution

  • Detect that a repository failed and offer a reload action

Recording

SLES4SAP-screen0.webm
  • There is a new error section with "retry" link
  • Unfortunately the VirtualBox does not record the mouse pointer so it not obvious that the "Try again" link was clicked by mouse
  • For easier testing I used a local copy of the SLE repository to easily simulate unreachable repository and make it working for the retry attempt. That's why you see a different (local) repository in the recording.

Details

  • It turned out that it is not simple to detect a repository failure in the software page.
  • It reports an issue but it might contain a translated text or there might be a different issue like missing product or pattern. That means we cannot use the issues texts.
  • We will very likely need a repository management later anyway it makes sense to add API for fetching the current repository setup with the load status (succeeded or failed).

Tasks

  • DBus interface for listing the current repository setup (added the ListRepositories DBus method)
  • Add the HTTP API endpoint /api/software/repositories using the DBus backend above (@jreidinger thanks!)
  • Adapt the frontend code to show a failure
  • Adapt the frontend to retry after clicking a button

@coveralls
Copy link

coveralls commented Jan 17, 2025

Pull Request Test Coverage Report for Build 12872505669

Details

  • 1 of 21 (4.76%) changed or added relevant lines in 3 files are covered.
  • 9 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.05%) to 70.868%

Changes Missing Coverage Covered Lines Changed/Added Lines %
service/lib/agama/dbus/software/manager.rb 1 4 25.0%
rust/agama-server/src/software/web.rs 0 4 0.0%
rust/agama-lib/src/software/client.rs 0 13 0.0%
Files with Coverage Reduction New Missed Lines %
service/lib/agama/dbus/software/manager.rb 9 80.23%
Totals Coverage Status
Change from base Build 12870685697: -0.05%
Covered Lines: 17233
Relevant Lines: 24317

💛 - Coveralls

@lslezak lslezak marked this pull request as ready for review January 17, 2025 16:29
Copy link
Contributor

@dgdavid dgdavid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Web part looks good to me, just few NP comments.

@@ -1,4 +1,3 @@
/* eslint-disable */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NP: I believe such a line was there because the file is automatically generated. Let's ask @imobachgs or @joseivanlopez

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but I have removed it too in our feature branch. I have to check whether that line can be omitted somehow when generating the file.

web/src/components/software/SoftwarePage.tsx Outdated Show resolved Hide resolved
web/src/components/software/SoftwarePage.tsx Outdated Show resolved Hide resolved
@@ -67,6 +67,24 @@ def issues
private_constant :SOFTWARE_INTERFACE

dbus_interface SOFTWARE_INTERFACE do
# array of repository properties: pkg-bindings ID, alias, name, URL, product dir, enabled
# and loaded flag
dbus_method :ListRepositories, "out Result:a(issssbb)" do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In storage we are tending to other kind of interfaces. The storage API returns JSON data instead of D-Bus structs, dicts, etc. At the end, we are using D-Bus as a transport layer, and probably we will replace it in the future by a HTTP API. Having JSON data has 2 advandanges in our case:

  • Replacing D-Bus by HTTP will be almost transparent.
  • The rust code is only a proxy that defines an endpoint (it does not need to interpret the data coming from D-Bus).

I guess it is fine to continue with this approach using structs in software. Anyway, we want to rewrite this service in rust.

Copy link
Contributor

@joseivanlopez joseivanlopez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@imobachgs imobachgs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I trust @dgdavid when it comes to the UI. The rest looks good to me.

@@ -28,6 +28,7 @@ use serde_repr::Serialize_repr;
use std::collections::HashMap;
use zbus::Connection;

// TODO: move it to model?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. But there is not need to do it right now.

Comment on lines 127 to 141
const ReloadSection = (): React.ReactNode => (
// TRANSLATORS: title for an error message box, at least one repository could not be loaded
<Alert variant="danger" isInline title={_("Repository load failed")}>
{/* TRANSLATORS: error details followed by a "Try again" link*/}
{_(
"Some installation repositories could not be loaded. The system cannot be installed without them.",
)}{" "}
{loading ? (
<>
{" "}
<Spinner size="md" />
<Spinner size="md" /> {_("Loading the installation repositories...")}
</>
) : (
<Button variant="link" isInline onClick={startProbing}>
{/* TRANSLATORS: link for retrying failed repository load */}
{_("Try again")}
</Button>
<>
{errorMsg}{" "}
<Button variant="link" isInline onClick={startProbing}>
{/* TRANSLATORS: link for retrying failed repository load */}
{_("Try again")}
</Button>
</>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I forgot to mention in yestereday's review. Please, move this component outside of the component is using it. As far as I can see yo just need to give it an onReload prop

<ReloadSection onReload={startProbing} />

Reason for moving it outside: https://react.dev/learn/preserving-and-resetting-state.

We have had issues with that, for example #1550 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot about this, I didn't know it!

@lslezak lslezak merged commit 6901956 into master Jan 20, 2025
14 checks passed
@lslezak lslezak deleted the repository_retry branch January 20, 2025 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants