Skip to content

Handle listProjects API to list projects with user as members when listAll=true - #4316

Merged
yadvr merged 3 commits into
apache:masterfrom
shapeblue:list_project_users_filter
Sep 17, 2020
Merged

Handle listProjects API to list projects with user as members when listAll=true#4316
yadvr merged 3 commits into
apache:masterfrom
shapeblue:list_project_users_filter

Conversation

@Pearl1594

@Pearl1594Pearl1594 commented Sep 10, 2020

Copy link
Copy Markdown
Contributor

Description

  1. When listAll is true, listProjects API doesn't list projects that have users as members
  2. Added defensive checks to overcome NPEs

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)

How Has This Been Tested?

This has been verified using the cmk and UI
There exists 7 projects:

MariaDB [cloud]> select name, account_id, user_id, created, removed from project_view where removed is NULL;
+--------------+------------+---------+---------------------+---------+
| name | account_id | user_id | created | removed |
+--------------+------------+---------+---------------------+---------+
| Project2 | 4 | NULL | 2020-09-09 10:08:52 | NULL |
| Project2 | 5 | 6 | 2020-09-09 10:08:52 | NULL |
| p3 | 2 | NULL | 2020-09-09 11:43:50 | NULL |
| p3 | 5 | 5 | 2020-09-09 11:43:50 | NULL |
| Project1 | 2 | NULL | 2020-09-09 12:36:03 | NULL |
| Project1 | 5 | 5 | 2020-09-09 12:36:03 | NULL |
| p1 | 2 | 2 | 2020-09-09 13:16:11 | NULL |
| p1 | 5 | 5 | 2020-09-09 13:16:11 | NULL |
| d1 | 12 | 8 | 2020-09-09 13:21:38 | NULL |
| p1 | 2 | 2 | 2020-09-09 13:16:11 | NULL |
| p1 | 5 | 5 | 2020-09-09 13:16:11 | NULL |
| p4 | 15 | 10 | 2020-09-10 05:54:44 | NULL |
| p41useradmin | 17 | 12 | 2020-09-10 06:23:43 | NULL |
| Project1 | 2 | NULL | 2020-09-09 12:36:03 | NULL |
| Project1 | 5 | 5 | 2020-09-09 12:36:03 | NULL |
+--------------+------------+---------+---------------------+---------+

Before fix:

(localcloud) SBCM5> > list projects filter=account,owner,name,id, listall=true {
"count": 2,
"project": [
{
"id": "cab2a46a-8250-4825-85ff-e18e7275eb18",
"name": "p3",
"owner": [
{
"account": "admin"
}
]
},
{
"id": "f0e64573-3483-4e4c-8164-c92e9efda80f",
"name": "Project2",
"owner": [
{
"account": "ACSUser"
}
]
}
]
}

With fix:

(localcloud) SBCM5> > list projects filter=account,owner,name,id, listall=true {
"count": 7,
"project": [
{
"id": "0f4a6c4f-a95e-4ea2-b840-e16eedf1085a",
"name": "p41useradmin",
"owner": [
{
"account": "u4",
"user": "u41",
"userid": "9d523792-a777-45c2-8b34-84052b8d4b34"
}
]
},
{
"id": "352b9a95-cc6e-412f-ad1a-7671eaebfdff",
"name": "p4",
"owner": [
{
"account": "u3",
"user": "u3",
"userid": "41d2a5e2-f45f-479b-bc2b-3c911d2b7b46"
}
]
},
{
"id": "02b5bc7b-a1e7-4e77-860e-99fd5fb30ec3",
"name": "d1",
"owner": [
{
"account": "dom1",
"user": "dom1",
"userid": "a534379c-804d-4a45-bf09-73e784adacb0"
}
]
},
{
"id": "7ab34cd7-2403-477a-a3cf-9d03c517345c",
"name": "p1",
"owner": [
{
"account": "admin",
"user": "admin",
"userid": "e125c80a-eebf-11ea-ba61-1e006a013aee"
},
{
"account": "user1",
"user": "user1",
"userid": "705136fe-2c09-4031-873f-835ee3dfad02"
}
]
},
{
"id": "f5884fbe-9ce1-4315-9a76-c1564d13dac0",
"name": "Project1",
"owner": [
{
"account": "admin"
},
{
"account": "user1",
"user": "user1",
"userid": "705136fe-2c09-4031-873f-835ee3dfad02"
}
]
},
{
"id": "cab2a46a-8250-4825-85ff-e18e7275eb18",
"name": "p3",
"owner": [
{
"account": "admin"
}
]
},
{
"id": "f0e64573-3483-4e4c-8164-c92e9efda80f",
"name": "Project2",
"owner": [
{
"account": "ACSUser"
}
]
}
]
}

