You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by "Pearl1594 (via GitHub)" <gi...@apache.org> on 2025/08/28 20:09:47 UTC
[PR] CKS: Validate network offering from network if provided rather than global setting [cloudstack]
Pearl1594 opened a new pull request, #11528:
URL: https://github.com/apache/cloudstack/pull/11528
### Description
This PR adds a fix where in it checks the validity of the network offering of the network provided while creating the CKS cluster rather than that of the network offering set in the global setting
<!--- Describe your changes in DETAIL - And how has behaviour functionally changed. -->
<!-- For new features, provide link to FS, dev ML discussion etc. -->
<!-- In case of bug fix, the expected and actual behaviours, steps to reproduce. -->
<!-- When "Fixes: #<id>" is specified, the issue/PR will automatically be closed when this PR gets merged -->
<!-- For addressing multiple issues/PRs, use multiple "Fixes: #<id>" -->
<!-- Fixes: # -->
<!--- ******************************************************************************* -->
<!--- NOTE: AUTOMATION USES THE DESCRIPTIONS TO SET LABELS AND PRODUCE DOCUMENTATION. -->
<!--- PLEASE PUT AN 'X' in only **ONE** box -->
<!--- ******************************************************************************* -->
### 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
#### Bug Severity
- [ ] BLOCKER
- [ ] Critical
- [ ] Major
- [X] Minor
- [ ] Trivial
### Screenshots (if appropriate):
### How Has This Been Tested?
<!-- Please describe in detail how you tested your changes. -->
<!-- Include details of your testing environment, and the tests you ran to -->
#### How did you try to break this feature and the system with this change?
<!-- see how your change affects other areas of the code, etc. -->
<!-- Please read the [CONTRIBUTING](https://github.com/apache/cloudstack/blob/main/CONTRIBUTING.md) document -->
--
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] CKS: Validate network offering from network if provided rather than global setting [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #11528:
URL: https://github.com/apache/cloudstack/pull/11528#issuecomment-3234986679
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 14756
--
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] CKS: Validate network offering from network if provided rather than global setting [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #11528:
URL: https://github.com/apache/cloudstack/pull/11528#issuecomment-3236246105
@borisstoyanov a [SL] 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.
--
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] CKS: Validate network offering from network if provided rather than global setting [cloudstack]
Posted by "Pearl1594 (via GitHub)" <gi...@apache.org>.
Pearl1594 commented on PR #11528:
URL: https://github.com/apache/cloudstack/pull/11528#issuecomment-3237615579
@blueorangutan test
--
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] CKS: Validate network offering from network if provided rather than global setting [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #11528:
URL: https://github.com/apache/cloudstack/pull/11528#issuecomment-3239082103
<b>[SF] Trillian test result (tid-14149)</b>
Environment: kvm-ol8 (x2), zone: Advanced Networking with Mgmt server ol8
Total time taken: 53748 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr11528-t14149-kvm-ol8.zip
Smoke tests completed. 140 look OK, 1 have errors, 0 did not run
Only failed and skipped tests results shown below:
Test | Result | Time (s) | Test File
--- | --- | --- | ---
ContextSuite context=TestRAMCPUResourceAccounting>:setup | `Error` | 0.00 | test_resource_accounting.py
--
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] CKS: Validate network offering from network if provided rather than global setting [cloudstack]
Posted by "weizhouapache (via GitHub)" <gi...@apache.org>.
weizhouapache commented on code in PR #11528:
URL: https://github.com/apache/cloudstack/pull/11528#discussion_r2329959458
##########
plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterManagerImpl.java:
##########
@@ -367,18 +367,33 @@ private void logAndThrow(final Level logLevel, final String message, final Excep
logTransitStateAndThrow(logLevel, message, null, null, ex);
}
- private boolean isKubernetesServiceNetworkOfferingConfigured(DataCenter zone) {
+ private boolean isKubernetesServiceNetworkOfferingConfigured(DataCenter zone, Long networkId) {
// Check network offering
String networkOfferingName = KubernetesClusterNetworkOffering.value();
- if (networkOfferingName == null || networkOfferingName.isEmpty()) {
- logger.warn(String.format("Global setting %s is empty. Admin has not yet specified the network offering to be used for provisioning isolated network for the cluster", KubernetesClusterNetworkOffering.key()));
+ if (StringUtils.isEmpty(networkOfferingName) && networkId == null) {
+ logger.warn("Global setting: {} is empty. Admin has not yet specified the network offering to be used for provisioning isolated network for the cluster nor has a pre-created network been passed", KubernetesClusterNetworkOffering.key());
return false;
}
- NetworkOfferingVO networkOffering = networkOfferingDao.findByUniqueName(networkOfferingName);
- if (networkOffering == null) {
- logger.warn(String.format("Unable to find the network offering %s to be used for provisioning Kubernetes cluster", networkOfferingName));
- return false;
+ NetworkOfferingVO networkOffering = null;
+ if (networkId != null) {
+ NetworkVO network = networkDao.findById(networkId);
+ if (network == null) {
+ logger.warn("Unable to find the network with ID: {} passed for the Kubernetes cluster", networkId);
+ return false;
+ }
+ networkOffering = networkOfferingDao.findById(network.getNetworkOfferingId());
+ if (networkOffering == null) {
+ logger.warn("Unable to find the network offering of the network: {} ({}) to be used for provisioning Kubernetes cluster", network.getName(), network.getUuid());
+ return false;
+ }
+ } else if (StringUtils.isNotEmpty(networkOfferingName)) {
+ networkOffering = networkOfferingDao.findByUniqueName(networkOfferingName);
+ if (networkOffering == null) {
+ logger.warn("Unable to find the network offering: {} to be used for provisioning Kubernetes cluster", networkOfferingName);
+ return false;
+ }
}
+
Review Comment:
I think all scenarios have been covered. this will not happen
cc @Pearl1594
--
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] CKS: Validate network offering from network if provided rather than global setting [cloudstack]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #11528:
URL: https://github.com/apache/cloudstack/pull/11528#issuecomment-3234962864
## [](https://sonarcloud.io/dashboard?id=apache_cloudstack&pullRequest=11528) **Quality Gate failed**
Failed conditions
 [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_cloudstack&pullRequest=11528&metric=new_coverage&view=list) (required ≥ 40%)
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_cloudstack&pullRequest=11528)
--
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] CKS: Validate network offering from network if provided rather than global setting [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #11528:
URL: https://github.com/apache/cloudstack/pull/11528#issuecomment-3237616826
@Pearl1594 a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests
--
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] CKS: Validate network offering from network if provided rather than global setting [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #11528:
URL: https://github.com/apache/cloudstack/pull/11528#issuecomment-3236459295
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 14766
--
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] CKS: Validate network offering from network if provided rather than global setting [cloudstack]
Posted by "weizhouapache (via GitHub)" <gi...@apache.org>.
weizhouapache merged PR #11528:
URL: https://github.com/apache/cloudstack/pull/11528
--
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] CKS: Validate network offering from network if provided rather than global setting [cloudstack]
Posted by "borisstoyanov (via GitHub)" <gi...@apache.org>.
borisstoyanov commented on PR #11528:
URL: https://github.com/apache/cloudstack/pull/11528#issuecomment-3236243946
@blueorangutan package
--
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] CKS: Validate network offering from network if provided rather than global setting [cloudstack]
Posted by "weizhouapache (via GitHub)" <gi...@apache.org>.
weizhouapache commented on PR #11528:
URL: https://github.com/apache/cloudstack/pull/11528#issuecomment-3270128571
Tested OK
- Register CKS ISO
- Set global config endpoint.url
- Update `cloud.kubernetes.cluster.network.offering` setting from `DefaultNetworkOfferingforKubernetesService` to `DefaultNetworkOfferingforKubernetesService2`
- Create a CKS cluster without network, fail with error: `Kubernetes service has not been configured properly to provision Kubernetes clusters`. this is expected
- Create network with offering `DefaultNetworkOfferingforKubernetesService`
- Create a CKS cluster with the network
- Without this PR: fail with error: `Kubernetes service has not been configured properly to provision Kubernetes clusters`. this is expected
- With this PR: CKS cluster is created successfully
--
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] CKS: Validate network offering from network if provided rather than global setting [cloudstack]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #11528:
URL: https://github.com/apache/cloudstack/pull/11528#discussion_r2329938475
##########
plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterManagerImpl.java:
##########
@@ -367,18 +367,33 @@ private void logAndThrow(final Level logLevel, final String message, final Excep
logTransitStateAndThrow(logLevel, message, null, null, ex);
}
- private boolean isKubernetesServiceNetworkOfferingConfigured(DataCenter zone) {
+ private boolean isKubernetesServiceNetworkOfferingConfigured(DataCenter zone, Long networkId) {
// Check network offering
String networkOfferingName = KubernetesClusterNetworkOffering.value();
- if (networkOfferingName == null || networkOfferingName.isEmpty()) {
- logger.warn(String.format("Global setting %s is empty. Admin has not yet specified the network offering to be used for provisioning isolated network for the cluster", KubernetesClusterNetworkOffering.key()));
+ if (StringUtils.isEmpty(networkOfferingName) && networkId == null) {
+ logger.warn("Global setting: {} is empty. Admin has not yet specified the network offering to be used for provisioning isolated network for the cluster nor has a pre-created network been passed", KubernetesClusterNetworkOffering.key());
return false;
}
- NetworkOfferingVO networkOffering = networkOfferingDao.findByUniqueName(networkOfferingName);
- if (networkOffering == null) {
- logger.warn(String.format("Unable to find the network offering %s to be used for provisioning Kubernetes cluster", networkOfferingName));
- return false;
+ NetworkOfferingVO networkOffering = null;
+ if (networkId != null) {
+ NetworkVO network = networkDao.findById(networkId);
+ if (network == null) {
+ logger.warn("Unable to find the network with ID: {} passed for the Kubernetes cluster", networkId);
+ return false;
+ }
+ networkOffering = networkOfferingDao.findById(network.getNetworkOfferingId());
+ if (networkOffering == null) {
+ logger.warn("Unable to find the network offering of the network: {} ({}) to be used for provisioning Kubernetes cluster", network.getName(), network.getUuid());
+ return false;
+ }
+ } else if (StringUtils.isNotEmpty(networkOfferingName)) {
+ networkOffering = networkOfferingDao.findByUniqueName(networkOfferingName);
+ if (networkOffering == null) {
+ logger.warn("Unable to find the network offering: {} to be used for provisioning Kubernetes cluster", networkOfferingName);
+ return false;
+ }
}
+
Review Comment:
Potential null pointer exception. The networkOffering variable can be null when both networkId is null and networkOfferingName is empty, but the code still attempts to access networkOffering.getState() at line 397.
```suggestion
if (networkOffering == null) {
logger.warn("Network offering is null. Cannot check its state or properties.");
return false;
}
```
--
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] CKS: Validate network offering from network if provided rather than global setting [cloudstack]
Posted by "blueorangutan (via GitHub)" <gi...@apache.org>.
blueorangutan commented on PR #11528:
URL: https://github.com/apache/cloudstack/pull/11528#issuecomment-3234820447
@Pearl1594 a [SL] 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.
--
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