Skip to content

Conversation

@DK101010
Copy link
Contributor

@DK101010 DK101010 commented Oct 13, 2020

Description

  • only changed HostDaoImpl.java to handle with comma separated multi host string
  • old behavior with one tag works like the old implementation

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?

manually tested (run cloudstack in my vmware environment)

PR: #4399

@DaanHoogland DaanHoogland added this to the 4.16.0.0 milestone Nov 12, 2020
@DaanHoogland
Copy link
Contributor

@DV101010 can you invest some time in an automated test?

@DK101010
Copy link
Contributor Author

DK101010 commented Nov 12, 2020 via email

@DaanHoogland
Copy link
Contributor

@DK101010 All necesary steps/items are in the cwiki in that article and in others, but if you have specific questions the [email protected] list can give more feedback.

@DK101010
Copy link
Contributor Author

DK101010 commented Dec 4, 2020

Hi @DaanHoogland,
I have added a marvin test and tried to implement a generic solution, but a couple of things must be adapt like host, network name and hypervisor as well I couldn't found a option to test the ingest feature with marvin.

Let me know if I can improve the test.

@DaanHoogland
Copy link
Contributor

@blueorangutan test centos7 kvm-centos7 keepEnv

encapsulate multi tag check from Ingest Feature, DepolymentPlanningManager into
HostDaoImpl to prevent code duplicates
@DK101010
Copy link
Contributor Author

DK101010 commented Dec 9, 2020

Hi,
yesterday we had a problem during our deployment and I've found a additional tag check in the DeploymentPlanningManager. To prevent code duplicates I've encapsulate tag handling in HostDaoImpl. But I afraid I can not write test for this because we use currently a older version.

Comment on lines 485 to 502
@Override
public boolean checkHostServiceOfferingTags(HostVO host, ServiceOffering serviceOffering){
if (host == null) {
return false;
}
if (serviceOffering == null) {
return false;
}
if (Strings.isNullOrEmpty(serviceOffering.getHostTag())) {
return true;
}

List<String> serviceOfferingTags = Arrays.asList(serviceOffering.getHostTag().split(","));
if(host.getHostTags() != null && host.getHostTags().containsAll(serviceOfferingTags)){
return true;
}
return false;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

trying to isolate this check is fine but the DAO is for DB interaction, and this is really business logic. personally I would make it a default method for the Host interface, but a member of HostVO could also be.
Can you (shortly) explain why you put it here, @DK101010 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi,
In the HostDaoImpl there are a couple of other methods that are check host tags, therefore i thought will be good to add this also here. So will be encapsulate common logic in one class, but my experience is still not very well in CS and when it destroy other guidelines then will be also ok to move this method. For me sounds HostVO good, because it seems to be only relevant for this object.

Copy link
Contributor

Choose a reason for hiding this comment

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

as said I prefer a default method on the interface but it maight require undesirable imports so HostVO is good for my part.

Copy link
Contributor

Choose a reason for hiding this comment

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

will you be moving this method @DK101010 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

is moved ;)

@DaanHoogland
Copy link
Contributor

Hi,
yesterday we had a problem during our deployment and I've found a additional tag check in the DeploymentPlanningManager. To prevent code duplicates I've encapsulate tag handling in HostDaoImpl. But I afraid I can not write test for this because we use currently a older version.

very good to avoid duplicates, but I'd put it in the Host object hierarchy somewhere. For this piece of code a unit test would do, @DK101010 . no need for an integration test as far as I can see.

@apache apache deleted a comment from blueorangutan Dec 12, 2020
@apache apache deleted a comment from blueorangutan Dec 12, 2020
@apache apache deleted a comment from blueorangutan Dec 12, 2020
@apache apache deleted a comment from blueorangutan Dec 12, 2020
@apache apache deleted a comment from blueorangutan Dec 12, 2020
@apache apache deleted a comment from blueorangutan Dec 12, 2020
@DK101010
Copy link
Contributor Author