@Pearl1594

Copy link
Copy Markdown
ContributorAuthor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@Pearl1594 a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.

private boolean checkOperationPermitted(Account caller, ControlledEntity entity) {
User user = CallContext.current().getCallingUser();
Project project = projectDao.findByProjectAccountId(entity.getAccountId());
if (project == null) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Are there usage of this method where throwing an exception would break flow? (or, are we expecting all usages of this method to be project related?)

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

this method is called only if the entity is owned by a project - which would mean that ideally project should be present if the entity's account is of Project type

if (owner.getType() != Account.ACCOUNT_TYPE_PROJECT && networkOwner.getType() == Account.ACCOUNT_TYPE_PROJECT) {
User user = CallContext.current().getCallingUser();
Project project = projectDao.findByProjectAccountId(network.getAccountId());
if (project == null) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same as previous comment

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

here too, the check is explicitly for networks owned by a project

@blueorangutan

Copy link
Copy Markdown

Packaging result: ✔centos7 ✔centos8 ✔debian. JID-1950

@yadvryadvr added this to the 4.15.0.0 milestone Sep 10, 2020
@yadvr

Copy link
Copy Markdown
Member

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

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

@Pearl1594Pearl1594 changed the title Handle listProjects API to list projects with user as Project Admin when listAll=trueHandle listProjects API to list projects with user as members when listAll=trueSep 10, 2020
@blueorangutan

Copy link
Copy Markdown

Trillian test result (tid-2717)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 58171 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr4316-t2717-kvm-centos7.zip
Intermittent failure detected: /marvin/tests/smoke/test_accounts.py
Intermittent failure detected: /marvin/tests/smoke/test_deploy_virtio_scsi_vm.py
Intermittent failure detected: /marvin/tests/smoke/test_deploy_vm_iso.py
Intermittent failure detected: /marvin/tests/smoke/test_deploy_vms_with_varied_deploymentplanners.py
Intermittent failure detected: /marvin/tests/smoke/test_deploy_vm_with_userdata.py
Intermittent failure detected: /marvin/tests/smoke/test_diagnostics.py
Intermittent failure detected: /marvin/tests/smoke/test_domain_service_offerings.py
Intermittent failure detected: /marvin/tests/smoke/test_internal_lb.py
Intermittent failure detected: /marvin/tests/smoke/test_iso.py
Intermittent failure detected: /marvin/tests/smoke/test_list_ids_parameter.py
Intermittent failure detected: /marvin/tests/smoke/test_loadbalance.py
Intermittent failure detected: /marvin/tests/smoke/test_metrics_api.py
Intermittent failure detected: /marvin/tests/smoke/test_multipleips_per_nic.py
Intermittent failure detected: /marvin/tests/smoke/test_nested_virtualization.py
Intermittent failure detected: /marvin/tests/smoke/test_network_acl.py
Intermittent failure detected: /marvin/tests/smoke/test_network.py
Intermittent failure detected: /marvin/tests/smoke/test_password_server.py
Intermittent failure detected: /marvin/tests/smoke/test_portforwardingrules.py
Intermittent failure detected: /marvin/tests/smoke/test_privategw_acl.py
Intermittent failure detected: /marvin/tests/smoke/test_projects.py
Intermittent failure detected: /marvin/tests/smoke/test_reset_vm_on_reboot.py
Intermittent failure detected: /marvin/tests/smoke/test_resource_accounting.py
Intermittent failure detected: /marvin/tests/smoke/test_router_dhcphosts.py
Intermittent failure detected: /marvin/tests/smoke/test_router_dns.py
Intermittent failure detected: /marvin/tests/smoke/test_router_dnsservice.py
Intermittent failure detected: /marvin/tests/smoke/test_routers_iptables_default_policy.py
Intermittent failure detected: /marvin/tests/smoke/test_routers_network_ops.py
Intermittent failure detected: /marvin/tests/smoke/test_routers.py
Intermittent failure detected: /marvin/tests/smoke/test_service_offerings.py
Intermittent failure detected: /marvin/tests/smoke/test_snapshots.py
Intermittent failure detected: /marvin/tests/smoke/test_vpc_redundant.py
Intermittent failure detected: /marvin/tests/smoke/test_hostha_kvm.py
Smoke tests completed. 54 look OK, 31 have error(s)
Only failed tests results shown below:

TestResultTime (s)Test File
ContextSuite context=TestDeployVirtioSCSIVM>:setupError0.00test_deploy_virtio_scsi_vm.py
test_deploy_vm_from_isoError0.00test_deploy_vm_iso.py
ContextSuite context=TestInternalLb>:setupError0.00test_internal_lb.py
ContextSuite context=TestDeployVmWithVariedPlanners>:setupError0.00test_deploy_vms_with_varied_deploymentplanners.py
test_01_1_create_iso_with_checksum_sha1_negativeError66.71test_iso.py
test_01_create_iso_with_checksum_sha1Error65.59test_iso.py
test_01_create_iso_with_checksum_sha1Error66.70test_iso.py
test_02_1_create_iso_with_checksum_sha256_negativeError66.86test_iso.py
test_02_create_iso_with_checksum_sha256Error65.61test_iso.py
test_02_create_iso_with_checksum_sha256Error66.74test_iso.py
test_03_1_create_iso_with_checksum_md5_negativeError66.67test_iso.py
test_03_create_iso_with_checksum_md5Error65.66test_iso.py
test_03_create_iso_with_checksum_md5Error66.79test_iso.py
test_04_create_iso_with_no_checksumError65.67test_iso.py
test_04_create_iso_with_no_checksumError66.76test_iso.py
test_01_create_isoFailure1517.64test_iso.py
ContextSuite context=TestISO>:setupError3036.02test_iso.py
ContextSuite context=TestDeployVmWithUserData>:setupError0.00test_deploy_vm_with_userdata.py
ContextSuite context=TestRemoteDiagnostics>:setupError0.00test_diagnostics.py
ContextSuite context=TestLoadBalance>:setupError0.00test_loadbalance.py
ContextSuite context=TestDomainsServiceOfferings>:setupError2.91test_domain_service_offerings.py
ContextSuite context=TestListIdsParams>:setupError0.00test_list_ids_parameter.py
test_list_vms_metricsError0.28test_metrics_api.py
test_nic_secondaryip_add_removeError0.05test_multipleips_per_nic.py
ContextSuite context=TestNestedVirtualization>:setupError0.00test_nested_virtualization.py
ContextSuite context=TestNetworkACL>:setupError0.00test_network_acl.py
test_delete_accountError0.47test_network.py
test_delete_network_while_vm_on_itError0.09test_network.py
test_deploy_vm_l2networkError0.10test_network.py
test_l2network_restartError0.15test_network.py
ContextSuite context=TestPortForwarding>:setupError1.54test_network.py
ContextSuite context=TestPublicIP>:setupError1.06test_network.py
test_reboot_routerError0.06test_network.py
test_releaseIPError0.48test_network.py
ContextSuite context=TestRouterRules>:setupError0.58test_network.py
ContextSuite context=TestIsolatedNetworksPasswdServer>:setupError0.00test_password_server.py
ContextSuite context=TestResetVmOnReboot>:setupError0.00test_reset_vm_on_reboot.py
ContextSuite context=TestPortForwardingRules>:setupError0.00test_portforwardingrules.py
ContextSuite context=TestPrivateGwACL>:setupError0.00test_privategw_acl.py
test_09_project_suspendError0.10test_projects.py
test_10_project_activationError0.09test_projects.py
ContextSuite context=TestRAMCPUResourceAccounting>:setupError0.00test_resource_accounting.py
ContextSuite context=TestRouterDHCPHosts>:setupError0.00test_router_dhcphosts.py
ContextSuite context=TestRouterDHCPOpts>:setupError0.00test_router_dhcphosts.py
ContextSuite context=TestRouterDns>:setupError0.00test_router_dns.py
ContextSuite context=TestRouterDnsService>:setupError0.00test_router_dnsservice.py
ContextSuite context=TestRouterIpTablesPolicies>:setupError0.00test_routers_iptables_default_policy.py
ContextSuite context=TestVPCIpTablesPolicies>:setupError0.00test_routers_iptables_default_policy.py
test_01_isolate_network_FW_PF_default_routes_egress_trueError0.21test_routers_network_ops.py
test_02_isolate_network_FW_PF_default_routes_egress_falseError0.28test_routers_network_ops.py
ContextSuite context=TestRedundantIsolateNetworks>:setupError0.87test_routers_network_ops.py
ContextSuite context=TestRouterServices>:setupError0.00test_routers.py
ContextSuite context=TestCpuCapServiceOfferings>:setupError0.00test_service_offerings.py
ContextSuite context=TestServiceOfferings>:setupError3.20test_service_offerings.py
ContextSuite context=TestSnapshotRootDisk>:setupError0.00test_snapshots.py
test_03_create_redundant_VPC_1tier_2VMs_2IPs_2PF_ACL_reboot_routersFailure340.68test_vpc_redundant.py
test_hostha_kvm_host_fencingError177.66test_hostha_kvm.py

@Pearl1594

Copy link
Copy Markdown
ContributorAuthor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@Pearl1594 a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result: ✔centos7 ✔centos8 ✖debian. JID-1953

@Pearl1594

Copy link
Copy Markdown
ContributorAuthor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@Pearl1594 a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result: ✖centos7 ✖centos8 ✖debian. JID-1954

@Pearl1594

Copy link
Copy Markdown
ContributorAuthor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@Pearl1594 a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result: ✔centos7 ✔centos8 ✔debian. JID-1955

@Pearl1594

Copy link
Copy Markdown
ContributorAuthor

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

@Pearl1594 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-2718)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 74705 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr4316-t2718-kvm-centos7.zip
Intermittent failure detected: /marvin/tests/smoke/test_privategw_acl.py
Intermittent failure detected: /marvin/tests/smoke/test_pvlan.py
Intermittent failure detected: /marvin/tests/smoke/test_router_dhcphosts.py
Intermittent failure detected: /marvin/tests/smoke/test_vpc_redundant.py
Intermittent failure detected: /marvin/tests/smoke/test_hostha_kvm.py
Smoke tests completed. 81 look OK, 4 have error(s)
Only failed tests results shown below:

TestResultTime (s)Test File
test_02_vpc_privategw_static_routesFailure253.21test_privategw_acl.py
test_03_vpc_privategw_restart_vpc_cleanupFailure338.73test_privategw_acl.py
test_04_rvpc_privategw_static_routesFailure501.95test_privategw_acl.py
test_create_pvlan_networkError0.20test_pvlan.py
test_03_create_redundant_VPC_1tier_2VMs_2IPs_2PF_ACL_reboot_routersFailure541.83test_vpc_redundant.py
test_05_rvpc_multi_tiersError3813.82test_vpc_redundant.py
test_05_rvpc_multi_tiersError3972.65test_vpc_redundant.py
test_hostha_kvm_host_fencingError191.82test_hostha_kvm.py

@yadvr

Copy link
Copy Markdown
Member

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result: ✖centos7 ✖centos8 ✖debian. JID-1985

@yadvr

Copy link
Copy Markdown
Member

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result: ✖centos7 ✖centos8 ✖debian. JID-2009

@yadvr

Copy link
Copy Markdown
Member

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result: ✔centos7 ✔centos8 ✔debian. JID-2013

@yadvr

Copy link
Copy Markdown
Member

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

@rhtyd 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-2754)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 50934 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr4316-t2754-kvm-centos7.zip
Intermittent failure detected: /marvin/tests/smoke/test_kubernetes_clusters.py
Intermittent failure detected: /marvin/tests/smoke/test_vpc_redundant.py
Intermittent failure detected: /marvin/tests/smoke/test_hostha_kvm.py
Smoke tests completed. 82 look OK, 3 have error(s)
Only failed tests results shown below:

