Skip to content

Fix PR 7131 bugs and vulnerabilities - #7140

Merged
DaanHoogland merged 5 commits into
apache:4.18from
scclouds:fix-log-bugs-and-vulnerabilities
Mar 21, 2023
Merged

DaanHoogland merged 5 commits into
apache:4.18from
scclouds:fix-log-bugs-and-vulnerabilities

Conversation

@JoaoJandre

Copy link
Copy Markdown
Contributor

Description

This PR fixes the bugs and vulnerabilities found by SonarCloud in PR #7131.

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)

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?

@codecov

codecov Bot commented Jan 27, 2023

Copy link
Copy Markdown

Codecov Report

Merging #7140 (a721520) into main (eac357c) will increase coverage by 0.85%.
The diff coverage is 0.76%.

@@             Coverage Diff              @@
##               main    #7140      +/-   ##
============================================
+ Coverage     11.78%   12.63%   +0.85%     
- Complexity     7676     8613     +937     
============================================
  Files          2505     2711     +206     
  Lines        246339   255756    +9417     
  Branches      38427    39868    +1441     
============================================
+ Hits          29039    32325    +3286     
- Misses       213520   219324    +5804     
- Partials       3780     4107     +327     
Impacted Files Coverage Δ
.../hypervisor/kvm/storage/LibvirtStorageAdaptor.java 0.24% <0.00%> (-0.01%) ⬇️
...java/com/cloud/ovm/hypervisor/OvmResourceBase.java 0.00% <0.00%> (ø)
...oud/hypervisor/vmware/resource/VmwareResource.java 4.50% <0.00%> (-0.01%) ⬇️
...or/xenserver/resource/XenServerConnectionPool.java 9.34% <0.00%> (-0.04%) ⬇️
...java/com/cloud/alert/ConsoleProxyAlertAdapter.java 0.00% <0.00%> (ø)
...om/cloud/alert/SecondaryStorageVmAlertAdapter.java 0.00% <0.00%> (ø)
server/src/main/java/com/cloud/api/ApiServer.java 1.87% <0.00%> (-0.01%) ⬇️
...network/ExternalLoadBalancerDeviceManagerImpl.java 6.32% <0.00%> (ø)
...in/java/com/cloud/servlet/ConsoleProxyServlet.java 5.14% <0.00%> (-0.16%) ⬇️
.../src/main/java/com/cloud/vm/UserVmManagerImpl.java 7.35% <0.00%> (+0.60%) ⬆️
... and 270 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

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

some suggestions but clgtm

Comment on lines +62 to +72
String secStorageVmHostName = "";
String secStorageVmPublicIpAddress = "";
String secStorageVmPrivateIpAddress = "N/A";
Long secStorageVmPodIdToDeployIn = null;

if (secStorageVm != null) {
secStorageVmHostName = secStorageVm.getHostName();
secStorageVmPublicIpAddress = secStorageVm.getPublicIpAddress();
secStorageVmPrivateIpAddress = secStorageVm.getPrivateIpAddress() == null ? "N/A" : secStorageVm.getPrivateIpAddress();
secStorageVmPodIdToDeployIn = secStorageVm.getPodIdToDeployIn();
}

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.

this is the exact same functionality as https://github.com/apache/cloudstack/pull/7140/files#diff-836e2e853d64b7a2f86c1add5aa76deea112788fe69c19a3c5eb2618d753ff2c lines 63-73. Can we make it a utiity method?

i.e. can we use VMInstanceVO instead of ConsoleProxyVO and SecondaryStorageVmVO and make it a member method of that class.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hey @DaanHoogland, yes this is replicate code from the ConsoleProxyAlertAdapter, but is it worth it to make a utility method out of it?
To make the code clear I would probably have to create a new object to store this info and use it during these methods. In the end I would probably end up with more lines of code and a whole new class just for this.

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.

@JoaoJandre , I am just bringing it to your attention. If you feel it isn't worth the trouble and you don't think it will be used more than considder my remark answerred.
Just one more opiniated remark; I think it is worth even if it doesn´t save lines of code to unify it. It makes clear to the reader that the same is happening, as future readers will not see the two peaces at the same time as we do now. This can also be solved by a comment of course.

@DaanHoogland

Copy link
Copy Markdown
Contributor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@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

Copy link
Copy Markdown

Packaging result: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 5426

@yadvr

yadvr commented Jan 28, 2023

Copy link
Copy Markdown
Member

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

@rohityadavcloud a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests

@blueorangutan

Copy link
Copy Markdown

Trillian test result (tid-6018)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 42155 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr7140-t6018-kvm-centos7.zip
Smoke tests completed. 107 look OK, 0 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File

@DaanHoogland

Copy link
Copy Markdown
Contributor

@rohityadavcloud , I am satisfied with just smoketests for this, would you agree?
@JoaoJandre , will you apply/answer my suggestions?

@BryanMLima BryanMLima 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.

CLGTM

@GutoVeronezi

Copy link
Copy Markdown
Contributor

@JoaoJandre, could you look at the code smells as well?

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs Vulnerability A 0 Vulnerabilities Security Hotspot A 0 Security Hotspots Code Smell B 19 Code Smells

0.0% 0.0% Coverage 0.0% 0.0% Duplication

@DaanHoogland

Copy link
Copy Markdown
Contributor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@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

Copy link
Copy Markdown

Packaging result: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 5453

@DaanHoogland

Copy link
Copy Markdown
Contributor

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

@DaanHoogland a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests

@blueorangutan

Copy link
Copy Markdown

Trillian test result (tid-6040)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 43196 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr7140-t6040-kvm-centos7.zip
Smoke tests completed. 102 look OK, 5 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File
test_01_add_primary_storage_disabled_host Error 0.68 test_primary_storage.py
test_01_primary_storage_nfs Error 0.11 test_primary_storage.py
ContextSuite context=TestStorageTags>:setup Error 0.21 test_primary_storage.py
test_01_non_strict_host_anti_affinity Failure 112.86 test_nonstrict_affinity_group.py
test_02_non_strict_host_affinity Error 82.22 test_nonstrict_affinity_group.py
test_03_deploy_and_scale_kubernetes_cluster Failure 34.19 test_kubernetes_clusters.py
test_07_deploy_kubernetes_ha_cluster Failure 69.75 test_kubernetes_clusters.py
test_08_upgrade_kubernetes_ha_cluster Failure 44.08 test_kubernetes_clusters.py
test_09_delete_kubernetes_ha_cluster Failure 42.11 test_kubernetes_clusters.py
ContextSuite context=TestKubernetesCluster>:teardown Error 131.14 test_kubernetes_clusters.py
test_01_secure_vm_migration Error 158.20 test_vm_life_cycle.py
test_02_unsecure_vm_migration Error 262.84 test_vm_life_cycle.py
test_03_secured_to_nonsecured_vm_migration Error 140.72 test_vm_life_cycle.py
test_08_migrate_vm Error 43.75 test_vm_life_cycle.py
test_hostha_enable_ha_when_host_in_maintenance Error 303.86 test_hostha_kvm.py

@yadvr

yadvr commented Feb 1, 2023

Copy link
Copy Markdown
Member

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

@rohityadavcloud a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests

@blueorangutan

Copy link
Copy Markdown

Trillian Build Failed (tid-6080)

@DaanHoogland DaanHoogland reopened this Feb 8, 2023
Comment thread server/src/main/java/com/cloud/vm/UserVmManagerImpl.java Outdated
Comment thread server/src/main/java/com/cloud/servlet/ConsoleProxyServlet.java Outdated
Comment thread server/src/main/java/com/cloud/servlet/ConsoleProxyServlet.java Outdated
Comment thread server/src/main/java/com/cloud/servlet/ConsoleProxyServlet.java Outdated
@GutoVeronezi

Copy link
Copy Markdown
Contributor

I am hesistent to merge this before 4.18 as it introduces no functionality or fixes any reported use case from failing. @rohityadavcloud @weizhouapache @GutoVeronezi , can you give your opinions on how serious the fixes in here are?

@DaanHoogland, as it is just a refactoring (to fix the bugs and vulnerabilities reported by the SonarCloud), I see no problem in adding this one to 4.18. We just have to guarantee that nothing broke with the refactoring; by the results of the tests and the code analysis, the changes seems OK; manual tests are welcome, though.

@JoaoJandre
JoaoJandre force-pushed the fix-log-bugs-and-vulnerabilities branch from 3abfed4 to a721520 Compare February 10, 2023 18:57
@sonarqubecloud

