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

Fix validation in the storage modal mount path #3236

Merged

Conversation

DaoDaoNoCode
Copy link
Member

@DaoDaoNoCode DaoDaoNoCode commented Sep 20, 2024

JIRA: https://issues.redhat.com/browse/RHOAIENG-7680

Description

There is something wrong with the logic in the helper text and what error text we should show. I made some changes to that to correct the logic. Also, change the regex to allow a trailing / in the path.

Initial state:

Screenshot 2024-09-20 at 3 12 01 PM

Trailing slash:

Screenshot 2024-09-20 at 3 12 24 PM

Duplicate path:

Screenshot 2024-09-20 at 3 12 47 PM

Empty input:

Screenshot 2024-09-20 at 3 13 05 PM

Invalid value (contains number):

Screenshot 2024-09-20 at 3 13 30 PM

Invalid value (slash is not the trailing slash):

Screenshot 2024-09-20 at 3 14 32 PM

How Has This Been Tested?

  1. Create a cluster storage
  2. Attach it to a workbench
  3. Input in the mouth path field, check if it's allowing a trailing slash
  4. Check all the error states as listed above

Test Impact

Updated the cypress test to check the error cases.

Request review criteria:

Self checklist (all need to be checked):

  • The developer has manually tested the changes and verified that the changes work
  • Testing instructions have been added in the PR body (for PRs involving changes that are not immediately obvious).
  • The developer has added tests or explained why testing cannot be added (unit or cypress tests for related changes)

If you have UI changes:

  • Included any necessary screenshots or gifs if it was a UI change.
  • Included tags to the UX team if it was a UI/UX change.

After the PR is posted & before it merges:

  • The developer has tested their solution on a cluster by using the image produced by the PR to main

@DaoDaoNoCode
Copy link
Member Author

@andrewballantyne The bug you mentioned in #3231 (review) is not because of the connection path starts with a preexisting connection path, it's because you have a number 2 in your path, which is not allowed. The code had wrong logic of checking the error cases so it was showing an incorrect error message. The logic is fixed now in this PR.

@andrewballantyne
Copy link
Member

That logic is likely wrong fwiw -- but I suppose this PR doesn't have to deal with that

Copy link

codecov bot commented Sep 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.08%. Comparing base (a509cf4) to head (15d1363).
Report is 15 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #3236   +/-   ##
=======================================
  Coverage   85.07%   85.08%           
=======================================
  Files        1292     1292           
  Lines       28814    28813    -1     
  Branches     7749     7748    -1     
=======================================
+ Hits        24514    24516    +2     
+ Misses       4300     4297    -3     
Files with missing lines Coverage Δ
frontend/src/pages/projects/pvc/MountPathField.tsx 100.00% <100.00%> (+21.05%) ⬆️

... and 4 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a509cf4...15d1363. Read the comment docs.

Copy link
Contributor

@jpuzz0 jpuzz0 left a comment

Choose a reason for hiding this comment

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

Verified locally. Although you did not write the error messages of Must only consist of lower case letters and dashes and Mount folder is already in use for this workbench, I think these both are meant to end with periods.

Worth having @kaedward take a look at all of these screenshots of yours to be sure anyways. I don't consider this blocking.

frontend/src/pages/projects/pvc/MountPathField.tsx Outdated Show resolved Hide resolved
@@ -37,8 +37,8 @@ const MountPathField: React.FC<MountPathFieldProps> = ({
onChange={(e, value) => {
let error = '';
if (value.length === 0) {
error = 'Required';
} else if (!/^[a-z-]+$/.test(value)) {
error = 'Enter a path to a model or folder. This path cannot point to a root folder.';
Copy link
Contributor

Choose a reason for hiding this comment

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

Was this text been provided by UX? Maybe @kaedward could verify this tech content.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah I just moved the old text here https://github.com/opendatahub-io/odh-dashboard/blob/main/frontend/src/pages/projects/pvc/MountPathField.tsx#L55 to above because the helper text render logic was incorrect before.

@Gkrumbach07
Copy link
Member

Gkrumbach07 commented Sep 25, 2024

@DaoDaoNoCode it will except a duplicate path if you put a just a trailing slash, but will reject without it or if you add another folder to the end of the trailing slash

@DaoDaoNoCode
Copy link
Member Author

@Gkrumbach07 Reading the comment that @andrewballantyne left in the ticket:

I read the issue fast and missed your final remark – I was on a time crunch in the triage meeting and this was one of our last ones we were trying to get through.

I'll update my UX ping and just leave this on the backlog. I didn't know `/something/` was valid and I would think that this is equiv to `/something` anyways.

I think /something is different from /something/, did I understand wrongly? 🤔

@andrewballantyne
Copy link
Member

andrewballantyne commented Sep 25, 2024

Read the last line of the description

The trailing slash is still valid for the notebook object and should not throw an error in the UI. If you manually update the notebook object with a trailing slash it works perfectly fine.

Allow them to add a slash if they want.

@Gkrumbach07
Copy link
Member

if

/something is different from /something/

is true then this looks good, otherwise needs to be fixed?

@DaoDaoNoCode
Copy link
Member Author

@Gkrumbach07 I tested with both /something and /something/ set as the path and it works well, I think the notebook itself could handle the path. If that's not the case we can refine it later I guess.

@Gkrumbach07
Copy link
Member

no it can handle the path. i am saying it allows me to create two pvcs one with /something and the other with /something/... both attached to the same workbench. i tested it and it wont let the notebook start

@DaoDaoNoCode
Copy link
Member Author

@Gkrumbach07 My notebook start and running

Screenshot 2024-09-25 at 3 42 13 PM

@Gkrumbach07
Copy link
Member

i still cannot replicate it. Are you restarting the workbench pods after you add both PVCs to it

@DaoDaoNoCode
Copy link
Member Author

@Gkrumbach07 Hmm, I added it to a stopped notebook, and click toggle the start manually.

@Gkrumbach07
Copy link
Member

well i cant get a workbench to spawn at all im pretty sure so something is wrong on my end. I wont hold this PR up then

/lgtm
/approve

Copy link
Contributor

openshift-ci bot commented Sep 25, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Gkrumbach07, jpuzz0

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@pnaik1
Copy link
Contributor

pnaik1 commented Sep 26, 2024

/retest

@openshift-merge-bot openshift-merge-bot bot merged commit ca27d1d into opendatahub-io:main Sep 26, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants