Skip to content

ui: Fix refresh and re-route behaviour #7846

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

Merged
merged 7 commits into from
Aug 25, 2023

Conversation

rohityadavcloud
Copy link
Member

@rohityadavcloud rohityadavcloud commented Aug 10, 2023

This introduces change in AutogenView to do the following:

  • Cancel old list API requests when the route is changed (between different list view or list and resource views)
  • In the handler of an API call made in the fetchData(), to check if the json received is for the current route/id (API)
  • Add console log for debugging which may be removed if this passes code review and testing

Fixes #7840

How was this tested?

  • In my env the listVirtualMachines API takes time to complete, so I go to the instances page and go quick back/forth other views; for example, go to instances page that doesn't load and click on 2nd VM (or go to instance page and search something that returns faster than the whole list API and go the VM). When the original list API call completes, the current VM is replaced by the first VM in the list.
  • Check console log with the fix and network to see that old API (xhr) requests that haven't completed are cancelled when the route/view is changed between list and resource views of different resources

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

this.items = json[responseName][objectName]
if (!this.items || this.items.length === 0) {
this.items = []
}
this.itemCount = apiItemCount
if (this.itemCount !== this.items.length) {
console.log('WARN: API items length does not match the API return count, something is wrong')
Copy link
Member Author

Choose a reason for hiding this comment

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

this is one part that needs testing, I observed it a few times

@rohityadavcloud
Copy link
Member Author

@blueorangutan
Copy link

@rohityadavcloud a Jenkins job has been kicked to build UI QA env. I'll keep you posted as I make progress.

@blueorangutan
Copy link

UI build: ✔️
Live QA URL: https://qa.cloudstack.cloud/simulator/pr/7846 (QA-JID-137)

@codecov
Copy link

codecov bot commented Aug 10, 2023

Codecov Report

Merging #7846 (ee52f36) into 4.18 (3c38ed7) will not change coverage.
Report is 1 commits behind head on 4.18.
The diff coverage is n/a.

❗ Current head ee52f36 differs from pull request most recent head 3857af2. Consider uploading reports for the commit 3857af2 to get more accurate results

@@            Coverage Diff            @@
##               4.18    #7846   +/-   ##
=========================================
  Coverage     13.06%   13.06%           
  Complexity     9088     9088           
=========================================
  Files          2720     2720           
  Lines        257391   257391           
  Branches      40130    40130           
=========================================
  Hits          33621    33621           
  Misses       219548   219548           
  Partials       4222     4222           

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@DaanHoogland
Copy link
Contributor

@rohityadavcloud , I'll test but I have my doubt because of the following; If you reroute it will not help to cancel any outstanding APIs. These are still being executed and I am unsure of the value of the concept of "cancel". Can you explain that?
There is only a problem if the user will start an action (fire a new call) fr wich it can not know the changed parameters.

@rohityadavcloud
Copy link
Member Author

@DaanHoogland in case of the UI, routing/re-routing, refer to the browser/history URL change; when we move from one list view or resource view to any other, the AutogenView is the same component that render such views; since it's the same component it doesn't unmount/recreated, and any previous APIs (list APIs generally) fired by the fetchData() may return and call the handler (see the api() in fetchData()) which can mess the new list/resource view and cause it to update its this.items or this.resource. This is generally rare, but can happen when the list API is slow (in my case I can reproduce, and share a video of the same if it helps - before and after this PR).

Due to this side effect, something like this can be produced https://www.loom.com/share/97225b22110944b689687409729f2938?sid=435ff224-bb2c-4d14-8ab1-867d91352cfe

@rohityadavcloud
Copy link
Member Author

@blueorangutan ui

@blueorangutan
Copy link

@rohityadavcloud a Jenkins job has been kicked to build UI QA env. I'll keep you posted as I make progress.

@rohityadavcloud
Copy link
Member Author

@blueorangutan ui

@blueorangutan
Copy link

@rohityadavcloud a Jenkins job has been kicked to build UI QA env. I'll keep you posted as I make progress.

@blueorangutan
Copy link

UI build: ✔️
Live QA URL: https://qa.cloudstack.cloud/simulator/pr/7846 (QA-JID-140)

@rohityadavcloud
Copy link
Member Author

cc @shwstppr @Pearl1594 I'll need some help to fix the failing UI unit tests - any tips or assistance you can offer?

@rohityadavcloud
Copy link
Member Author

cc @nvazquez - if you can advise/assist on the failing unit tests, thanks.

@DaanHoogland
Copy link
Contributor

@blueorangutan ui

Signed-off-by: Rohit Yadav <[email protected]>
@rohityadavcloud
Copy link
Member Author

@blueorangutan package
@blueorangutan ui

@blueorangutan
Copy link

@rohityadavcloud a [SF] Jenkins job has been kicked to build packages. It will be bundled with@blueorangutan ui SystemVM template(s). I'll keep you posted as I make progress.

@blueorangutan
Copy link

@rohityadavcloud a Jenkins job has been kicked to build UI QA env. I'll keep you posted as I make progress.

@blueorangutan
Copy link

UI build: ✔️
Live QA URL: https://qa.cloudstack.cloud/simulator/pr/7846 (QA-JID-168)

@DaanHoogland
Copy link
Contributor

@blueorangutan package

@blueorangutan
Copy link

@DaanHoogland a [SF] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result [SF]: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 6888

@blueorangutan
Copy link

Packaging result [SF]: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 6890

@DaanHoogland
Copy link
Contributor

all seems fine but one strange thing I noticed is that an "Add VPC" notification remained "in progress"
image
while the VPC was allready added
image

@DaanHoogland
Copy link
Contributor

I think this is no issue in this code. can we merge @weizhouapache @rohityadavcloud ?

@rohityadavcloud
Copy link
Member Author

@DaanHoogland that could a notification regression or somehow things got opened in a new tab / refreshed, I've noticed that too (but not related to changes in autogenview)

@rohityadavcloud
Copy link
Member Author

@DaanHoogland I've asked @andrijapanicsb to confirm testing, perhaps @GutoVeronezi was testing as well - appreciate all the QA, feedback we can get on this. Thanks.

@weizhouapache
Copy link
Member

I think this is no issue in this code. can we merge @weizhouapache @rohityadavcloud ?

@DaanHoogland
thanks for testing
I am ok with merging .

@andrijapanicsb
Copy link
Contributor

Wait for it... give me 1h

@andrijapanicsb
Copy link
Contributor

Reproduction with high load on the mgmt server and 400+ VMs in DB
Short video: https://somup.com/c0jTXqAO10

Issues does NOT happen after upgrading to packages from this PR:
Short video: https://screenpal.com/watch/c0jTXuVpzoA

Copy link
Contributor

@andrijapanicsb andrijapanicsb left a comment

Choose a reason for hiding this comment

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

LGTM

@DaanHoogland
Copy link
Contributor

ok, merging. @GutoVeronezi if you find anything please open a new issue on that? thanks

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.

UI bug: internal "refresh" of the UI can cause a wrong VM to be deleted