You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by "toolmanwyj (via GitHub)" <gi...@apache.org> on 2025/01/21 08:31:15 UTC

[PR] Fix issue where security group selection is shown regardless of zone settings in EditVM [cloudstack]

toolmanwyj opened a new pull request, #10224:
URL: https://github.com/apache/cloudstack/pull/10224

   ### Description
   
   In CloudStack, the security group selection box is displayed when editing a VM, regardless of whether the zone supports security groups or not. This causes the `securitygroupids` parameter to be sent with the request even if no security group is selected. If the zone is of type `NetworkType.Advanced` and does not support security groups, this triggers a `NullPointerException` in the `UserVmManagerImpl.updateVirtualMachine` method when calling `isSecurityGroupSupportedInNetwork`.
   
   Upon investigation, it was found that the `listZones` API call, which is used to fetch the zone details, incorrectly uses `zoneid` instead of `id` for the zone identifier. This prevents the correct zone information from being retrieved. Additionally, since the `listZones` API does not properly filter zones, it fetches all zones and always takes the first one in the list (index 0) to determine whether security groups are enabled. Consequently, if that first zone supports security groups, the security group selection box is displayed in the UI—even if the zone actually used by the VM does not support them.
   
   Moreover, the logic for checking whether the security group selection box is empty is not strict enough, which causes the `securitygroupids` parameter to be included in the request even when the selection box is empty.
   
   #### Proposed Solution
   
   1. Correct the parameter name for the zone identifier when calling the `listZones` API by using `id` instead of `zoneid`.
   2. Filter the zones correctly in the `listZones` API call to ensure that only the relevant zone is considered when checking for security group support.
   3. Improve the logic for checking if the security group selection box is empty before attaching the `securitygroupids` parameter to the request.
   
   #### Modified Files
   
   - `EditVM.vue`
   
   #### PR Changes
   - Fix incorrect usage of `zoneid` in `listZones` calls to properly retrieve the VM’s zone details.
   - Only consider the matching zone (instead of just taking the first item) to determine whether security groups are enabled.
   - Enhance the empty-check logic for the security group selection, preventing `securitygroupids` from being included if no security group is actually selected.
   - Prevent a `NullPointerException` when editing VMs in `NetworkType.Advanced` zones that do not support security groups.
   
   ### 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)
   - [ ] build/CI
   - [ ] test (unit or integration test code)
   
   ### Feature/Enhancement Scale or Bug Severity
   
   #### Feature/Enhancement Scale
   
   - [ ] Major
   - [ ] Minor
   
   #### Bug Severity
   
   - [ ] BLOCKER
   - [ ] Critical
   - [ ] Major
   - [x] Minor
   - [ ] Trivial
   
   ### How Has This Been Tested?
   
   1. **Local Dev Environment**  
      - Configured multiple zones: one supporting security groups and one not supporting security groups (VPC).  
      - Edited a VM in each zone to confirm that:
        1. When the zone supports SG, the security group selection is displayed and functions correctly.
        2. When the zone does not support SG, no security group selection is displayed or an empty list is properly handled, and no `securitygroupids` is sent to the backend.
      - Verified no `NullPointerException` is thrown even if `securitygroupids` is `null` or empty.
   
   2. **UI Validation**  
      - Checked that the modified logic in `EditVM.vue` properly filters the correct zone from `listZones`.
      - Ensured that if the user does not select a security group, the request does not include `securitygroupids`.
   
   #### How did you try to break this feature and the system with this change?
   
   - Attempted to edit a VM in a zone that does not support SG and artificially forced the frontend to pass `securitygroupids`, verifying that no NPE occurs.
   - Made sure any new changes do not affect zones where security groups are legitimately supported.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix issue where security group selection is shown regardless of zone settings in EditVM [cloudstack]

Posted by "Pearl1594 (via GitHub)" <gi...@apache.org>.
Pearl1594 commented on PR #10224:
URL: https://github.com/apache/cloudstack/pull/10224#issuecomment-2934110616

   CLosing this as this was raised against 4.19: https://github.com/apache/cloudstack/pull/10849 (commit: https://github.com/apache/cloudstack/commit/39a0ba967041e2492b1687ad0ac7e5ef7a6cac57)  - as this issue existed in the earlier version as well. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix issue where security group selection is shown regardless of zone settings in EditVM [cloudstack]

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #10224:
URL: https://github.com/apache/cloudstack/pull/10224#issuecomment-2603999162

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


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix issue where security group selection is shown regardless of zone settings in EditVM [cloudstack]

