cloudstack icon indicating copy to clipboard operation
cloudstack copied to clipboard

Fix 404 when moving a VM to out of a project

Open winterhazel opened this issue 1 year ago • 7 comments

Description

In a project's view, after assigning an instance belonging to the project to a user account through the instance's page, the UI tries to refresh the information about the instance. However, as the project does not have permission to view instances from other accounts, the user is redirected to a 404.

This PR adds a check in the UI to avoid showing this 404.

Types of changes

  • [ ] Breaking change (fix or feature that would cause existing functionality to change)
  • [ ] New feature (non-breaking change which adds functionality)
  • [X] 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

Bug Severity

  • [ ] BLOCKER
  • [ ] Critical
  • [ ] Major
  • [X] Minor
  • [ ] Trivial

Screenshots (if appropriate):

How Has This Been Tested?

In the root admin account, I made the following tests:

Number Test Previous result New result Expected result? (Y/N)
1 In a project's view, I assigned an instance belonging to the project to a user account UI gets redirected to a 404 UI gets redirected to the instance listing Y
2 In a project's view, I tried to assign an instance belonging to the project to the project itself An error is shown, as the previous and the new owner are the same. The UI stays in the same page An error is shown, as the previous and the new owner are the same. The UI stays in the same page Y
3 In a project's view, I assigned an instance belonging to the project to another project in the same domain UI gets redirected to a 404 UI gets redirected to the instance listing Y
4 In a project's view, I assigned an instance belonging to the project to another project in a subdomain UI gets redirected to a 404 UI gets redirected to the instance listing Y
5 In the default view, I assigned an instance belonging to account A to account B The UI refreshes the information about the instance The UI refreshes the information about the instance Y

winterhazel avatar Feb 13 '24 18:02 winterhazel

Codecov Report

Attention: 276 lines in your changes are missing coverage. Please review.

Comparison is base (a0e592e) 30.94% compared to head (4f97039) 30.76%.

:exclamation: Current head 4f97039 differs from pull request most recent head cad306f. Consider uploading reports for the commit cad306f to get more accurate results

Files Patch % Lines
agent/src/main/java/com/cloud/agent/Agent.java 0.00% 93 Missing :warning:
...nt/resource/consoleproxy/ConsoleProxyResource.java 0.00% 44 Missing :warning:
...in/java/com/cloud/agent/api/storage/OVFHelper.java 10.71% 24 Missing and 1 partial :warning:
...gent/src/main/java/com/cloud/agent/AgentShell.java 9.09% 20 Missing :warning:
...rc/main/java/com/cloud/agent/mockvm/MockVmMgr.java 0.00% 11 Missing :warning:
...va/com/cloud/agent/dao/impl/PropertiesStorage.java 11.11% 8 Missing :warning:
...i/command/admin/vm/ImportUnmanagedInstanceCmd.java 0.00% 6 Missing :warning:
api/src/main/java/com/cloud/storage/Storage.java 89.36% 2 Missing and 3 partials :warning:
...api/command/admin/systemvm/MigrateSystemVMCmd.java 0.00% 4 Missing :warning:
...k/api/command/admin/systemvm/ScaleSystemVMCmd.java 0.00% 4 Missing :warning:
... and 38 more
Additional details and impacted files
@@             Coverage Diff              @@
##               4.19    #8650      +/-   ##
============================================
- Coverage     30.94%   30.76%   -0.19%     
+ Complexity    34234    33089    -1145     
============================================
  Files          5347     5353       +6     
  Lines        375585   374585    -1000     
  Branches      54632    54633       +1     
============================================
- Hits         116234   115246     -988     
- Misses       244047   244068      +21     
+ Partials      15304    15271      -33     
Flag Coverage Δ
simulator-marvin-tests 24.62% <14.82%> (-0.22%) :arrow_down:
uitests 4.38% <ø> (-0.02%) :arrow_down:
unit-tests 16.43% <16.86%> (-0.13%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Feb 13 '24 18:02 codecov[bot]

@blueorangutan ui

DaanHoogland avatar Feb 14 '24 16:02 DaanHoogland

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

blueorangutan avatar Feb 14 '24 16:02 blueorangutan

UI build: :heavy_check_mark: Live QA URL: https://qa.cloudstack.cloud/simulator/pr/8650 (QA-JID-280)

blueorangutan avatar Feb 14 '24 16:02 blueorangutan

@winterhazel, as this PR fixes the 404 error, it's Types of changes should be defined as Bug fix.

GutoVeronezi avatar Feb 14 '24 22:02 GutoVeronezi

@winterhazel can you change base branch to 4.19 as it's a fix.

rohityadavcloud avatar Feb 16 '24 05:02 rohityadavcloud

This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.

github-actions[bot] avatar Feb 16 '24 18:02 github-actions[bot]

@winterhazel , does this not occur on 4.18? or should it go into the 4.18 branch?

DaanHoogland avatar Mar 11 '24 15:03 DaanHoogland

@DaanHoogland this problem also occurs on 4.18.

I'm not sure if this PR can still go to 4.18 though, as @JoaoJandre recently froze the branch and will move most pending items to the next milestone. Will there be another milestone in 4.18 this PR can go to?

winterhazel avatar Mar 12 '24 11:03 winterhazel

@DaanHoogland this problem also occurs on 4.18.

I'm not sure if this PR can still go to 4.18 though, as @JoaoJandre recently froze the branch and will move most pending items to the next milestone. Will there be another milestone in 4.18 this PR can go to?

It does not matter, we can put it on the branch so people building their own have it, and we will still merge it forward to 4.19 whether there will be a 4.18.3 or not.

DaanHoogland avatar Mar 15 '24 13:03 DaanHoogland

that said, just say no and we can merge it now

DaanHoogland avatar Mar 15 '24 13:03 DaanHoogland

Alright, I'll keep this for 4.19.

winterhazel avatar Mar 15 '24 14:03 winterhazel