Skip to content

improvement(offering): make network mode mandatory when creating vpc …#13622

Open
Chinmay048 wants to merge 1 commit into
apache:mainfrom
Chinmay048:fix/13607-validate-network-mode-offerings
Open

improvement(offering): make network mode mandatory when creating vpc …#13622
Chinmay048 wants to merge 1 commit into
apache:mainfrom
Chinmay048:fix/13607-validate-network-mode-offerings

Conversation

@Chinmay048

Copy link
Copy Markdown
Contributor

Description

This PR resolves an issue where the networkmode parameter (ROUTED vs NATTED) was treated as optional during the creation of VPC and Network Offerings, leading to ambiguous network configurations.

Full-Stack Boundary Enforcement:

  • Frontend (Vue.js / Ant Design): Added reactive validation rules (required: true) in AddVpcOffering.vue and AddNetworkOffering.vue to give administrators immediate visual feedback and prevent form submission if a network mode is not selected.
  • Backend (Java API): Hardened the serialization contract by adding required = true to the @Parameter annotation in CreateVPCOfferingCmd.java and NetworkOfferingBaseCmd.java (which governs creation and cloning operations without impacting updates).

Types of changes

  • Improvement (non-breaking change which enhances UX and API stability)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • I have read the CONTRIBUTING document.
  • My changes generate no new warnings or checkstyle errors.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to eliminate ambiguous VPC/Network Offering configurations by making networkmode (ROUTED vs NATTED) mandatory at both the UI form-validation layer and the Java API parameter layer.

Changes:

  • Added Ant Design Vue form rules to require networkmode selection in the VPC Offering and Network Offering creation UIs.
  • Marked networkmode as required = true in the Java API command parameter annotations for VPC and Network offering creation flows.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
ui/src/views/offering/AddVpcOffering.vue Adds a required validation rule for networkmode in the VPC offering creation form.
ui/src/views/offering/AddNetworkOffering.vue Adds a required validation rule for networkmode in the network offering creation form.
api/src/main/java/org/apache/cloudstack/api/command/admin/vpc/CreateVPCOfferingCmd.java Sets networkmode as required in the API command parameter definition for VPC offering creation (currently impacts clone as well via inheritance).
api/src/main/java/org/apache/cloudstack/api/command/admin/network/NetworkOfferingBaseCmd.java Sets networkmode as required in the shared base command for network offering create/clone (currently impacts clone as well via inheritance).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +369 to +370
// ADD THIS LINE:
networkmode: [{ required: true, message: this.$t('message.error.select') }],
Comment on lines +714 to +715
// ADD THIS LINE:
networkmode: [{ required: true, message: this.$t('message.error.select') }],
Comment on lines +147 to 148
@Parameter(name = ApiConstants.NETWORK_MODE, type = CommandType.STRING, required = true, description = "the network mode for the VPC offering")
private String networkMode;
Comment on lines +156 to +157
@Parameter(name = ApiConstants.NETWORK_MODE, type = CommandType.STRING, required = true, description = "the network mode for the network offering")
private String networkMode;

@DaanHoogland DaanHoogland left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why remove the possible values from the descriptions of the networkMode parameters?

@codecov

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 19.64%. Comparing base (0e43c6a) to head (2cfc768).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main   #13622      +/-   ##
============================================
+ Coverage     19.50%   19.64%   +0.14%     
- Complexity    19444    19789     +345     
============================================
  Files          6303     6368      +65     
  Lines        569286   575107    +5821     
  Branches      69791    70370     +579     
============================================
+ Hits         111040   112996    +1956     
- Misses       446093   449826    +3733     
- Partials      12153    12285     +132     
Flag Coverage Δ
uitests 3.41% <ø> (-0.01%) ⬇️
unittests 20.92% <ø> (+0.14%) ⬆️

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

☔ View full report in Codecov by Harness.
📢 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.

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.

Improvement/Ui: Make network mode mandatory or validate when creating vpc offering and network offering

3 participants