@DK101010 yes, I agree it should not be allowed. but, since it is allowed in 4.15 and previous versions, it might already exists in some/few user environments that a host have a same tag multiple times (who knows...).
IMHO options are
(1) check and throw an exception (as you said) or silently ignoring the duplicated tags, and remove duplications in host_tags in next cloudstack upgrade, or
(2) change your sql to take the scenario into consideration.
I would go for (1), but it looks (2) is much easier to you.

@weizhouapache I'm also for (1), it is cleaner. But we need also checks in the frontend for future actions to prevent doubles. Also I think a DB upgrade is not necessary. In my opinion it is for a user a small thing to fix this mistake. Especially as I can't imagine that there are so many duplicate tags in use.

@weizhouapache
Copy link
Member

@DK101010 yes, I agree it should not be allowed. but, since it is allowed in 4.15 and previous versions, it might already exists in some/few user environments that a host have a same tag multiple times (who knows...).
IMHO options are
(1) check and throw an exception (as you said) or silently ignoring the duplicated tags, and remove duplications in host_tags in next cloudstack upgrade, or
(2) change your sql to take the scenario into consideration.
I would go for (1), but it looks (2) is much easier to you.

@weizhouapache I'm also for (1), it is cleaner. But we need also checks in the frontend for future actions to prevent doubles. Also I think a DB upgrade is not necessary. In my opinion it is for a user a small thing to fix this mistake. Especially as I can't imagine that there are so many duplicate tags in use.

@DK101010
if we choose (1), we should fix it in api/java code as well as gui.

IMHO DB upgrade is also required, as we need to remove the duplications in cloudstack upgrade (otherwise it needs user intervention to remove them from DB manually ). for example, we need to remove record with id=62 from below

mysql> select * from host_tags;
+----+---------+------+
| id | host_id | tag  |
+----+---------+------+
| 61 |       4 | tag1 |
| 62 |       4 | tag1 |
+----+---------+------+
2 rows in set (0.00 sec)

it is not a small change. I confirm that we can set same storage tag two times on a primary storage as well.

@DK101010
Copy link
Contributor Author

@DK101010 yes, I agree it should not be allowed. but, since it is allowed in 4.15 and previous versions, it might already exists in some/few user environments that a host have a same tag multiple times (who knows...).
IMHO options are
(1) check and throw an exception (as you said) or silently ignoring the duplicated tags, and remove duplications in host_tags in next cloudstack upgrade, or
(2) change your sql to take the scenario into consideration.
I would go for (1), but it looks (2) is much easier to you.

@weizhouapache I'm also for (1), it is cleaner. But we need also checks in the frontend for future actions to prevent doubles. Also I think a DB upgrade is not necessary. In my opinion it is for a user a small thing to fix this mistake. Especially as I can't imagine that there are so many duplicate tags in use.

@DK101010
if we choose (1), we should fix it in api/java code as well as gui.

IMHO DB upgrade is also required, as we need to remove the duplications in cloudstack upgrade (otherwise it needs user intervention to remove them from DB manually ). for example, we need to remove record with id=62 from below

mysql> select * from host_tags;
+----+---------+------+
| id | host_id | tag  |
+----+---------+------+
| 61 |       4 | tag1 |
| 62 |       4 | tag1 |
+----+---------+------+
2 rows in set (0.00 sec)

it is not a small change. I confirm that we can set same storage tag two times on a primary storage as well.

OK, I thought the user can change the tags over the UI.

So we need additional
- Checks for UI Input for Host and SO
- Checks for API input for Host and SO
- Exception for findHostByComputeOfferings
- SQL Upgrade script

@weizhouapache
Copy link
Member

@DK101010 yes, I agree it should not be allowed. but, since it is allowed in 4.15 and previous versions, it might already exists in some/few user environments that a host have a same tag multiple times (who knows...).
IMHO options are
(1) check and throw an exception (as you said) or silently ignoring the duplicated tags, and remove duplications in host_tags in next cloudstack upgrade, or
(2) change your sql to take the scenario into consideration.
I would go for (1), but it looks (2) is much easier to you.

@weizhouapache I'm also for (1), it is cleaner. But we need also checks in the frontend for future actions to prevent doubles. Also I think a DB upgrade is not necessary. In my opinion it is for a user a small thing to fix this mistake. Especially as I can't imagine that there are so many duplicate tags in use.

@DK101010
if we choose (1), we should fix it in api/java code as well as gui.
IMHO DB upgrade is also required, as we need to remove the duplications in cloudstack upgrade (otherwise it needs user intervention to remove them from DB manually ). for example, we need to remove record with id=62 from below

mysql> select * from host_tags;
+----+---------+------+
| id | host_id | tag  |
+----+---------+------+
| 61 |       4 | tag1 |
| 62 |       4 | tag1 |
+----+---------+------+
2 rows in set (0.00 sec)

it is not a small change. I confirm that we can set same storage tag two times on a primary storage as well.

OK, I thought the user can change the tags over the UI.

So we need additional

  • Checks for UI Input for Host and SO
  • Checks for API input for Host and SO
  • Exception for findHostByComputeOfferings
  • SQL Upgrade script

@DK101010 yes, it looks a bit complicated. I suggest you to change SQL in this pr as 1st step.

@nvazquez
Copy link
Contributor

nvazquez commented Aug 3, 2021

Thanks for start incorporating the suggested changes @DK101010, let us know when it is ready for review

@weizhouapache
Copy link
Member

@blueorangutan package

@blueorangutan
Copy link

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

@blueorangutan
Copy link

Packaging result: ✖️ el7 ✖️ el8 ✖️ debian ✖️ suse15. SL-JID 740

@weizhouapache
Copy link
Member

@DK101010 could you please fix the conflicts ?

@weizhouapache
Copy link
Member

@blueorangutan package

@blueorangutan
Copy link

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

@blueorangutan
Copy link

Packaging result: ✔️ el7 ✔️ el8 ✔️ debian. SL-JID 748

@weizhouapache
Copy link
Member

@blueorangutan test

@blueorangutan
Copy link

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

@weizhouapache
Copy link
Member

tested ok

@blueorangutan
Copy link

Trillian test result (tid-1471)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 47094 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr4399-t1471-kvm-centos7.zip
Intermittent failure detected: /marvin/tests/smoke/test_internal_lb.py
Intermittent failure detected: /marvin/tests/smoke/test_resource_accounting.py
Intermittent failure detected: /marvin/tests/smoke/test_router_dnsservice.py
Intermittent failure detected: /marvin/tests/smoke/test_routers_network_ops.py
Intermittent failure detected: /marvin/tests/smoke/test_vpc_redundant.py
Intermittent failure detected: /marvin/tests/smoke/test_vpc_vpn.py
Smoke tests completed. 86 look OK, 3 have error(s)
Only failed tests results shown below:

Test Result Time (s) Test File
test_01_RVR_Network_FW_PF_SSH_default_routes_egress_true Failure 144.54 test_routers_network_ops.py
test_02_RVR_Network_FW_PF_SSH_default_routes_egress_false Failure 355.92 test_routers_network_ops.py
test_03_create_redundant_VPC_1tier_2VMs_2IPs_2PF_ACL_reboot_routers Failure 552.49 test_vpc_redundant.py
test_01_vpc_site2site_vpn_multiple_options Failure 589.62 test_vpc_vpn.py
test_01_vpc_site2site_vpn Failure 256.46 test_vpc_vpn.py

@nvazquez
Copy link
Contributor

@blueorangutan package

@blueorangutan
Copy link

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

@blueorangutan
Copy link

Packaging result: ✔️ el7 ✔️ el8 ✔️ debian. SL-JID 877

@nvazquez
Copy link
Contributor

@blueorangutan test

@blueorangutan
Copy link

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

@blueorangutan
Copy link

Trillian test result (tid-1651)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 34086 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr4399-t1651-kvm-centos7.zip
Smoke tests completed. 89 look OK, 0 have error(s)
Only failed tests results shown below:

Test Result Time (s) Test File

Copy link
Contributor

@nvazquez nvazquez left a comment

Choose a reason for hiding this comment

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

LGTM

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.

Use multiple host tags in compute offerings

8 participants