Skip to content

Commit

Permalink
Fix for untrue !Deleted flag
Browse files Browse the repository at this point in the history
  • Loading branch information
ashley-o0o committed Jul 31, 2024
1 parent 81961d4 commit 3a73507
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,21 @@ describe('getNotebookImageData', () => {
const result = getNotebookImageData(notebook, images);
expect(result?.imageAvailability).toBe(NotebookImageAvailability.DELETED);
});

it('should fail without fix', () => {
const imageName = 'jupyter-datascience-notebook';
const tagName = '2024.1';
const notebook = mockNotebookK8sResource({
lastImageSelection: `${imageName}:${tagName}`,
image: `image-registry.openshift-image-registry.svc:5000/opendatahub/${imageName}:${tagName}`,
});
const images = [
mockImageStreamK8sResource({
tagName,
name: imageName,
}),
];
const result = getNotebookImageData(notebook, images);
expect(result?.imageAvailability).toBe(NotebookImageAvailability.ENABLED);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,19 @@ export const getNotebookImageData = (
}

const [imageName, versionName] = imageTag;
const [lastImageSelectionName] =
const [lastImageSelectionName, lastImageSelectionTag] =
notebook.metadata.annotations?.['notebooks.opendatahub.io/last-image-selection']?.split(':') ??
[];

// Fallback for non internal registry clusters
const imageStream =
images.find((image) => image.metadata.name === imageName) ||
images.find((image) =>

Check failure on line 34 in frontend/src/pages/projects/screens/detail/notebooks/useNotebookImageData.ts

View workflow job for this annotation

GitHub Actions / Tests (18.x)

Insert `⏎······`
image.spec.tags
? image.spec.tags.find(
image.metadata.name === lastImageSelectionName &&

Check failure on line 35 in frontend/src/pages/projects/screens/detail/notebooks/useNotebookImageData.ts

View workflow job for this annotation

GitHub Actions / Tests (18.x)

Insert `····`
(image.spec.tags?.find(

Check failure on line 36 in frontend/src/pages/projects/screens/detail/notebooks/useNotebookImageData.ts

View workflow job for this annotation

GitHub Actions / Tests (18.x)

Replace `⏎············(version)·=>⏎··············version.from?.name·===·container.image⏎··········)·||·image.status?.tags?.find(version·=>·version.tag·===·lastImageSelectionTag·&&·version.items?.find(item·=>·item.dockerImageReference·===·container.image)))` with `(version)·=>·version.from?.name·===·container.image)·||⏎··········image.status?.tags?.find(⏎············(version)·=>⏎··············version.tag·===·lastImageSelectionTag·&&⏎··············version.items?.find((item)·=>·item.dockerImageReference·===·container.image),⏎··········)),`
(version) =>
version.from?.name === container.image &&
image.metadata.name === lastImageSelectionName,
)
: false,
version.from?.name === container.image
) || image.status?.tags?.find(version => version.tag === lastImageSelectionTag && version.items?.find(item => item.dockerImageReference === container.image)))
);

// if the image stream is not found, consider it deleted
Expand All @@ -54,7 +52,7 @@ export const getNotebookImageData = (

const versions = imageStream.spec.tags || [];
const imageVersion = versions.find(
(version) => version.name === versionName || version.from?.name === container.image,
(version) => version.name === versionName || version.from?.name === container.image || version.name === lastImageSelectionTag,

Check failure on line 55 in frontend/src/pages/projects/screens/detail/notebooks/useNotebookImageData.ts

View workflow job for this annotation

GitHub Actions / Tests (18.x)

Replace `·version.name·===·versionName·||·version.from?.name·===·container.image·||` with `⏎······version.name·===·versionName·||⏎······version.from?.name·===·container.image·||⏎·····`
);

// because the image stream was found, get its display name
Expand Down

0 comments on commit 3a73507

Please sign in to comment.