cloudstack icon indicating copy to clipboard operation
cloudstack copied to clipboard

Support network-scope settings and add setting to override vr service offering

Open soreana opened this issue 3 years ago • 82 comments

Description

As of now, it is possible to override the virtual router service offering with global, domain, and account level configurations. What if a customer wants to change the service offering for only one network? There isn't such an option in Cloudstack. As an admin, you can only override the network offering for a domain, account, or global, affecting all the networks in that domain, account, or zone. This pull request aims to add a network-level setting to override the virtual router service offering per network.

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)
  • [x] Enhancement (improves an existing feature and functionality)
  • [ ] Cleanup (Code refactoring and cleanup, that may add test cases)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • [x] Major
  • [ ] Minor

How Has This Been Tested?

To test this feature, please follow the below steps:

  1. Create a network
  2. Create VM in that network (to create a VR)
  3. List the network and get the UUID of the network
  4. Check the service offering of the network
  5. Create a new router service offering
  6. Set the network.router.service.offering to the UUID of the service offering for the network using the cmk
  7. Restart the network with clean up
  8. Check the service offering of the network

Useful cmk commands:

(localcloud) 🐱 > list networks filter=id,name
{
  "count": 2,
  "network": [
    {
      "id": "c9d70872-b877-4f02-92b5-b4b08e1095d7",
      "name": "isolated-network"
    },
    {
      "id": "1ebf1ca9-7930-4f2f-8263-8da1840f02fc",
      "name": "shared"
    }
  ]
}
(localcloud) 🐱 > list configurations networkid=c9d70872-b877-4f02-92b5-b4b08e1095d7
{
  "configuration": [
    {
      "category": "Advanced",
      "description": "Uuid of the service offering used by virtual routers of this network; if NULL - account/system offering will be used",
      "isdynamic": true,
      "name": "network.router.service.offering",
      "scope": "network",
      "value": ""
    }
  ],
  "count": 1
}
(localcloud) 🐱 > list routers filter=serviceofferingid,serviceofferingname
{
  "count": 1,
  "router": [
    {
      "serviceofferingid": "f37ed5fd-6f26-4316-8b27-dbebb0b56a5a"
      "serviceofferingname": "System Offering For Software Router"
    }
  ]
}
(localcloud) 🐱 > update configuration networkid=c9d70872-b877-4f02-92b5-b4b08e1095d7 name="network.router.service.offering" value="5ad7f2c4-29e0-460b-901b-05ee8de8a0df"
{
  "configuration": {
    "category": "Advanced",
    "description": "Uuid of the service offering used by virtual routers of this network; if NULL - account/system offering will be used",
    "isdynamic": true,
    "name": "network.router.service.offering",
    "scope": "network",
    "value": "5ad7f2c4-29e0-460b-901b-05ee8de8a0df"
  }
}
(localcloud) 🐱 > restart network id=c9d70872-b877-4f02-92b5-b4b08e1095d7 cleanup=true
{
  "success": true
}
(localcloud) 🐱 > list routers filter=serviceofferingid,serviceofferingname
{
  "count": 1,
  "router": [
    {
      "serviceofferingid": "5ad7f2c4-29e0-460b-901b-05ee8de8a0df"
      "serviceofferingname": "Medium Instance"
    }
  ]
}

soreana avatar Nov 23 '22 11:11 soreana

@blueorangutan package

soreana avatar Nov 23 '22 11:11 soreana

@soreana a 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.

blueorangutan avatar Nov 23 '22 13:11 blueorangutan

Packaging result: :heavy_multiplication_x: el7 :heavy_multiplication_x: el8 :heavy_multiplication_x: debian :heavy_multiplication_x: suse15. SL-JID 4629

blueorangutan avatar Nov 23 '22 13:11 blueorangutan

@soreana can you check build failures? I also see failing coverage and quality checks

rohityadavcloud avatar Nov 23 '22 13:11 rohityadavcloud

@blueorangutan package

DaanHoogland avatar Dec 21 '22 07:12 DaanHoogland

@DaanHoogland a 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.

blueorangutan avatar Dec 21 '22 07:12 blueorangutan

Packaging result: :heavy_multiplication_x: el7 :heavy_multiplication_x: el8 :heavy_multiplication_x: debian :heavy_multiplication_x: suse15. SL-JID 5042

blueorangutan avatar Dec 21 '22 08:12 blueorangutan

@blueorangutan package

soreana avatar Dec 30 '22 23:12 soreana

@soreana a 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.

blueorangutan avatar Dec 30 '22 23:12 blueorangutan

Packaging result: :heavy_multiplication_x: el7 :heavy_multiplication_x: el8 :heavy_multiplication_x: el9 :heavy_multiplication_x: debian :heavy_multiplication_x: suse15. SL-JID 5145

blueorangutan avatar Dec 30 '22 23:12 blueorangutan

@DaanHoogland Happy new year. :) I tried to fix the test failure, but I couldn't. Can you have a look when you have time please?

[ERROR] org.apache.cloudstack.networkoffering.CreateNetworkOfferingTest1
[ERROR]         at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:669)
[ERROR]         at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:282)
[ERROR]         at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:245)
[ERROR]         at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:1183)

soreana avatar Dec 31 '22 11:12 soreana

@soreana I haven't had a chance to investigate very deeply yet, but at my laptop it also crashes with

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test (default-test) on project cloud-server: There are test failures.
[ERROR] 
[ERROR] Please refer to /home/dahn/apache/cloudstack/server/target/surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
[ERROR] The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
[ERROR] Command was /bin/sh -c cd /home/dahn/apache/cloudstack/server && /home/dahn/.jdks/azul-11.0.15/bin/java -Djava.security.egd=file:/dev/./urandom -noverify -Xmx2048m -XX:MaxPermSize=512m -Djava.security.egd=file:/dev/./urandom org.apache.maven.surefire.booter.ForkedBooter /home/dahn/apache/cloudstack/server/target/surefire 2022-12-31T15-16-34_362-jvmRun1 surefire6779432936451500986tmp surefire_139610296058936276723tmp
[ERROR] Error occurred in starting fork, check output in log
[ERROR] Process Exit Code: 1
[ERROR] Crashed tests:
[ERROR] org.apache.cloudstack.networkoffering.CreateNetworkOfferingTest
[ERROR] org.apache.maven.surefire.booter.SurefireBooterForkException: The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
[ERROR] Command was /bin/sh -c cd /home/dahn/apache/cloudstack/server && /home/dahn/.jdks/azul-11.0.15/bin/java -Djava.security.egd=file:/dev/./urandom -noverify -Xmx2048m -XX:MaxPermSize=512m -Djava.security.egd=file:/dev/./urandom org.apache.maven.surefire.booter.ForkedBooter /home/dahn/apache/cloudstack/server/target/surefire 2022-12-31T15-16-34_362-jvmRun1 surefire6779432936451500986tmp surefire_139610296058936276723tmp
[ERROR] Error occurred in starting fork, check output in log
[ERROR] Process Exit Code: 1
[ERROR] Crashed tests:
[ERROR] org.apache.cloudstack.networkoffering.CreateNetworkOfferingTest
[ERROR] 	at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:669)
[ERROR] 	at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:282)
[ERROR] 	at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:245)
[ERROR] 	at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:1183)
[ERROR] 	at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:1011)
[ERROR] 	at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:857)
[ERROR] 	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
[ERROR] 	at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute(MojoExecutor.java:301)
[ERROR] 	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:211)
[ERROR] 	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:165)
[ERROR] 	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:157)
[ERROR] 	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:121)
[ERROR] 	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
[ERROR] 	at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
[ERROR] 	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:127)
[ERROR] 	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:294)
[ERROR] 	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
[ERROR] 	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
[ERROR] 	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:960)
[ERROR] 	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:293)
[ERROR] 	at org.apache.maven.cli.MavenCli.main(MavenCli.java:196)
[ERROR] 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR] 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR] 	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
[ERROR] 	at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
[ERROR] 	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
[ERROR] 	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
[ERROR] 	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)
[ERROR] 
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <args> -rf :cloud-server

DaanHoogland avatar Jan 02 '23 12:01 DaanHoogland

@DaanHoogland The CreateNetworkOfferingTest fails and I don't know why :( Build packages with -DskipTests, they were working. I'm trouble shooting to see what went wrong, let me know if you found anything.

soreana avatar Jan 02 '23 16:01 soreana

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

github-actions[bot] avatar Jan 31 '23 10:01 github-actions[bot]

@soreana i ran this in a debugger and for some reason your PR tries to load ~/.m2/repository/com/sun/xml/bind/jaxb-core/2.3.0/jaxb-api.jar during testing, which doesn´t exist.

DaanHoogland avatar Feb 01 '23 11:02 DaanHoogland

@DaanHoogland I removed these lines and the build error gone. I don't know what was wrong. 🤷‍♂️

diff --git a/server/src/test/java/org/apache/cloudstack/networkoffering/ChildTestConfiguration.java b/server/src/test/java/org/apache/cloudstack/networkoffering/ChildTestConfiguration.java
index 33747b0342..6beba0b212 100644
--- a/server/src/test/java/org/apache/cloudstack/networkoffering/ChildTestConfiguration.java
+++ b/server/src/test/java/org/apache/cloudstack/networkoffering/ChildTestConfiguration.java
@@ -56,7 +56,6 @@ import com.cloud.network.dao.FirewallRulesDcidrsDaoImpl;
 import com.cloud.network.dao.IPAddressDaoImpl;
 import com.cloud.network.dao.LoadBalancerDao;
 import com.cloud.network.dao.NetworkDao;
-import com.cloud.network.dao.NetworkDetailsDao;
 import com.cloud.network.dao.NetworkDomainDaoImpl;
 import com.cloud.network.dao.NetworkServiceMapDaoImpl;
 import com.cloud.network.dao.PhysicalNetworkDaoImpl;
@@ -325,11 +324,6 @@ public class
         return Mockito.mock(DomainDetailsDao.class);
     }
 
-    @Bean
-    public NetworkDetailsDao networkDetailsDao() {
-        return Mockito.mock(NetworkDetailsDao.class);
-    }
-
     @Bean
     public DataStoreManager dataStoreManager() {
         return Mockito.mock(DataStoreManager.class);

soreana avatar Apr 04 '23 15:04 soreana

@blueorangutan package

soreana avatar Apr 04 '23 15:04 soreana

@soreana a 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.

blueorangutan avatar Apr 04 '23 15:04 blueorangutan

Packaging result: :heavy_check_mark: el7 :heavy_check_mark: el8 :heavy_check_mark: el9 :heavy_check_mark: debian :heavy_check_mark: suse15. SL-JID 5855

blueorangutan avatar Apr 04 '23 16:04 blueorangutan

Codecov Report

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

Comparison is base (314537a) 24.22% compared to head (baf242e) 29.21%. Report is 290 commits behind head on main.

Files Patch % Lines
...a/com/cloud/network/dao/NetworkDetailsDaoImpl.java 29.72% 25 Missing and 1 partial :warning:
.../cloud/configuration/ConfigurationManagerImpl.java 11.11% 22 Missing and 2 partials :warning:
.../router/deployment/RouterDeploymentDefinition.java 45.45% 4 Missing and 2 partials :warning:
...in/java/com/cloud/server/ManagementServerImpl.java 20.00% 3 Missing and 1 partial :warning:
...dstack/api/command/admin/config/ListCfgsByCmd.java 33.33% 1 Missing and 1 partial :warning:
...oudstack/api/command/admin/config/ResetCfgCmd.java 33.33% 1 Missing and 1 partial :warning:
...udstack/api/command/admin/config/UpdateCfgCmd.java 33.33% 1 Missing and 1 partial :warning:
ui/src/components/view/SettingsTab.vue 0.00% 2 Missing :warning:
ui/src/config/section/network.js 0.00% 2 Missing :warning:
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #6918      +/-   ##
============================================
+ Coverage     24.22%   29.21%   +4.99%     
- Complexity    22284    30491    +8207     
============================================
  Files          4624     5101     +477     
  Lines        311033   358887   +47854     
  Branches      43942    52378    +8436     
============================================
+ Hits          75335   104861   +29526     
- Misses       224698   239612   +14914     
- Partials      11000    14414    +3414     
Flag Coverage Δ
simulator-marvin-tests 25.18% <36.53%> (+0.95%) :arrow_up:
uitests 4.84% <0.00%> (?)
unit-tests 14.50% <12.94%> (?)

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 Apr 05 '23 15:04 codecov[bot]

@blueorangutan package

soreana avatar Apr 11 '23 09:04 soreana

@soreana a Jenkins job has been kicked to build packages. It will be bundled with SystemVM template(s). I'll keep you posted as I make progress.

blueorangutan avatar Apr 11 '23 09:04 blueorangutan

Packaging result: :heavy_check_mark: el7 :heavy_check_mark: el8 :heavy_check_mark: el9 :heavy_check_mark: debian :heavy_check_mark: suse15. SL-JID 5897

blueorangutan avatar Apr 11 '23 09:04 blueorangutan

@blueorangutan package

soreana avatar May 19 '23 13:05 soreana

@soreana a [LL] Jenkins job has been kicked to build packages. It will be bundled with SystemVM template(s). I'll keep you posted as I make progress.

blueorangutan avatar May 19 '23 13:05 blueorangutan

@weizhouapache Can I add this to 4.18.1 milestone?

soreana avatar May 19 '23 13:05 soreana

Packaging result [LL]: :heavy_check_mark: el7 :heavy_check_mark: el8 :heavy_check_mark: el9 :heavy_check_mark: debian :heavy_check_mark: suse15. SL-JID 6039

blueorangutan avatar May 19 '23 13:05 blueorangutan

@blueorangutan package

soreana avatar May 19 '23 14:05 soreana

@soreana a [LL] 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.

blueorangutan avatar May 19 '23 14:05 blueorangutan