Fix for mapping guest OS type read from OVF to existing guest OS in C…#4553
Conversation
|
@blueorangutan package |
|
@harikrishna-patnala a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
|
Packaging result: ✔centos7 ✔centos8 ✔debian. JID-2501 |
|
@blueorangutan test centos7 vmware-67u3 |
|
@rhtyd a Trillian-Jenkins test job (centos7 mgmt + vmware-67u3) has been kicked to run smoke tests |
|
Trillian test result (tid-3355)
|
|
Marking it as blocker - the deploy as-is created regression in VM template registration. |
|
@blueorangutan package |
|
@harikrishna-patnala a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
DaanHoogland
left a comment
There was a problem hiding this comment.
I think the assuption of what is "like" another string is so dangerous that we might as well just pick the last if the strings aren't equal.
| * @param str1 | ||
| * String that needs editing | ||
| * @param str2 | ||
| * Target string that needs after editing |
There was a problem hiding this comment.
| * @param str1 | |
| * String that needs editing | |
| * @param str2 | |
| * Target string that needs after editing | |
| * @param str1 String that needs editing | |
| * @param str2 Target string that is required/expected after editing |
There was a problem hiding this comment.
Updated this section with suggested changes
| * Target string that needs after editing | ||
| * @return minimum number of edits required to convert str1 to str2 | ||
| */ | ||
| public static int minimumEditDistance(String str1, String str2) { |
There was a problem hiding this comment.
can we have some unit tests for this, please?
I think it assumes a definition of what an edit is, that we need to make explicit as well.
There was a problem hiding this comment.
Added unit tests in new commit.
|
Packaging result: ✔centos7 ✔centos8 ✔debian. JID-2503 |
| public void testBestMatchStringWithEditDistance() { | ||
| String str1 = "FreeBSD 11 (32bit)"; | ||
| String str2 = "FreeBSD 12 (64bit)"; | ||
| String targetString = "FreeBSD 64bit"; |
There was a problem hiding this comment.
maybe not here but as extra:
| public void testBestMatchStringWithEditDistance() { | |
| String str1 = "FreeBSD 11 (32bit)"; | |
| String str2 = "FreeBSD 12 (64bit)"; | |
| String targetString = "FreeBSD 64bit"; | |
| public void testBestFreeBSDWithEditDistance() { | |
| String str1 = "FreeBSD 11 (32bit)"; | |
| String str2 = "FreeBSD 22 (64bit)"; | |
| String targetString = "FreeBSD 11 (64bit)"; |
| public void testBestMatchStringWithEditDistance() { | |
| String str1 = "FreeBSD 11 (32bit)"; | |
| String str2 = "FreeBSD 12 (64bit)"; | |
| String targetString = "FreeBSD 64bit"; | |
| public void testBestFedoraWithEditDistance() { | |
| String str1 = "Fedora 29 (32bit)"; | |
| String str2 = "FreeBSD 32 (64bit)"; | |
| String targetString = "FreeBSD 33 (32bit)"; |
| public void testBestMatchStringWithEditDistance() { | |
| String str1 = "FreeBSD 11 (32bit)"; | |
| String str2 = "FreeBSD 12 (64bit)"; | |
| String targetString = "FreeBSD 64bit"; | |
| public void testBestUbuntuWithEditDistance() { | |
| String str1 = "ubuntu 14.04 (32bit)"; | |
| String str2 = "ubuntu 20.10 (64bit)"; | |
| String targetString = "ubuntu 18.04 (64bit)"; |
nvazquez
left a comment
There was a problem hiding this comment.
I like the proposed approach, but I'm also thinking that we could check the longest prefix match or a mix of both approaches.
Examples:
Ubuntu 4.10
Ubuntu 8.10
Ubuntu 8.04
Ubuntu 8.10
In case 1) we have minDistance = 1 however by longer prefix we could have chosen case 2)
Opinions? @DaanHoogland @rhtyd @harikrishna-patnala @andrijapanicsb
|
|
since we are using a generic algorithm here I think if we have to handle these kind of special cases we need to add special checks for bits. Likewise if there is some other scenario we need to handle that separately too.. Since this string comes from a description 32 bit can written in any format (32-bit, 32bit, 32 bit, 32_bit). So atleast in this case I don't see a generic solution at the moment. |
|
fair enough @harikrishna-patnala . I don't think we can rely on anything but an unlikely exact match. |
|
@rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
|
Packaging result: ✔centos7 ✔centos8 ✔debian. JID-2506 |
|
@blueorangutan test matrix |
|
@rhtyd a Trillian-Jenkins matrix job (centos7 mgmt + xs71, centos7 mgmt + vmware65, centos7 mgmt + kvmcentos7) has been kicked to run smoke tests |
|
Trillian test result (tid-3360)
|
f03be40 to
2815d01
Compare
|
@DaanHoogland @rhtyd @nvazquez updated the logic to equals ignore case (removed min edit distance algorithm). I've retested the cases mentioned in the description. Please review |
|
@blueorangutan package |
|
@rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
| } | ||
| } | ||
| } | ||
| if (null == guestOsId) { |
There was a problem hiding this comment.
Minor nit - I think variable == null maybe more readable, but as I said that's not picking
There was a problem hiding this comment.
depends on how accustomed you are in right to left reading ;)
There was a problem hiding this comment.
making habit of this to avoid setting null to the variable by mistake, in that case IDE also don't know if it is logically wrong "if (guestOsId = null)" :p
DaanHoogland
left a comment
There was a problem hiding this comment.
I think we can agree this is the least bad solution (for now)
|
Packaging result: ✔centos7 ✔centos8 ✔debian. JID-2509 |
|
@blueorangutan test centos7 vmware-67u3 |
|
@rhtyd a Trillian-Jenkins test job (centos7 mgmt + vmware-67u3) has been kicked to run smoke tests |
|
Trillian test result (tid-3366)
|
…loudStack database while registering VMware template
2815d01 to
4b8adeb
Compare
|
Resolved the merge conflicts. @rhtyd @nvazquez Please do the last review |
|
@blueorangutan package |
|
@harikrishna-patnala a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress. |
|
Packaging result: ✔centos7 ✔centos8 ✔debian. JID-2514 |
* commit '280c13a4bb103dd748ec304bfe0714a148c24602': Updating pom.xml version numbers for release 4.15.0.0 kvm: Fix double-escape issue while creating rbd disk options (apache#4568) networkorchestrator: Fix typo in exception message (apache#4559) checkstyle: fix pom version Updating pom.xml version numbers for release 4.15.1.0-SNAPSHOT Updating pom.xml version numbers for release 4.15.0.0 vmware: Fix for mapping guest OS type read from OVF to existing guest OS in C… (apache#4553) vmware: Fix template upload from local (apache#4555)
Description
This fix address the issue when CloudStack does reverse look up for guest OS type read from OVF to guest OS type in CloudStack during VMware template registration. After reading the OS type from OVF and while trying to map in CS, currently the first in the list of guest_os_hypervisor table with guest os name is picked and assigned to template. This cannot be true always as there are cases that multiple entries in guest_os_hypervisor table can be of different versions of same OS or it can also be different types of OS as well (in case of types like Other 32bit or otherGuest)
For example

"otherGuest" os name in OVF file can map to guest_os_id either to "85" or "60". But these two are completely different OS types and there chances that wrong guest OS is marked to template.
We are trying to fix the problem using the description field of the OS in OVF file and equals ignore match with display name in guest_os table. If description field is not present or if it does not match with any of guest os display names, then last in the list of guest_os_hypervisor table is picked so that latest version of that guest OS is assigned to the template.
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?
Tested registering a template with different types of OSes in OVF file.
- CS maps to single entry in guest_os_hypervisor table and OS type is assigned to "macOS 10.14 (64 bit)"
- CS maps to two entries in guest_os_hypervisor table, but based on description it assigned to "other 32-bit"
- CS maps to two entries in guest_os_hypervisor table but since no description is there CS maps to the latest guest os type which is "other 32-bit"
MariaDB [cloud]> select * from guest_os where id in (85,60) order by id DESC;
+----+-------------+------+--------------------------------------+------------------+---------------------+---------+-----------------+
| id | category_id | name | uuid | display_name | created | removed | is_user_defined |
+----+-------------+------+--------------------------------------+------------------+---------------------+---------+-----------------+
| 85 | 9 | NULL | 06bb4c79-1e50-11eb-bde5-1e005f013ade | SCO OpenServer 5 | 2020-11-04 03:44:52 | NULL | 0 |
| 60 | 7 | NULL | 06b43ca5-1e50-11eb-bde5-1e005f013ade | Other (32-bit) | 2020-11-04 03:44:52 | NULL | 0 |
+----+-------------+------+--------------------------------------+------------------+---------------------+---------+-----------------+