Skip to content

Public IP quarantine feature - #7378

Merged
DaanHoogland merged 34 commits into
apache:mainfrom
scclouds:ip-quarantine
Nov 15, 2023
Merged

Public IP quarantine feature#7378
DaanHoogland merged 34 commits into
apache:mainfrom
scclouds:ip-quarantine

Conversation

@BryanMLima

Copy link
Copy Markdown
Contributor

Description

This PR aims to add the concept of quarantine for public IPs. The feature is fully described in issue #7369. The main goal of this functionality is to block the allocation of a disassociated public IP address by a configurable duration, public.ip.address.quarantine.duration. This can prevent the allocation of this recently disassociated IP to another user. More critically, this feature can prevent the allocation of an IP that has been blacklisted for inappropriate use by the previous owner.

Fixes: #7369

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

How Has This Been Tested?

I added some unit tests to validate the core logic of this feature. Moreover, I tested in a local lab the whole process of disassociation of a public IP address and trying to allocate different accounts with different roles. As designed, only the previous owner was able to allocate the quarantined IP. Furthermore, I tested if the previous behavior is maintained, as the default value for the global configuration public.ip.address.quarantine.duration is 0, no public IP address is added to quarantined, as expected.

@github-actions

Copy link
Copy Markdown

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

@sonarqubecloud

Copy link
Copy Markdown

@DaanHoogland

Copy link
Copy Markdown
Contributor

SonarCloud Quality Gate failed. Quality Gate failed

BugA0 BugsVulnerabilityA0 VulnerabilitiesSecurity HotspotA0 Security HotspotsCode SmellA15 Code Smells

16.6%16.6% Coverage0.2%0.2% Duplication

@BryanMLima can you have a look at those code smells? most of those are not your doing but there are some easy wins there.

Comment threadserver/src/main/java/com/cloud/network/IpAddressManagerImpl.java Outdated
Comment threadserver/src/main/java/com/cloud/network/IpAddressManagerImpl.java Outdated
Comment threadengine/components-api/src/main/java/com/cloud/network/IpAddressManager.java Outdated
Comment threadengine/components-api/src/main/java/com/cloud/network/IpAddressManager.java Outdated
Comment threadserver/src/main/java/com/cloud/network/IpAddressManagerImpl.java Outdated
@codecov

codecovBot commented Apr 28, 2023

Copy link
Copy Markdown

Codecov Report

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

Comparison is base (bd52fa8) 29.20% compared to head (3fb9586) 29.13%.
Report is 50 commits behind head on main.

FilesPatch %Lines
...n/java/com/cloud/network/IpAddressManagerImpl.java48.48%31 Missing and 3 partials ⚠️
.../cloudstack/api/response/IpQuarantineResponse.java0.00%26 Missing ⚠️
...ava/com/cloud/network/vo/PublicIpQuarantineVO.java21.42%22 Missing ⚠️
...src/main/java/com/cloud/api/ApiResponseHelper.java0.00%13 Missing ⚠️
...i/command/user/address/UpdateQuarantinedIpCmd.java0.00%12 Missing ⚠️
...i/command/user/address/RemoveQuarantinedIpCmd.java0.00%11 Missing ⚠️
...ain/java/com/cloud/api/query/QueryManagerImpl.java63.33%9 Missing and 2 partials ⚠️
...ain/java/com/cloud/network/NetworkServiceImpl.java67.64%11 Missing ⚠️
...pi/command/user/address/ListQuarantinedIpsCmd.java0.00%9 Missing ⚠️
...c/main/java/com/cloud/utils/db/GenericDaoBase.java27.27%7 Missing and 1 partial ⚠️
... and 3 more
Additional details and impacted files
@@ Coverage Diff @@## main #7378 +/- ##
============================================
- Coverage 29.20% 29.13% -0.07% - Complexity 30891 31034 +143 
============================================
Files 5150 5192 +42 Lines 363420 366141 +2721 Branches 53230 53529 +299 ============================================
+ Hits 106144 106690 +546 - Misses 242730 244844 +2114 - Partials 14546 14607 +61 
FlagCoverage Δ
simulator-marvin-tests25.06% <28.21%> (-0.19%)⬇️
uitests4.49% <0.00%> (-0.06%)⬇️
unit-tests14.81% <28.70%> (+0.12%)⬆️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@github-actions

Copy link
Copy Markdown

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

@blueorangutan

Copy link
Copy Markdown

[SF] Trillian test result (tid-8097)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 37731 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr7378-t8097-kvm-centos7.zip
Smoke tests completed. 90 look OK, 24 have errors, 0 did not run
Only failed and skipped tests results shown below:

