Skip to content

Commit

Permalink
fix: Ingore services already deleted (#1166)
Browse files Browse the repository at this point in the history
* fix: Ingore services already deleted
  • Loading branch information
aleixhub authored May 2, 2023
1 parent 73ded58 commit 51b964c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
18 changes: 16 additions & 2 deletions catalog/ui/src/app/Services/ServicesList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,14 @@ const ServicesList: React.FC<{
resourceClaimName: resourceClaim.metadata.name,
})
);
return await deleteResourceClaim(resourceClaim);
try {
return await deleteResourceClaim(resourceClaim);
} catch (error) {
if (error.status === 404) {
return resourceClaim;
}
throw error;
}
} else {
const isPartOfWorkshop = isResourceClaimPartOfWorkshop(resourceClaim);
if (isPartOfWorkshop) return resourceClaim; // If has a workshopProvision -> Do nothing.
Expand All @@ -279,7 +286,14 @@ const ServicesList: React.FC<{
const performModalActionForWorkshop = useCallback(
async (workshop: WorkshopWithResourceClaims): Promise<WorkshopWithResourceClaims> => {
if (modalState.action === 'delete') {
return await deleteWorkshop(workshop);
try {
return await deleteWorkshop(workshop);
} catch (error) {
if (error.status === 404) {
return workshop;
}
throw error;
}
} else {
if (Array.isArray(workshop.resourceClaims)) {
if (modalState.action === 'start') {
Expand Down
8 changes: 4 additions & 4 deletions catalog/ui/src/app/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1066,14 +1066,14 @@ export async function patchWorkshop({
jsonPatch?: JSONPatch;
patch?: Record<string, unknown>;
}): Promise<Workshop> {
return (await patchK8sObject({
return await patchK8sObject({
apiVersion: `${BABYLON_DOMAIN}/v1`,
jsonPatch: jsonPatch,
name: name,
namespace: namespace,
plural: 'workshops',
patch: patch,
}));
});
}

export async function patchWorkshopProvision({
Expand All @@ -1087,14 +1087,14 @@ export async function patchWorkshopProvision({
jsonPatch?: JSONPatch;
patch?: Record<string, unknown>;
}): Promise<WorkshopProvision> {
return (await patchK8sObject({
return await patchK8sObject({
apiVersion: `${BABYLON_DOMAIN}/v1`,
jsonPatch: jsonPatch,
name: name,
namespace: namespace,
plural: 'workshopprovisions',
patch: patch,
}));
});
}

export async function requestStatusForAllResourcesInResourceClaim(resourceClaim: ResourceClaim) {
Expand Down

0 comments on commit 51b964c

Please sign in to comment.