Posted by "Pearl1594 (via GitHub)" <gi...@apache.org>.
Pearl1594 closed pull request #10224: Fix issue where security group selection is shown regardless of zone settings in EditVM
URL: https://github.com/apache/cloudstack/pull/10224


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix issue where security group selection is shown regardless of zone settings in EditVM [cloudstack]

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #10224:
URL: https://github.com/apache/cloudstack/pull/10224#issuecomment-2604014665

   ## [Codecov](https://app.codecov.io/gh/apache/cloudstack/pull/10224?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   All modified and coverable lines are covered by tests :white_check_mark:
   > Project coverage is 4.02%. Comparing base [(`a163831`)](https://app.codecov.io/gh/apache/cloudstack/commit/a163831b7e884b11eb8b41b2aff592edc2d33061?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) to head [(`9d4128b`)](https://app.codecov.io/gh/apache/cloudstack/commit/9d4128bc982e87747110bc7a876c68d0f3b20f90?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   
   > :exclamation:  There is a different number of reports uploaded between BASE (a163831) and HEAD (9d4128b). Click for more details.
   > 
   > <details><summary>HEAD has 1 upload less than BASE</summary>
   >
   >| Flag | BASE (a163831) | HEAD (9d4128b) |
   >|------|------|------|
   >|unittests|1|0|
   ></details>
   
   <details><summary>Additional details and impacted files</summary>
   
   
   ```diff
   @@              Coverage Diff              @@
   ##               4.20   #10224       +/-   ##
   =============================================
   - Coverage     16.13%    4.02%   -12.12%     
   =============================================
     Files          5639      394     -5245     
     Lines        494264    32345   -461919     
     Branches      59899     5713    -54186     
   =============================================
   - Hits          79760     1301    -78459     
   + Misses       405684    30896   -374788     
   + Partials       8820      148     -8672     
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/cloudstack/pull/10224/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [uitests](https://app.codecov.io/gh/apache/cloudstack/pull/10224/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `4.02% <ø> (+<0.01%)` | :arrow_up: |
   | [unittests](https://app.codecov.io/gh/apache/cloudstack/pull/10224/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   </details>
   
   [:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/cloudstack/pull/10224?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix issue where security group selection is shown regardless of zone settings in EditVM [cloudstack]

Posted by "boring-cyborg[bot] (via GitHub)" <gi...@apache.org>.
boring-cyborg[bot] commented on PR #10224:
URL: https://github.com/apache/cloudstack/pull/10224#issuecomment-2603963448

   Congratulations on your first Pull Request and welcome to the Apache CloudStack community! If you have any issues or are unsure about any anything please check our Contribution Guide (https://github.com/apache/cloudstack/blob/main/CONTRIBUTING.md)
   Here are some useful points:
   - In case of a new feature add useful documentation (raise doc PR at https://github.com/apache/cloudstack-documentation)
   - Be patient and persistent. It might take some time to get a review or get the final approval from the committers.
   - Pay attention to the quality of your code, ensure tests are passing and your PR doesn't have conflicts.
   - Please follow [ASF Code of Conduct](https://github.com/apache/.github/blob/main/.github/CODE_OF_CONDUCT.md) for all communication including (but not limited to) comments on Pull Requests, Issues, Mailing list and Slack.
   - Be sure to read the [CloudStack Coding Conventions](https://cwiki.apache.org/confluence/display/CLOUDSTACK/Coding+conventions).
   Apache CloudStack is a community-driven project and together we are making it better 🚀.
   In case of doubts contact the developers at:
   Mailing List: dev@cloudstack.apache.org (https://cloudstack.apache.org/mailing-lists.html)
   Slack: https://apachecloudstack.slack.com/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix issue where security group selection is shown regardless of zone settings in EditVM [cloudstack]

Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on PR #10224:
URL: https://github.com/apache/cloudstack/pull/10224#issuecomment-2603996983

   @blueorangutan ui


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix issue where security group selection is shown regardless of zone settings in EditVM [cloudstack]

Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on PR #10224:
URL: https://github.com/apache/cloudstack/pull/10224#issuecomment-2872597833

   checked as #10849 looks ok


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix issue where security group selection is shown regardless of zone settings in EditVM [cloudstack]

Posted by "weizhouapache (via GitHub)" <gi...@apache.org>.
weizhouapache commented on PR #10224:
URL: https://github.com/apache/cloudstack/pull/10224#issuecomment-2865643799

   This is related to #10714 and #10719


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix issue where security group selection is shown regardless of zone settings in EditVM [cloudstack]

Posted by "DaanHoogland (via GitHub)" <gi...@apache.org>.
DaanHoogland commented on PR #10224:
URL: https://github.com/apache/cloudstack/pull/10224#issuecomment-2865589284

   thanks for pointing this one out @rohityadavcloud .
   @toolmanwyj , does it make sense to backport this PR to 4.19? it seem applicable to that as well.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix issue where security group selection is shown regardless of zone settings in EditVM [cloudstack]

Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #10224:
URL: https://github.com/apache/cloudstack/pull/10224#issuecomment-2604088157

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


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org