TestResultTime (s)Test File
test_another_user_can_allocate_ip_after_quarantined_has_ended_networkError4.78test_quarantined_ips.py
test_another_user_can_allocate_ip_after_quarantined_has_ended_vpcError0.32test_quarantined_ips.py
test_only_owner_can_allocate_ip_in_quarantine_networkError1.48test_quarantined_ips.py
test_only_owner_can_allocate_ip_in_quarantine_vpcError0.33test_quarantined_ips.py
test_DeleteDomainError23.21test_accounts.py
test_forceDeleteDomainFailure20.25test_accounts.py
ContextSuite context=TestPublicIP>:setupError11.14test_network.py
test_reboot_routerError9.51test_network.py
test_releaseIPError9.36test_network.py
ContextSuite context=TestRouterRules>:setupError18.73test_network.py
test_DeployVmAffinityGroupError7.43test_affinity_groups.py
test_network_aclError1.15test_network_acl.py
ContextSuite context=TestNatRuleUsage>:setupError32.97test_usage.py
ContextSuite context=TestPublicIPUsage>:setupError42.05test_usage.py
ContextSuite context=TestSnapshotUsage>:setupError51.13test_usage.py
ContextSuite context=TestVmUsage>:setupError80.07test_usage.py
ContextSuite context=TestVpnUsage>:setupError231.55test_usage.py
test_02_upgrade_kubernetes_clusterFailure568.20test_kubernetes_clusters.py
test_08_upgrade_kubernetes_ha_clusterFailure662.43test_kubernetes_clusters.py
ContextSuite context=TestSnapshotStandaloneBackup>:setupError99.11test_snapshots.py
ContextSuite context=TestSetSourceNatIp>:setupError0.00test_set_sourcenat.py
test_01_native_to_native_network_migrationError22.01test_migration.py
test_02_native_to_native_vpc_migrationError4.15test_migration.py
test_04_deploy_vm_for_other_user_and_test_vm_operationsFailure46.32test_network_permissions.py
ContextSuite context=TestNetworkPermissions>:teardownError1.37test_network_permissions.py
test_02_vpc_privategw_static_routesFailure3.05test_privategw_acl.py
test_03_vpc_privategw_restart_vpc_cleanupFailure3.03test_privategw_acl.py
test_04_rvpc_privategw_static_routesFailure4.16test_privategw_acl.py
ContextSuite context=TestRouterDHCPOpts>:setupError113.83test_router_dhcphosts.py
test_02_routervm_iptables_policiesError4.34test_routers_iptables_default_policy.py
test_01_single_VPC_iptables_policiesError1.21test_routers_iptables_default_policy.py
test_01_isolate_network_FW_PF_default_routes_egress_trueError5.48test_routers_network_ops.py
test_01_RVR_Network_FW_PF_SSH_default_routes_egress_trueError0.26test_routers_network_ops.py
test_02_RVR_Network_FW_PF_SSH_default_routes_egress_falseError0.28test_routers_network_ops.py
test_03_RVR_Network_check_router_stateError0.24test_routers_network_ops.py
ContextSuite context=TestServiceOfferings>:setupError9.86test_service_offerings.py
ContextSuite context=TestTemplates>:setupError45.35test_templates.py
ContextSuite context=TestVmAutoScaling>:setupError0.00test_vm_autoscaling.py
test_01_secure_vm_migrationError69.27test_vm_life_cycle.py
ContextSuite context=TestVMLifeCycle>:setupError9.37test_vm_life_cycle.py
ContextSuite context=TestVolumes>:setupError7.40test_volumes.py
test_02_redundant_VPC_default_routesError4.14test_vpc_redundant.py
test_03_create_redundant_VPC_1tier_2VMs_2IPs_2PF_ACL_reboot_routersError3.19test_vpc_redundant.py
test_04_rvpc_network_garbage_collector_nicsError4.08test_vpc_redundant.py
test_05_rvpc_multi_tiersError3.08test_vpc_redundant.py
test_01_VPC_nics_after_destroyError3.17test_vpc_router_nics.py
test_01_vpc_site2site_vpn_multiple_optionsFailure1.31test_vpc_vpn.py
test_01_vpc_site2site_vpn_multiple_optionsError1.32test_vpc_vpn.py
test_01_vpc_remote_access_vpnFailure0.09test_vpc_vpn.py
test_01_vpc_site2site_vpnFailure3.34test_vpc_vpn.py
test_01_vpc_site2site_vpnError3.35test_vpc_vpn.py
test_02_cancel_host_maintenace_with_migration_jobsError0.45test_host_maintenance.py
test_03_cancel_host_maintenace_with_migration_jobs_failureError0.49test_host_maintenance.py
test_01_cancel_host_maintenance_ssh_enabled_agent_connectedFailure1.16test_host_maintenance.py
test_03_cancel_host_maintenance_ssh_disabled_agent_connectedFailure0.15test_host_maintenance.py
test_04_cancel_host_maintenance_ssh_disabled_agent_disconnectedFailure0.11test_host_maintenance.py