TestResultTime (s)Test File
test_01_deploy_kubernetes_clusterError0.08test_kubernetes_clusters.py
test_02_deploy_kubernetes_ha_clusterError0.04test_kubernetes_clusters.py
test_04_deploy_and_upgrade_kubernetes_clusterError0.04test_kubernetes_clusters.py
test_05_deploy_and_upgrade_kubernetes_ha_clusterError0.03test_kubernetes_clusters.py
test_06_deploy_and_invalid_upgrade_kubernetes_clusterError0.03test_kubernetes_clusters.py
test_07_deploy_and_scale_kubernetes_clusterError0.04test_kubernetes_clusters.py
test_01_create_redundant_VPC_2tiers_4VMs_4IPs_4PF_ACLFailure433.15test_vpc_redundant.py
test_02_redundant_VPC_default_routesFailure436.55test_vpc_redundant.py
test_03_create_redundant_VPC_1tier_2VMs_2IPs_2PF_ACL_reboot_routersError432.88test_vpc_redundant.py
test_04_rvpc_network_garbage_collector_nicsError3856.49test_vpc_redundant.py
test_hostha_kvm_host_fencingError98.32test_hostha_kvm.py

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

LGTM

@yadvr

Copy link
Copy Markdown
Member

Lgtm, test failures unrelated

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.

5 participants

@Pearl1594@blueorangutan@yadvr@shwstppr@DaanHoogland