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

No internal registry support for 2.8.3 #2870

Merged
Show file tree
Hide file tree
Changes from all 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
10 changes: 7 additions & 3 deletions frontend/src/__mocks__/mockImageStreamK8sResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@ type MockResourceConfigType = {
name?: string;
namespace?: string;
displayName?: string;
imageTag?: string;
tagName?: string;
opts?: RecursivePartial<ImageStreamKind>;
};

export const mockImageStreamK8sResource = ({
name = 'test-imagestream',
namespace = 'test-project',
displayName = 'Test Image',
imageTag = 'quay.io/opendatahub/notebooks@sha256:a138838e1c9acd7708462e420bf939e03296b97e9cf6c0aa0fd9a5d20361ab75',
tagName = '1.2',
opts = {},
}: MockResourceConfigType): ImageStreamKind =>
_.mergeWith(
Expand Down Expand Up @@ -48,15 +52,15 @@ export const mockImageStreamK8sResource = ({
},
tags: [
{
name: '1.2',
name: tagName,
annotations: {
'opendatahub.io/notebook-python-dependencies':
'[{"name":"JupyterLab","version": "3.2"}, {"name": "Notebook","version": "6.4"}]',
'opendatahub.io/notebook-software': '[{"name":"Python","version":"v3.8"}]',
},
from: {
kind: 'DockerImage',
name: 'quay.io/opendatahub/notebooks@sha256:a138838e1c9acd7708462e420bf939e03296b97e9cf6c0aa0fd9a5d20361ab75',
name: imageTag,
},
},
],
Expand All @@ -72,7 +76,7 @@ export const mockImageStreamK8sResource = ({
created: '2023-06-30T15:07:36Z',
dockerImageReference:
'quay.io/opendatahub/notebooks@sha256:a138838e1c9acd7708462e420bf939e03296b97e9cf6c0aa0fd9a5d20361ab75',
image: 'sha256:a138838e1c9acd7708462e420bf939e03296b97e9cf6c0aa0fd9a5d20361ab75',
image: imageTag,
generation: 2,
},
],
Expand Down
9 changes: 6 additions & 3 deletions frontend/src/__mocks__/mockNotebookK8sResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ type MockResourceConfigType = {
user?: string;
description?: string;
resources?: ContainerResources;
image?: string;
lastImageSelection?: string;
opts?: RecursivePartial<NotebookKind>;
};

Expand All @@ -22,6 +24,8 @@ export const mockNotebookK8sResource = ({
user = 'test-user',
description = '',
resources = DEFAULT_NOTEBOOK_SIZES[0].resources,
image = 'test-imagestream:1.2',
lastImageSelection = 's2i-minimal-notebook:py3.8-v1',
opts = {},
}: MockResourceConfigType): NotebookKind =>
_.merge(
Expand All @@ -32,7 +36,7 @@ export const mockNotebookK8sResource = ({
annotations: {
'notebooks.kubeflow.org/last-activity': '2023-02-14T21:45:14Z',
'notebooks.opendatahub.io/inject-oauth': 'true',
'notebooks.opendatahub.io/last-image-selection': 's2i-minimal-notebook:py3.8-v1',
'notebooks.opendatahub.io/last-image-selection': lastImageSelection,
'notebooks.opendatahub.io/last-size-selection': 'Small',
'notebooks.opendatahub.io/oauth-logout-url':
'http://localhost:4010/projects/project?notebookLogout=workbench',
Expand Down Expand Up @@ -96,8 +100,7 @@ export const mockNotebookK8sResource = ({
},
},
],
image:
'image-registry.openshift-image-registry.svc:5000/redhat-ods-applications/s2i-minimal-notebook:py3.8-v1',
image,
imagePullPolicy: 'Always',
livenessProbe: {
failureThreshold: 3,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,18 @@ import { projectDetails } from '~/__tests__/cypress/cypress/pages/projects';
type HandlersProps = {
isEmpty?: boolean;
imageStreamName?: string;
imageStreamTag?: string;
disableKServeConfig?: boolean;
disableKServeMetrics?: boolean;
disableModelConfig?: boolean;
isEnabled?: string;
isUnknown?: boolean;
};

const initIntercepts = ({
isEmpty = false,
imageStreamName = 'test-image',
imageStreamTag = 'latest',
isEnabled = 'true',
isUnknown = false,
}: HandlersProps) => {
Expand Down Expand Up @@ -99,14 +104,14 @@ const initIntercepts = ({
spec: {
tags: [
{
name: 'latest',
name: imageStreamTag,
},
],
},
status: {
tags: [
{
tag: 'latest',
tag: imageStreamTag,
},
],
},
Expand Down Expand Up @@ -185,7 +190,7 @@ describe('Project Details', () => {
});

it('Notebook with deleted image', () => {
initIntercepts({ imageStreamName: 'test' });
initIntercepts({ imageStreamName: 'test', imageStreamTag: 'failing-tag' });
projectDetails.visit('test-project');
const notebookRow = projectDetails.getNotebookRow('test-notebook');
notebookRow.shouldHaveNotebookImageName('Test image');
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/__tests__/cypress/cypress/pages/modelServing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,10 @@ class ServingRuntimeModal extends Modal {
}
}

// Expect KServeModal to inherit both modal classes.
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
interface KServeModal extends ServingRuntimeModal, InferenceServiceModal {}
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
class KServeModal extends InferenceServiceModal {}
mixin(KServeModal, [ServingRuntimeModal, InferenceServiceModal]);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
import { mockNotebookK8sResource } from '~/__mocks__/mockNotebookK8sResource';
import { mockImageStreamK8sResource } from '~/__mocks__/mockImageStreamK8sResource';
import { getNotebookImageData } from '~/pages/projects/screens/detail/notebooks/useNotebookImageData';
import { NotebookImageAvailability } from '~/pages/projects/screens/detail/notebooks/const';

describe('getNotebookImageData', () => {
it('should return image data when image stream exists and image version exists with internal registry', () => {
const notebook = mockNotebookK8sResource({
image:
'quay.io/opendatahub/notebooks@sha256:a138838e1c9acd7708462e420bf939e03296b97e9cf6c0aa0fd9a5d20361ab75',
lastImageSelection: 'jupyter-datascience-notebook',
});
const images = [
mockImageStreamK8sResource({
imageTag:
'quay.io/opendatahub/notebooks@sha256:a138838e1c9acd7708462e420bf939e03296b97e9cf6c0aa0fd9a5d20361ab75',
name: 'jupyter-datascience-notebook',
}),
];
const result = getNotebookImageData(notebook, images);
expect(result?.imageAvailability).toBe(NotebookImageAvailability.ENABLED);
});

it('should return image data when image stream exists and image version exists without internal registry', () => {
const imageName = 'jupyter-datascience-notebook';
const tagName = '2024.1';
const notebook = mockNotebookK8sResource({
image: `image-registry.openshift-image-registry.svc:5000/opendatahub/${imageName}:${tagName}`,
lastImageSelection: 'jupyter-datascience-notebook',
});
const images = [
mockImageStreamK8sResource({
imageTag:
'quay.io/opendatahub/notebooks@sha256:a138838e1c9acd7708462e420bf939e03296b97e9cf6c0aa0fd9a5d20361ab75',
tagName,
name: imageName,
}),
];
const result = getNotebookImageData(notebook, images);
expect(result?.imageAvailability).toBe(NotebookImageAvailability.ENABLED);
});

it('should return the right image if multiple ImageStreams have the same image with internal registry', () => {
const displayName = 'Jupyter Data Science Notebook';
const notebook = mockNotebookK8sResource({
image:
'quay.io/opendatahub/notebooks@sha256:a138838e1c9acd7708462e420bf939e03296b97e9cf6c0aa0fd9a5d20361ab75',
lastImageSelection: 'jupyter-datascience-notebook',
});
const images = [
mockImageStreamK8sResource({
imageTag:
'quay.io/opendatahub/notebooks@sha256:a138838e1c9acd7708462e420bf939e03296b97e9cf6c0aa0fd9a5d20361ab75',
name: 'jupyter-datascience-notebook',
displayName,
}),
mockImageStreamK8sResource({
imageTag:
'quay.io/opendatahub/notebooks@sha256:a138838e1c9acd7708462e420bf939e03296b97e9cf6c0aa0fd9a5d20361ab75',
name: 'custom-notebook',
displayName: 'Custom Notebook',
}),
];
const result = getNotebookImageData(notebook, images);
expect(result?.imageDisplayName).toBe(displayName);
});

it('should return the right image if multiple ImageStreams have the same tag without internal registry', () => {
const imageName = 'jupyter-datascience-notebook';
const tagName = '2024.1';
const displayName = 'Jupyter Data Science Notebook';
const notebook = mockNotebookK8sResource({
image: `image-registry.openshift-image-registry.svc:5000/opendatahub/${imageName}:${tagName}`,
lastImageSelection: 'jupyter-datascience-notebook',
});
const images = [
mockImageStreamK8sResource({
imageTag:
'quay.io/opendatahub/notebooks@sha256:a138838e1c9acd7708462e420bf939e03296b97e9cf6c0aa0fd9a5d20361ab75',
tagName,
name: 'code-server',
displayName: 'Code Server',
}),
mockImageStreamK8sResource({
imageTag:
'quay.io/opendatahub/notebooks@sha256:a138838e1c9acd7708462e420bf939e03296b97e9cf6c0aa0fd9a5d20361ab75',
tagName,
name: imageName,
displayName,
}),
];
const result = getNotebookImageData(notebook, images);
expect(result?.imageDisplayName).toBe(displayName);
});

it('should return image data when image stream exists and image version does not exist', () => {
const notebook = mockNotebookK8sResource({
image:
'quay.io/opendatahub/notebooks@sha256:a138838e1c9acd7708462e420bf939e03296b97e9cf6c0aa0fd9a5d20361ab75',
});
const images = [
mockImageStreamK8sResource({
imageTag: 'quay.io/opendatahub/notebooks@sha256:invalid',
}),
];
const result = getNotebookImageData(notebook, images);
expect(result?.imageAvailability).toBe(NotebookImageAvailability.DELETED);
});
});
Loading
Loading