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

web: Handle HTTP failures in storage #1203

Merged
merged 8 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
6 changes: 6 additions & 0 deletions web/package/agama-web-ui.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Tue May 14 12:24:23 UTC 2024 - José Iván López González <[email protected]>

- Make storage UI to work again when there is no device
joseivanlopez marked this conversation as resolved.
Show resolved Hide resolved
(gh#openSUSE/agama#1203).

-------------------------------------------------------------------
Tue May 14 11:17:45 UTC 2024 - Imobach Gonzalez Sosa <[email protected]>

Expand Down
31 changes: 10 additions & 21 deletions web/src/client/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,25 +197,6 @@ const EncryptionMethods = Object.freeze({
TPM: "tpm_fde"
});

/**
* Removes properties with undefined value
*
* @example
* removeUndefinedCockpitProperties({
* property1: { t: "s", v: "foo" },
* property2: { t: b, v: false },
* property3: { t: "s", v: undefined }
* });
* //returns { property1: { t: "s", v: "foo" }, property2: { t: "b", v: false } }
*
* @param {object} cockpitObject
* @returns {object}
*/
const removeUndefinedCockpitProperties = (cockpitObject) => {
const filtered = Object.entries(cockpitObject).filter(([, { v }]) => v !== undefined);
return Object.fromEntries(filtered);
};

/**
* Gets the basename of a D-Bus path
*
Expand Down Expand Up @@ -373,6 +354,7 @@ class DevicesManager {
const response = await this.client.get(`/storage/devices/${this.rootPath}`);
if (!response.ok) {
console.warn("Failed to get storage devices: ", response);
return [];
}
const jsonDevices = await response.json();
return jsonDevices.map(d => buildDevice(d, jsonDevices));
Expand Down Expand Up @@ -411,6 +393,7 @@ class ProposalManager {
const response = await this.client.get("/storage/proposal/usable_devices");
if (!response.ok) {
console.warn("Failed to get usable devices: ", response);
return [];
}
const usable_devices = await response.json();
return usable_devices.map(name => findDevice(systemDevices, name)).filter(d => d);
Expand Down Expand Up @@ -459,6 +442,7 @@ class ProposalManager {
const response = await this.client.get("/storage/product/params");
if (!response.ok) {
console.warn("Failed to get product params: ", response);
return [];
}

return response.json().then(params => params.mountPoints);
Expand All @@ -473,6 +457,7 @@ class ProposalManager {
const response = await this.client.get("/storage/product/params");
if (!response.ok) {
console.warn("Failed to get product params: ", response);
return [];
}

return response.json().then(params => params.encryptionMethods);
Expand All @@ -482,13 +467,14 @@ class ProposalManager {
* Obtains the default volume for the given mount path
*
* @param {string} mountPath
* @returns {Promise<Volume>}
* @returns {Promise<Volume|undefined>}
*/
async defaultVolume(mountPath) {
const param = encodeURIComponent(mountPath);
const response = await this.client.get(`/storage/product/volume_for?mount_path=${param}`);
if (!response.ok) {
console.warn("Failed to get product volume: ", response);
return undefined;
}

const systemDevices = await this.system.getDevices();
Expand Down Expand Up @@ -1314,7 +1300,7 @@ class ISCSIManager {
/**
* Gets the iSCSI initiator
*
* @return {Promise<ISCSIInitiator>}
* @return {Promise<ISCSIInitiator|undefined>}
*
* @typedef {object} ISCSIInitiator
* @property {string} name
Expand All @@ -1324,6 +1310,7 @@ class ISCSIManager {
const response = await this.client.get("/storage/iscsi/initiator");
if (!response.ok) {
console.error("Failed to get the iSCSI initiator", response);
return undefined;
}

return response.json();
Expand Down Expand Up @@ -1357,6 +1344,7 @@ class ISCSIManager {
const response = await this.client.get("/storage/iscsi/nodes");
if (!response.ok) {
console.error("Failed to get the list of iSCSI nodes", response);
return [];
}

return response.json();
Expand Down Expand Up @@ -1574,6 +1562,7 @@ class StorageBaseClient {
const response = await this.client.get("/storage/devices/dirty");
if (!response.ok) {
console.warn("Failed to get storage devices dirty: ", response);
return false;
}
return response.json();
}
Expand Down
Loading
Loading