Skip to content

Commit

Permalink
Notifications: display entire error message when image compose fails
Browse files Browse the repository at this point in the history
  • Loading branch information
jkozol committed Feb 23, 2023
1 parent 1246bf6 commit 18cb469
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 28 deletions.
3 changes: 0 additions & 3 deletions src/components/Notifications/Notifications.css

This file was deleted.

18 changes: 5 additions & 13 deletions src/components/Notifications/Notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import {
} from "@patternfly/react-core";
import { selectAllAlerts, removeAlert } from "../../slices/alertsSlice";

import "./Notifications.css";

const Notifications = () => {
const dispatch = useDispatch();
const getAlerts = () => useSelector(selectAllAlerts);
Expand All @@ -24,7 +22,6 @@ const Notifications = () => {
case "composeQueued": {
return (
<Alert
id="alertComposeQueued"
key={alert.id}
variant="info"
title={
Expand All @@ -47,7 +44,6 @@ const Notifications = () => {
case "composeStarted": {
return (
<Alert
id="alertComposeStarted"
key={alert.id}
variant="info"
title={
Expand All @@ -74,7 +70,6 @@ const Notifications = () => {
case "composeSucceeded": {
return (
<Alert
id="alertComposeSucceeded"
key={alert.id}
variant="success"
title={
Expand All @@ -101,23 +96,20 @@ const Notifications = () => {
case "composeFailed": {
return (
<Alert
id="alertComposeFailed"
isExpandable
key={alert.id}
variant="danger"
title={
<FormattedMessage
defaultMessage="{blueprint} Image creation failed."
values={{
blueprint: <strong>{alert.blueprintName}:</strong>,
}}
/>
<FormattedMessage defaultMessage="Image creation failed." />
}
actionClose={
<AlertActionCloseButton
onClose={() => dispatch(removeAlert(alert.id))}
/>
}
></Alert>
>
<p>{alert.error}</p>
</Alert>
);
}
default:
Expand Down
7 changes: 7 additions & 0 deletions src/slices/alertsSlice.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ const alertsSlice = createSlice({
blueprintName: action.payload,
});
});
builder.addCase("images/create/rejected", (state, action) => {
alertsAdapter.addOne(state, {
id: uuidv4(),
type: "composeFailed",
error: action.payload,
});
});
},
});

Expand Down
27 changes: 16 additions & 11 deletions src/slices/imagesSlice.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,24 @@ export const fetchAllImages = createAsyncThunk("images/fetchAll", async () => {

export const createImage = createAsyncThunk(
"images/create",
async (args, { dispatch }) => {
async (args, { dispatch, rejectWithValue }) => {
const { blueprintName, type, size, ostree, upload } = args;
const sizeBytes = size * 1024 * 1024 * 1024;
const response = await api.createImage(
blueprintName,
type,
sizeBytes,
ostree,
upload
);
const imageId = response.build_id;
dispatch(fetchImage(imageId));
return blueprintName;
try {
const response = await api.createImage(
blueprintName,
type,
sizeBytes,
ostree,
upload
);
const imageId = response.build_id;
dispatch(fetchImage(imageId));
return blueprintName;
} catch (error) {
const msg = error?.body?.errors[0]?.msg;
return rejectWithValue(msg);
}
}
);

Expand Down
2 changes: 1 addition & 1 deletion translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@
"hzmswI": "Groups",
"i0ngz5": "OpenSCAP",
"idJaPS": "AWS region",
"jCoHMn": "Image creation failed.",
"jPcnu+": "OCI bucket",
"jvo0vs": "Save",
"kPQ+0U": "A source with this name already exists.",
Expand Down Expand Up @@ -207,7 +208,6 @@
"uRdfZs": "Upload to GCP",
"vAPLDS": "Toggle which package list to show",
"vXCeIi": "Failed",
"vr2saa": "{blueprint} Image creation failed.",
"w2BSgE": "Ignition",
"wV8yqy": "Stop build",
"wcW8tX": "Bucket namespace",
Expand Down

1 comment on commit 18cb469

@packit-as-a-service
Copy link

Choose a reason for hiding this comment

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

Based on your Packit configuration the settings of the @osbuild/cockpit-composer Copr project would need to be updated as follows:

field old value new value
chroots ['epel-8-x86_64'] ['centos-stream-8-x86_64', 'centos-stream-9-x86_64', 'epel-8-x86_64', 'epel-9-x86_64', 'fedora-36-x86_64', 'fedora-37-x86_64', 'fedora-rawhide-x86_64']

Diff of chroots:

+fedora-rawhide-x86_64
+epel-9-x86_64
+centos-stream-8-x86_64
+fedora-36-x86_64
+fedora-37-x86_64
+centos-stream-9-x86_64

Packit was unable to update the settings above as it is missing admin permissions on the @osbuild/cockpit-composer Copr project.

To fix this you can do one of the following:

  • Grant Packit admin permissions on the @osbuild/cockpit-composer Copr project on the permissions page.
  • Change the above Copr project settings manually on the settings page to match the Packit configuration.
  • Update the Packit configuration to match the Copr project settings.

Please retrigger the build, once the issue above is fixed.

Please sign in to comment.