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

ui: fix considerlasthost for start vm #10602

Merged
merged 2 commits into from
Mar 24, 2025

Conversation

shwstppr
Copy link
Contributor

Description

Fixes #10601

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)
  • build/CI
  • test (unit or integration test code)

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?

How did you try to break this feature and the system with this change?

Fixes apache#10601

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
@shwstppr shwstppr linked an issue Mar 21, 2025 that may be closed by this pull request
@shwstppr
Copy link
Contributor Author

@blueorangutan ui

@blueorangutan
Copy link

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

@@ -237,7 +237,7 @@ export default {
id: this.resource.id
}
for (const key in values) {
if (values[key]) {
if (values[key] || values[key] === false) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Couldn't we simply remove this if condition? I don't see how a form's field value could be null or undefined here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bernardodemarco It may be there because some fields may have an empty value which we shouldn't pass to the API

Copy link
Collaborator

Choose a reason for hiding this comment

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

Okay. Specifically in this form, in which all fields are select components (except for the considerlasthost), the UI does not allow the values to be empty.

However, I think that's a great idea to keep the if statement how you proposed, since that we could, in the future, add more fields to the form that can accept empty/nullable values

Copy link

codecov bot commented Mar 21, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 15.16%. Comparing base (95c2481) to head (6252610).
Report is 7 commits behind head on 4.19.

Additional details and impacted files
@@            Coverage Diff            @@
##               4.19   #10602   +/-   ##
=========================================
  Coverage     15.16%   15.16%           
- Complexity    11326    11328    +2     
=========================================
  Files          5414     5414           
  Lines        474804   474811    +7     
  Branches      57909    57911    +2     
=========================================
+ Hits          72002    72016   +14     
+ Misses       394749   394743    -6     
+ Partials       8053     8052    -1     
Flag Coverage Δ
uitests 4.28% <ø> (ø)
unittests 15.89% <ø> (+<0.01%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@blueorangutan
Copy link

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

Copy link
Collaborator

@bernardodemarco bernardodemarco left a comment

Choose a reason for hiding this comment

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

@shwstppr, I think that we should also tackle this bug when starting VMs through group actions.

I debugged the current behavior of the AutogenView component. On this block of code:

const paramsList = this.currentAction.groupMap(this.selectedRowKeys, values, this.items)
for (const params of paramsList) {
var resourceName = itemsNameMap[params.id]
// Using a method for this since it's an async call and don't want wrong prarms to be passed
this.promises.push(this.callGroupApi(params, resourceName))

The paramsList variable contains the considerlasthost parameter as undefined and, thus, it is not sent within the API request. To handle that, we could, in the following groupMap field:

api: 'startVirtualMachine',
icon: 'caret-right-outlined',
label: 'label.action.start.instance',
message: 'message.action.start.instance',
docHelp: 'adminguide/virtual_machines.html#stopping-and-starting-vms',
dataView: true,
groupAction: true,
popup: true,
groupMap: (selection, values) => { return selection.map(x => { return { id: x, considerlasthost: values.considerlasthost } }) },

Check whether values.considerlasthost is undefined. If so, the considerlasthost field could be set as false.


Edit: The bug when starting VMs through group actions occurs when the form is opened, and the considerlasthost field is not changed. If the field is set to true and switched back to false, then the UI sets the considerlasthost parameter correctly to false.

Copy link
Member

@weizhouapache weizhouapache left a comment

Choose a reason for hiding this comment

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

code lgtm

makes sense to pass the value "false" to API

@weizhouapache
Copy link
Member

@shwstppr, I think that we should also tackle this bug when starting VMs through group actions.

I debugged the current behavior of the AutogenView component. On this block of code:

const paramsList = this.currentAction.groupMap(this.selectedRowKeys, values, this.items)
for (const params of paramsList) {
var resourceName = itemsNameMap[params.id]
// Using a method for this since it's an async call and don't want wrong prarms to be passed
this.promises.push(this.callGroupApi(params, resourceName))

The paramsList variable contains the considerlasthost parameter as undefined and, thus, it is not sent within the API request. To handle that, we could, in the following groupMap field:

api: 'startVirtualMachine',
icon: 'caret-right-outlined',
label: 'label.action.start.instance',
message: 'message.action.start.instance',
docHelp: 'adminguide/virtual_machines.html#stopping-and-starting-vms',
dataView: true,
groupAction: true,
popup: true,
groupMap: (selection, values) => { return selection.map(x => { return { id: x, considerlasthost: values.considerlasthost } }) },

Check whether values.considerlasthost is undefined. If so, the considerlasthost field could be set as false.

Edit: The bug when starting VMs through group actions occurs when the form is opened, and the considerlasthost field is not changed. If the field is set to true and switched back to false, then the UI sets the considerlasthost parameter correctly to false.

good point.
this is indeed a bug

@shwstppr
Copy link
Contributor Author

Thanks guys for group action pointers. Will check and update.

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
@shwstppr
Copy link
Contributor Author

@blueorangutan ui

@blueorangutan
Copy link

@shwstppr 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/10602 (QA-JID-582)

@shwstppr shwstppr marked this pull request as ready for review March 24, 2025 05:57
@DaanHoogland DaanHoogland added this to the 4.19.3 milestone Mar 24, 2025
Copy link
Contributor

@DaanHoogland DaanHoogland left a comment

Choose a reason for hiding this comment

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

tested with devtools in qa , parameter is passed

@DaanHoogland DaanHoogland merged commit c1ff799 into apache:4.19 Mar 24, 2025
26 checks passed
@DaanHoogland DaanHoogland deleted the fix-ui-considerlasthost branch March 24, 2025 11:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

UI: Consider Last Host is ignored
5 participants