@DaanHoogland

Copy link
Copy Markdown
Contributor

@BryanMLima , can you resolve the conflicts?

@shwstppr

Copy link
Copy Markdown
Contributor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

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

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 7551

@shwstppr

Copy link
Copy Markdown
Contributor

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

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

@blueorangutan

Copy link
Copy Markdown

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

TestResultTime (s)Test File
test_another_user_can_allocate_ip_after_quarantined_has_ended_vpcError5.11test_quarantined_ips.py
test_only_owner_can_allocate_ip_in_quarantine_vpcError5.05test_quarantined_ips.py

@shwstppr

Copy link
Copy Markdown
Contributor

@BryanMLima can you please check the failing smoke test?

@shwstppr

Copy link
Copy Markdown
Contributor

@BryanMLima any update on this?

@BryanMLima

Copy link
Copy Markdown
ContributorAuthor

@shwstppr sorry for the delay, I will have time to work on this later this week.

@BryanMLima

Copy link
Copy Markdown
ContributorAuthor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

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

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 7709

@DaanHoogland

Copy link
Copy Markdown
Contributor

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

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

@BryanMLima

Copy link
Copy Markdown
ContributorAuthor

Hi @BryanMLima

The feature is nice

Can the following api's have an additional parameter of "ipaddress"

So that the user can easily provide the ip address instead of providing the id

1. update quarantinedip
2. remove quarantinedip

Similar to The associateIPaddress api call which has ipaddress parameter

https://cloudstack.apache.org/api/apidocs-4.18/apis/associateIpAddress.html

@kiranchavala, I addressed this enhancement, now it is possible to inform the ID of the quarantine or the address of the public IP in quarantine. It will be useful for the UI implementation of this functionality in the future.

@DaanHoogland

Copy link
Copy Markdown
Contributor

test results:

Smoke tests completed. 116 look OK, 2 have errors, 0 did not run
Only failed and skipped tests results shown below:

TestResultTime (s)Test File
test_01_invalid_upgrade_kubernetes_clusterFailure3605.01test_kubernetes_clusters.py
test_02_upgrade_kubernetes_clusterFailure3617.44test_kubernetes_clusters.py
test_03_deploy_and_scale_kubernetes_clusterFailure0.06test_kubernetes_clusters.py
test_04_autoscale_kubernetes_clusterFailure0.04test_kubernetes_clusters.py
test_05_basic_lifecycle_kubernetes_clusterFailure0.03test_kubernetes_clusters.py
test_06_delete_kubernetes_clusterFailure0.05test_kubernetes_clusters.py
test_07_deploy_kubernetes_ha_clusterFailure0.04test_kubernetes_clusters.py
test_08_upgrade_kubernetes_ha_clusterFailure0.04test_kubernetes_clusters.py
test_09_delete_kubernetes_ha_clusterFailure0.04test_kubernetes_clusters.py
test_10_vpc_tier_kubernetes_clusterFailure44.61test_kubernetes_clusters.py
test_11_test_unmanaged_cluster_lifecycleError1.22test_kubernetes_clusters.py
ContextSuite context=TestKubernetesCluster>:teardownError50.34test_kubernetes_clusters.py
test_hostha_enable_ha_when_host_in_maintenanceError303.87test_hostha_kvm.py

I will manually run the hostha test to make sure it is not related to the changes here.

@DaanHoogland

Copy link
Copy Markdown
Contributor

in a clean env:

Tests Enable HA when host is in Maintenance mode, should be Ineligible ... === TestName: test_hostha_enable_ha_when_host_in_maintenance | Status : SUCCESS ===

@DaanHoogland
DaanHoogland merged commit 1f29f6f into apache:mainNov 15, 2023
dhslove pushed a commit to ablecloud-team/ablestack-cloud that referenced this pull request Nov 16, 2023
Sign up for freeto 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.

Public IP quarantine feature

8 participants

@BryanMLima@DaanHoogland@blueorangutan@shwstppr@kiranchavala@harikrishna-patnala@borisstoyanov@winterhazel