-
Notifications
You must be signed in to change notification settings - Fork 179
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
Parse BYON repository URL correctly #1249
Parse BYON repository URL correctly #1249
Conversation
@@ -130,3 +130,6 @@ export const DEFAULT_NOTEBOOK_SIZES: NotebookSize[] = [ | |||
}, | |||
}, | |||
]; | |||
|
|||
export const imageUrlRegex = | |||
/^([\w.\-_]+((?::\d+|)(?=\/[a-z0-9._-]+\/[a-z0-9._-]+))|)(?:\/|)([a-z0-9.\-_]+(?:\/[a-z0-9.\-_]+|))(?::([\w.\-_]{1,127})|)/; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This regex won't match @sha256...
as the tag because if use that, we cannot set it as the tag name. So in the custom image, the tag name will be set to latest
but the repo URL will be set to the correct one with @sha256
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh my gosh -- we need you to comment this in some fashion haha... wowzers, that's a regex and a half haha.
@vconzola Please check the UI change for the error state of the custom images as listed in the description. |
@DaoDaoNoCode As long as invalid images are hidden from non-admin users in the spawner dropdowns, the UX LGTM. |
// check if the host is valid | ||
if (!matchArray[1]) { | ||
fastify.log.error('Invalid repository URL unable to add notebook image'); | ||
return { success: false, error: 'Invalid repository URL: ' + fullUrl }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess that's the way we had the endpoint configure, but I'm not a fan of returning a 200 with a failing state, rather than using the proper error code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, there is a lot of uncomfortable stuff with this area of the code -- I'm viewing the UI and noticing a lot of inconsistencies to the other parts of our app... we will need to rework this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
I left a little nit, but at this point I don't think we should do major refactors to the backend so it's ok.
test('OpenShift internal registry URL with tag', () => { | ||
const url = | ||
'image-registry.openshift-image-registry.svc:5000/opendatahub/s2i-minimal-notebook:v0.3.0-py36'; | ||
const match = url.match(REPOSITORY_URL_REGEX); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should have been a function wrapping to give 1/4 a real name instead of magic-ness... these tests showcase that just in reading of the test lines.
} | ||
return ( | ||
<Tooltip removeFindDomNode role="none" content={<Text>{image.error}</Text>}> | ||
<Icon role="button" aria-label="error icon" status="danger" isInline tabIndex={0}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel this is not the best way to make it tab-enabled... because you're explicitly setting the tab index to 0. We did this elsewhere with a button: https://github.com/opendatahub-io/odh-dashboard/blob/main/frontend/src/components/SupportedAppTitle.tsx#L22-L30
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will log a tech debt to clean up some of these things... this is bad for maintenance, but this works as-is... so we'll want to clean it up next sprint.
EDIT: for posterity, #1326
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: andrewballantyne, lucferbux The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Closes #1085
Description
The PR did the following things:
latest
, because it will automatically fetch the latest tag if you create an image stream without specifying the tag nameBecause some docker container images might not have the
latest
tag or might not have the tag user specifies, it could throw an error if the tag cannot be found. In this situation, we show the error in the BYON image table to the admin users and hide the image from the spawner page of both the KFNBC and DS projects.UX/UI change: Add an error state and tooltip to invalid BYON images
How Has This Been Tested?
jupyter
, also you can go to search the OpenShift internal image streams likeimage-registry.openshift-image-registry.svc:5000/opendatahub/s2i-minimal-notebook
. Try to create some with and without the tagslatest
tag and import that image without specifying the tagTest Impact
Add some jest tests to make sure the regex could parse the URL correctly.
Request review criteria: