Copilot commented on code in PR #14493:
URL: https://github.com/apache/cloudstack/pull/14493#discussion_r4483848537


##########
engine/schema/src/main/resources/META-INF/db/schema-42300to2400.sql:
##########
@@ -239,3 +239,21 @@ CREATE TABLE IF NOT EXISTS 
`cloud`.`instance_boot_group_details` (
     PRIMARY KEY (`id`),
     CONSTRAINT `fk_instance_boot_group_details__group_id` FOREIGN KEY 
(`boot_group_id`) REFERENCES `instance_boot_group` (`id`) ON DELETE CASCADE
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+
+-- Set the guest OS of the built-in Debian 13 templates to 'Debian GNU/Linux 
12 (64-bit)', which is only added by later upgrade scripts and is not available 
in templates.sql
+UPDATE `cloud`.`vm_template` SET `guest_os_id` = (SELECT `id` FROM 
`cloud`.`guest_os` WHERE `display_name` = 'Debian GNU/Linux 12 (64-bit)' AND 
`removed` IS NULL LIMIT 1)
+    WHERE `id` = 4 AND `unique_name` = 'debian13-x86_64-kvm' AND `type` = 
'BUILTIN';
+UPDATE `cloud`.`vm_template` SET `guest_os_id` = (SELECT `id` FROM 
`cloud`.`guest_os` WHERE `display_name` = 'Debian GNU/Linux 12 (64-bit)' AND 
`removed` IS NULL LIMIT 1)
+    WHERE `id` = 5 AND `unique_name` = 'debian13-x86_64-xen' AND `type` = 
'BUILTIN';
+UPDATE `cloud`.`vm_template` SET `guest_os_id` = (SELECT `id` FROM 
`cloud`.`guest_os` WHERE `display_name` = 'Debian GNU/Linux 12 (64-bit)' AND 
`removed` IS NULL LIMIT 1)
+    WHERE `id` = 7 AND `unique_name` = 'debian13-x86_64-vmware' AND `type` = 
'BUILTIN';

Review Comment:
   These UPDATEs will set `guest_os_id` to NULL if the subquery returns no row 
(which is plausible given the comment that the OS is only added by later 
upgrade scripts). To avoid corrupting the templates, guard the UPDATE with an 
EXISTS check (or join) so the UPDATE only runs when the target guest OS row 
exists.



##########
setup/db/templates.sql:
##########
@@ -34,16 +34,16 @@ INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, 
name, public, created,
     VALUES (2, UUID(), 'centos53-x86_64', 'CentOS 5.3(64-bit) no GUI 
(XenServer)', 1, now(), now(), 'BUILTIN', 0, 64, 1, 
'http://download.cloudstack.org/templates/builtin/f59f18fb-ae94-4f97-afd2-f84755767aca.vhd.bz2',
 'b63d854a9560c013142567bbae8d98cf', 0, 'CentOS 5.3(64-bit) no GUI 
(XenServer)', 'VHD', 12, 1, 1, 'XenServer', 1);
 
 INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, 
created, type, hvm, bits, account_id, url, checksum, display_text, 
enable_password, format, guest_os_id, featured, cross_zones, hypervisor_type, 
extractable)
-    VALUES (4, UUID(), 'centos55-x86_64', 'CentOS 5.5(64-bit) no GUI (KVM)', 
1, now(), 'BUILTIN', 0, 64, 1, 
'http://download.cloudstack.org/releases/2.2.0/eec2209b-9875-3c8d-92be-c001bd8a0faf.qcow2.bz2',
 'ed0e788280ff2912ea40f7f91ca7a249', 'CentOS 5.5(64-bit) no GUI (KVM)', 0, 
'QCOW2', 112, 1, 1, 'KVM', 1);
+    VALUES (4, UUID(), 'debian13-x86_64-kvm', 'Debian 13 (64-bit) genericcloud 
(KVM)', 1, now(), 'BUILTIN', 0, 64, 1, 
'http://10.0.34.8/templates/debian-13-genericcloud-amd64/debian-13-genericcloud-amd64-20261026-2643-acs.qcow2',
 
'{SHA-512}bd95d28cc1e42e2f9d54c16c1015fee0204677dc6122c9a10bec8aaf0b3730b426f47e1c50e046f21add95f917344fe07089d791eb996fbd996257879022aafe',
 'Debian 13 (64-bit) genericcloud (KVM)', 0, 'QCOW2', 184, 1, 1, 'KVM', 1);
 
 INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, 
created, type, hvm, bits, account_id, url, checksum, enable_password, 
display_text,  format, guest_os_id, featured, cross_zones, hypervisor_type, 
extractable)
-    VALUES (5, UUID(), 'centos56-x86_64-xen', 'CentOS 5.6(64-bit) no GUI 
(XenServer)', 1, now(), 'BUILTIN', 0, 64, 1, 
'http://download.cloudstack.org/templates/builtin/centos56-x86_64.vhd.bz2', 
'905cec879afd9c9d22ecc8036131a180', 0, 'CentOS 5.6(64-bit) no GUI (XenServer)', 
'VHD', 142, 1, 1, 'XenServer', 1);
+    VALUES (5, UUID(), 'debian13-x86_64-xen', 'Debian 13 (64-bit) genericcloud 
(XenServer)', 1, now(), 'BUILTIN', 0, 64, 1, 
'http://10.0.34.8/templates/debian-13-genericcloud-amd64/debian-13-genericcloud-amd64-20261026-2643-acs-xen.vhd.bz2',
 
'{SHA-512}1126134bdec1db47a34a0ca320b2f7d51e3d2fd2f7c3194ed855e592a3c92a7327edeafe8e8f05a1f2faac8a586d76d38c4003a669a7f28bda891c54261ad94c',
 0, 'Debian 13 (64-bit) genericcloud (XenServer)', 'VHD', 184, 1, 1, 
'XenServer', 1);
 
 INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, 
created, type, hvm, bits, account_id, url, checksum, enable_password, 
display_text,  format, guest_os_id, featured, cross_zones, hypervisor_type, 
extractable)
     VALUES (6, UUID(), 'centos64-x64', 'CentOS 6.4(64-bit) GUI (Hyperv)', 1, 
now(), 'BUILTIN', 0, 64, 1, 
'http://download.cloudstack.org/releases/4.3/centos6_4_64bit.vhd.bz2', 
'eef6b9940ea3ed01221d963d4a012d0a', 0, 'CentOS 6.4 (64-bit) GUI (Hyperv)', 
'VHD', 182, 1, 1, 'Hyperv', 1);
 
 INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, 
created, type, hvm, bits, account_id, url, checksum, enable_password, 
display_text,  format, guest_os_id, featured, cross_zones, hypervisor_type, 
extractable)
-    VALUES (7, UUID(), 'centos53-x64', 'CentOS 5.3(64-bit) no GUI (vSphere)', 
1, now(), 'BUILTIN', 0, 64, 1, 
'http://download.cloudstack.org/releases/2.2.0/CentOS5.3-x86_64.ova', 
'f6f881b7f2292948d8494db837fe0f47', 0, 'CentOS 5.3(64-bit) no GUI (vSphere)', 
'OVA', 12, 1, 1, 'VMware', 1);
+    VALUES (7, UUID(), 'debian13-x86_64-vmware', 'Debian 13 (64-bit) 
genericcloud (vSphere)', 1, now(), 'BUILTIN', 0, 64, 1, 
'http://10.0.34.8/templates/debian-13-genericcloud-amd64/debian-13-genericcloud-amd64-20261026-2643-acs.ova',
 
'{SHA-512}01500faa467c718561624ae697d1866476792c265714d2a742ae0ffba39108c8f245897d3eba6623ef3cecbf410fae490ee47f41b4b1a237eb586f4a79e5c165',
 0, 'Debian 13 (64-bit) genericcloud (vSphere)', 'OVA', 184, 1, 1, 'VMware', 1);

Review Comment:
   These built-in template URLs point to a private RFC1918 address (10.0.34.8), 
but the PR description says the templates are downloaded from 
download.cloudstack.org. Built-in templates should be publicly reachable for 
typical deployments; please switch these URLs to the intended public host 
(e.g., download.cloudstack.org) or update the PR description if the private 
host is intentional (which would be problematic for upstream).



##########
setup/db/templates.sql:
##########
@@ -34,16 +34,16 @@ INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, 
name, public, created,
     VALUES (2, UUID(), 'centos53-x86_64', 'CentOS 5.3(64-bit) no GUI 
(XenServer)', 1, now(), now(), 'BUILTIN', 0, 64, 1, 
'http://download.cloudstack.org/templates/builtin/f59f18fb-ae94-4f97-afd2-f84755767aca.vhd.bz2',
 'b63d854a9560c013142567bbae8d98cf', 0, 'CentOS 5.3(64-bit) no GUI 
(XenServer)', 'VHD', 12, 1, 1, 'XenServer', 1);
 
 INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, 
created, type, hvm, bits, account_id, url, checksum, display_text, 
enable_password, format, guest_os_id, featured, cross_zones, hypervisor_type, 
extractable)
-    VALUES (4, UUID(), 'centos55-x86_64', 'CentOS 5.5(64-bit) no GUI (KVM)', 
1, now(), 'BUILTIN', 0, 64, 1, 
'http://download.cloudstack.org/releases/2.2.0/eec2209b-9875-3c8d-92be-c001bd8a0faf.qcow2.bz2',
 'ed0e788280ff2912ea40f7f91ca7a249', 'CentOS 5.5(64-bit) no GUI (KVM)', 0, 
'QCOW2', 112, 1, 1, 'KVM', 1);
+    VALUES (4, UUID(), 'debian13-x86_64-kvm', 'Debian 13 (64-bit) genericcloud 
(KVM)', 1, now(), 'BUILTIN', 0, 64, 1, 
'http://10.0.34.8/templates/debian-13-genericcloud-amd64/debian-13-genericcloud-amd64-20261026-2643-acs.qcow2',
 
'{SHA-512}bd95d28cc1e42e2f9d54c16c1015fee0204677dc6122c9a10bec8aaf0b3730b426f47e1c50e046f21add95f917344fe07089d791eb996fbd996257879022aafe',
 'Debian 13 (64-bit) genericcloud (KVM)', 0, 'QCOW2', 184, 1, 1, 'KVM', 1);
 
 INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, 
created, type, hvm, bits, account_id, url, checksum, enable_password, 
display_text,  format, guest_os_id, featured, cross_zones, hypervisor_type, 
extractable)
-    VALUES (5, UUID(), 'centos56-x86_64-xen', 'CentOS 5.6(64-bit) no GUI 
(XenServer)', 1, now(), 'BUILTIN', 0, 64, 1, 
'http://download.cloudstack.org/templates/builtin/centos56-x86_64.vhd.bz2', 
'905cec879afd9c9d22ecc8036131a180', 0, 'CentOS 5.6(64-bit) no GUI (XenServer)', 
'VHD', 142, 1, 1, 'XenServer', 1);
+    VALUES (5, UUID(), 'debian13-x86_64-xen', 'Debian 13 (64-bit) genericcloud 
(XenServer)', 1, now(), 'BUILTIN', 0, 64, 1, 
'http://10.0.34.8/templates/debian-13-genericcloud-amd64/debian-13-genericcloud-amd64-20261026-2643-acs-xen.vhd.bz2',
 
'{SHA-512}1126134bdec1db47a34a0ca320b2f7d51e3d2fd2f7c3194ed855e592a3c92a7327edeafe8e8f05a1f2faac8a586d76d38c4003a669a7f28bda891c54261ad94c',
 0, 'Debian 13 (64-bit) genericcloud (XenServer)', 'VHD', 184, 1, 1, 
'XenServer', 1);

Review Comment:
   These built-in template URLs point to a private RFC1918 address (10.0.34.8), 
but the PR description says the templates are downloaded from 
download.cloudstack.org. Built-in templates should be publicly reachable for 
typical deployments; please switch these URLs to the intended public host 
(e.g., download.cloudstack.org) or update the PR description if the private 
host is intentional (which would be problematic for upstream).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to