Copy link
Copy Markdown

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@DaanHoogland

Copy link
Copy Markdown
Contributor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@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

Copy link
Copy Markdown

Packaging result: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 5561

@DaanHoogland

Copy link
Copy Markdown
Contributor

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

@DaanHoogland a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests

@blueorangutan

Copy link
Copy Markdown

Trillian test result (tid-6165)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 40903 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr7140-t6165-kvm-centos7.zip
Smoke tests completed. 106 look OK, 1 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File
test_02_deploy_vm_with_extraconfig_kvm Error 0.22 test_deploy_vm_extra_config_data.py
test_03_update_vm_with_extraconfig_kvm Error 0.18 test_deploy_vm_extra_config_data.py

@DaanHoogland
DaanHoogland changed the base branch from main to 4.18 March 17, 2023 10:16
@DaanHoogland

Copy link
Copy Markdown
Contributor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@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

Copy link
Copy Markdown

Packaging result: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 5743

@DaanHoogland

Copy link
Copy Markdown
Contributor

@blueorangutan test matrix

@blueorangutan

Copy link
Copy Markdown

@DaanHoogland a Trillian-Jenkins matrix job (centos7 mgmt + xenserver71, rocky8 mgmt + vmware67u3, centos7 mgmt + kvmcentos7) has been kicked to run smoke tests

@blueorangutan

Copy link
Copy Markdown

Trillian test result (tid-6293)
Environment: vmware-67u3 (x2), Advanced Networking with Mgmt server r8
Total time taken: 41933 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr7140-t6293-vmware-67u3.zip
Smoke tests completed. 108 look OK, 0 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File

@blueorangutan

Copy link
Copy Markdown

Trillian test result (tid-6292)
Environment: xenserver-71 (x2), Advanced Networking with Mgmt server 7
Total time taken: 50058 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr7140-t6292-xenserver-71.zip
Smoke tests completed. 107 look OK, 1 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File
test_02_upgrade_kubernetes_cluster Error 3978.13 test_kubernetes_clusters.py
test_03_deploy_and_scale_kubernetes_cluster Failure 285.50 test_kubernetes_clusters.py
test_07_deploy_kubernetes_ha_cluster Failure 62.40 test_kubernetes_clusters.py
test_08_upgrade_kubernetes_ha_cluster Failure 0.05 test_kubernetes_clusters.py
test_09_delete_kubernetes_ha_cluster Failure 0.04 test_kubernetes_clusters.py
ContextSuite context=TestKubernetesCluster>:teardown Error 225.42 test_kubernetes_clusters.py

@blueorangutan

Copy link
Copy Markdown

Trillian test result (tid-6294)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 50144 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr7140-t6294-kvm-centos7.zip
Smoke tests completed. 107 look OK, 1 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File
test_02_upgrade_kubernetes_cluster Error 3969.44 test_kubernetes_clusters.py
test_08_upgrade_kubernetes_ha_cluster Error 4054.17 test_kubernetes_clusters.py
test_09_delete_kubernetes_ha_cluster Failure 0.04 test_kubernetes_clusters.py
ContextSuite context=TestKubernetesCluster>:teardown Error 114.51 test_kubernetes_clusters.py

@DaanHoogland

Copy link
Copy Markdown
Contributor

This looks good to me, the kubernetes errors seem to be bugs in the tests assuming a state is returned when it is not in the assertions. If not that these are environmental.
cc @shwstppr @davidjumani

@DaanHoogland
DaanHoogland merged commit 523ab58 into apache:4.18 Mar 21, 2023
@JoaoJandre

Copy link
Copy Markdown
Contributor Author

@DaanHoogland this was merged into 4.18 instead of main, is this correct?

@DaanHoogland

Copy link
Copy Markdown
Contributor

@JoaoJandre you will find it also if you look at the main git log . It was merged forward (as all fixes on prior release branches should) if you fix something now on 4.17, we will forward merge it on 4.18 and then on main.

@DaanHoogland DaanHoogland added this to the 4.18.1.0 milestone Mar 22, 2023
DaanHoogland added a commit that referenced this pull request Mar 23, 2023
* 4.18:
  Fix PR 7131 bugs and vulnerabilities (#7140)
kishankavala pushed a commit to shapeblue/cloudstack that referenced this pull request Apr 13, 2023
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.

7 participants