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

feat: modify behaviours for the enable button for NIM. #3558

Open
wants to merge 24 commits into
base: main
Choose a base branch
from

Conversation

yzhao583
Copy link
Contributor

@yzhao583 yzhao583 commented Dec 9, 2024

Jira: https://issues.redhat.com/browse/NVPE-37
Jira: https://issues.redhat.com/browse/NVPE-72

Description

  • Show Skeleton when visibility of the enable button is determined.
  • Disable the submit button if the API key is not provided by user.
  • Hide the link to remove the NIM app from the enabled apps page when NIM is disabled.
  • Hide the enable button after NIM app is enabled.
image image image

How Has This Been Tested?

  • Tested locally.

Test Impact

  • Go to the Explore page, select the NVIDIA NIM tile, and should see the Skeletonwhen loading. If NIM is enabled, the Enable button should be hidden, if NIM is disabled but can be enabled, the Enable button should be displayed, if NIM cannot be enabled, the Enable button should be displayed but the button should be disabled, hover the button, the tooltip should be displayed.
  • Click the Enable button, and the modal to enable NIM should be displayed. If no API key is provided, the Submit button should be disabled, otherwise, it should be enabled.
  • Provide API key, and click the Submit button. If validation success, the modal should be closed and the Enable button on the Explore page should be hidden.
  • Disable NIM and go to the Enable page -> click the disable on the top-right corner of the NIM tile, the link to remove NIM from this page should NOT be seen.

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

@openshift-ci openshift-ci bot added the needs-ok-to-test The openshift bot needs to label PRs from non members to avoid strain on the CI label Dec 9, 2024
Copy link
Contributor

openshift-ci bot commented Dec 9, 2024

Hi @yzhao583. Thanks for your PR.

I'm waiting for a opendatahub-io member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@yzhao583 yzhao583 force-pushed the NVPE-37-fix-the-enable-button-loading-issue branch from 39448bd to 97e4f94 Compare December 9, 2024 05:22
@yzhao583 yzhao583 force-pushed the NVPE-37-fix-the-enable-button-loading-issue branch 2 times, most recently from 1bed0fd to 7043b7e Compare December 9, 2024 05:49
@andrewballantyne
Copy link
Member

/ok-to-test

@openshift-ci openshift-ci bot added ok-to-test The openshift bot needs `ok-to-test` to allow non member PRs to run the tests. and removed needs-ok-to-test The openshift bot needs to label PRs from non members to avoid strain on the CI labels Dec 9, 2024
Copy link

codecov bot commented Dec 10, 2024

Codecov Report

Attention: Patch coverage is 18.75000% with 52 lines in your changes missing coverage. Please review.

Project coverage is 85.06%. Comparing base (8d3338c) to head (dd60b29).
Report is 13 commits behind head on main.

Files with missing lines Patch % Lines
frontend/src/utilities/useEnableApplication.tsx 5.26% 36 Missing ⚠️
frontend/src/components/OdhAppCard.tsx 0.00% 5 Missing ⚠️
...ntend/src/pages/exploreApplication/EnableModal.tsx 37.50% 5 Missing ⚠️
...d/src/pages/exploreApplication/GetStartedPanel.tsx 28.57% 5 Missing ⚠️
...nd/src/utilities/useWatchIntegrationComponents.tsx 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3558      +/-   ##
==========================================
+ Coverage   85.01%   85.06%   +0.05%     
==========================================
  Files        1404     1406       +2     
  Lines       32239    32332      +93     
  Branches     9038     9085      +47     
==========================================
+ Hits        27407    27503      +96     
+ Misses       4832     4829       -3     
Files with missing lines Coverage Δ
...pages/exploreApplication/useIntegratedAppStatus.ts 88.88% <100.00%> (+1.38%) ⬆️
frontend/src/types.ts 100.00% <100.00%> (ø)
...nd/src/utilities/useWatchIntegrationComponents.tsx 37.73% <0.00%> (ø)
frontend/src/components/OdhAppCard.tsx 61.90% <0.00%> (-2.03%) ⬇️
...ntend/src/pages/exploreApplication/EnableModal.tsx 33.92% <37.50%> (+1.85%) ⬆️
...d/src/pages/exploreApplication/GetStartedPanel.tsx 62.06% <28.57%> (-2.22%) ⬇️
frontend/src/utilities/useEnableApplication.tsx 24.34% <5.26%> (-3.92%) ⬇️

... and 18 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 8d3338c...dd60b29. Read the comment docs.

@emilys314
Copy link
Contributor

/lgtm

Copy link
Contributor

openshift-ci bot commented Dec 19, 2024

New changes are detected. LGTM label has been removed.

@openshift-ci openshift-ci bot removed the lgtm label Dec 19, 2024
Comment on lines 74 to 86
setEnableStatus({
status:
response.variablesValidationStatus === 'True'
? EnableApplicationStatus.SUCCESS
: EnableApplicationStatus.FAILED,
error:
response.variablesValidationStatus === 'True' ? '' : 'Variables are not valid',
});
dispatchResults(
response.variablesValidationStatus === 'True'
? undefined
: 'Variables are not valid',
);
Copy link
Contributor

@emilys314 emilys314 Dec 19, 2024

Choose a reason for hiding this comment

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

Also the first time I enabled NIM with the modal by entering a key, it will tell me it failed with "Variables are not valid". I believe this is because the response.variablesValidationStatus is 'Unknown'

But this code will think it failed unless it's True. So we should update this part to account for Unknown somehow

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@emilys314 The logic here is to check if response.variablesValidationStatus is true. If yes, dispatchResults. If the response.variablesValidationStatus is Unknown, it should loop again to check the status of the application.

Copy link
Contributor

@emilys314 emilys314 Jan 2, 2025

Choose a reason for hiding this comment

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

Oh okay so it depends on how you test it. If I just delete the nvidia-nim-access your PR will work fine and not give an error.

But if the key is invalid (deleted/incorrect/expired) then it will say it's erroring when I submit
image

The response I get back is {isInstalled: true, isEnabled: false, variablesValidationStatus: 'False', canInstall: true, error: ''}

That's because the getIntegrationAppEnablementStatus() is polling the existing secret which is invalid via the GET. Meanwhile the initial pending value of the POST enableIntegrationApp() quickly gets overwritten by the poller to invalid

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@emilys314 Good catch! I am having hard time fixing this.... Do you have any suggestion?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@emilys314 I have a solution but it is not very ideal.

Copy link
Contributor

Choose a reason for hiding this comment

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

@emilys314
Yes the conditions status will be reset.

There are two conditions for this to work:

  1. The secrest should be managed by ODH, indicated by a target label. See here.
  2. The secret is referenced by an Account. See here.

As long as these conditions stand, a reconcialtion will start with the initial "Unknown" status. See here.

cc: @swati-kale @yzhao583

Copy link
Contributor

Choose a reason for hiding this comment

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

I see thank you for the info Tomer, so I guess the issue is there will be a delay when the new api key is set and the validation status in the account. And this is pretty hard to get rid of.

@yzhao583 I think there is a solution we can implement in the UI to work around this. When we start polling the status, we can also return a variablesValidationTimestamp to check if we have a new value. So on submit, we store a timestamp in the UI, and while polling we will only update the status if the variablesValidationTimestamp is newer than the onSubmit timestamp one. I think you can also revert / replace your latest commit with this

Copy link
Contributor

Choose a reason for hiding this comment

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

@emilys314
We're also working on a way to speed up the status reporting. Currently, we report it at the end of the reconciliation; we'll change this behaviour to report more frequently while the reconciliation is still running. Regardless, this will remain an async operation. While it will be faster, checking the timestamp is better, as you suggested.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@emilys314 @TomerFi Thanks for the suggestions, I will implement the workaround to compare the time stamp.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@emilys314 @TomerFi @swati-kale Implemented the Timestamp workaround, please review again, thanks!

frontend/src/components/OdhAppCard.tsx Show resolved Hide resolved
frontend/src/types.ts Outdated Show resolved Hide resolved
Copy link
Contributor

openshift-ci bot commented Dec 23, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from andrewballantyne. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

@yzhao583 yzhao583 requested review from swati-kale and TomerFi January 8, 2025 07:09
@emilys314
Copy link
Contributor

It looks like there is a typescript error with the most recent rebasing to include Olga's pr in frontend/src/__tests__/cypress/cypress/utils/nimUtils.ts

I think we may want to make the properties variablesValidationStatus and variablesValidationTimestamp optional in type IntegrationAppStatus in frontend/src/types.ts

@yzhao583
Copy link
Contributor Author

yzhao583 commented Jan 9, 2025

@emilys314 I changed variablesValidationTimestamp and variablesValidationStatus to optional

Copy link
Contributor

@emilys314 emilys314 left a comment

Choose a reason for hiding this comment

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

Also make sure to run the linter / formatter

Comment on lines 78 to 91
if (shouldContinueWatching(response)) {
watchHandle = setTimeout(watchStatus, 10 * 1000);
return;
}
if (response.isInstalled) {
setEnableStatus({
status: EnableApplicationStatus.SUCCESS,
error: '',
});
dispatchResults(undefined);
}
setLastVariablesValidationTimestamp(response.variablesValidationTimestamp || 'Unknown');
setEnableStatus({
status:
response.variablesValidationStatus === VariablesValidationStatus.SUCCESS
? EnableApplicationStatus.SUCCESS
: EnableApplicationStatus.FAILED,
error:
response.variablesValidationStatus === VariablesValidationStatus.SUCCESS
? ''
: 'Variables are not valid',
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm facing an issue where the first time I submit the api key, it will say it's invalid.

  1. Delete the nim secret or change it to be invalid
  2. Reload the page (important! otherwise the modal is saving the timestamp state after being closed because this modal isn't great)
  3. Enter and submit new key
  4. See invalid error

I believe this is happening because the initial value of the timestamp is set to Unknown, after the onSubmit POST, it will return the last timestamp which is stale. The watcher sees the timestamp changes and will check the status and see the stale invalid one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@emilys314 Thanks! Fixed it.

Comment on lines 42 to 43
variablesValidationStatus: VariablesValidationStatus.UNKNOWN,
variablesValidationTimestamp: 'Unknown',
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: I'm not sure how I feel about having "Unknown" as the return value for the timestamp. It looks a little strange next to the other enum, and timestamp can have many values, not different enum states, also passing in "Unknown" is a magic string. In my opinion returning an empty value or no timestamp is a more universal sign that there is no timestamp

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@emilys314 Thanks for your suggestion. Are you suggesting replacing Unknown with '' ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@emilys314 Replaced Unknow to ''

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ok-to-test The openshift bot needs `ok-to-test` to allow non member PRs to run the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants