Skip to content

Fix Ubuntu/Debian package installation#13207

Draft
vishesh92 wants to merge 3 commits into
apache:mainfrom
shapeblue:fix-ubuntu-package-installation
Draft

Fix Ubuntu/Debian package installation#13207
vishesh92 wants to merge 3 commits into
apache:mainfrom
shapeblue:fix-ubuntu-package-installation

Conversation

@vishesh92

@vishesh92 vishesh92 commented May 21, 2026

Copy link
Copy Markdown
Member

Description

This PR fixes package installation errors on Ubuntu and debian

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)
  • Build/CI
  • Test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

How did you try to break this feature and the system with this change?

@vishesh92

Copy link
Copy Markdown
Member Author

@blueorangutan package

@vishesh92 vishesh92 added this to the 4.23.0 milestone May 21, 2026
@blueorangutan

Copy link
Copy Markdown

@vishesh92 a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress.

Copilot AI 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.

Pull request overview

This PR updates the Debian/Ubuntu cloudstack-common post-install script to use Python 3 byte-compilation tooling during package installation, aiming to resolve install-time failures related to Python compilation steps.

Changes:

  • Replace pycompile invocations with py3compile in debian/cloudstack-common.postinst.
  • Keep post-install Python module copying and explicit python3 -m py_compile/compileall steps intact.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread debian/cloudstack-common.postinst Outdated
Comment thread debian/cloudstack-common.postinst Outdated
@codecov

codecov Bot commented May 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 19.50%. Comparing base (1fe486f) to head (6df61c2).
⚠️ Report is 164 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main   #13207      +/-   ##
============================================
+ Coverage     18.09%   19.50%   +1.40%     
- Complexity    16732    19444    +2712     
============================================
  Files          6037     6303     +266     
  Lines        542780   569288   +26508     
  Branches      66464    69792    +3328     
============================================
+ Hits          98233   111040   +12807     
- Misses       433499   446094   +12595     
- Partials      11048    12154    +1106     
Flag Coverage Δ
uitests 3.41% <ø> (-0.11%) ⬇️
unittests 20.77% <ø> (+1.51%) ⬆️

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

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@blueorangutan

Copy link
Copy Markdown

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

@weizhouapache

Copy link
Copy Markdown
Member

@blueorangutan test debian12 kvm-debian12

@blueorangutan

Copy link
Copy Markdown

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

@blueorangutan

Copy link
Copy Markdown

[SF] Trillian Build Failed (tid-16140)

@vishesh92

Copy link
Copy Markdown
Member Author

@blueorangutan package

Copilot AI 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.

Pull request overview

Copilot reviewed 20 out of 20 changed files in this pull request and generated 11 comments.

Comments suppressed due to low confidence (1)

scripts/storage/secondary/cloud-install-sys-tmplt.py:176

  • file(...) is not defined in Python 3, so these calls will raise NameError at runtime. Replace with open(..., 'wb') (and consider using context managers) for decompression output and template.properties writes.
  def uncompressFile(self, fileName):
    print('Uncompressing the file %s... which could take a long time, please wait' % self.systemvmtemplatepath)
    if self.fileextension == 'gz':
      compressedFile = gzip.GzipFile(self.systemvmtemplatepath, 'rb')
      decompressedData = compressedFile.read()
      compressedFile.close()
      decompressedFile = file(fileName, 'wb')
      decompressedFile.write(decompressedData)
      decompressedFile.close()

Comment thread debian/cloudstack-common.postinst Outdated
Comment on lines 28 to 31
if which py3compile >/dev/null 2>&1; then
py3compile -p cloudstack-common /usr/share/cloudstack-common
fi

if self.args.templatesuffix:
self.templatesuffix = self.args.templatesuffix
print 'Password for DB: %s'%self.databaseuserpassword
print('Password for DB: %s'%self.databaseuserpassword)
Comment on lines 110 to 127
def runCmd(self, cmds):
process = subprocess.Popen(' '.join(cmds), shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = process.communicate()
print(stdout)
if process.returncode != 0:
raise Exception(stderr)
return stdout

def runMysql(self, query):
try:
print 'Running Query: %s' % query
print('Running Query: %s' % query)
mysqlCmds = ['mysql', '--user=%s'%self.databaseusername, '--host=%s'%self.databasehostname, '--password=%s'%self.databaseuserpassword, '--skip-column-names', '-U', 'cloud', '-e "%s"'%query]
templateId = self.runCmd(mysqlCmds)
print 'TemplateId is : %s' % templateId
except Exception, e:
print('TemplateId is : %s' % templateId)
except Exception as e:
err = '''Encountering an error when executing mysql script\n%s''' % str(e)
self.errorAndExit(err)
return templateId
Comment on lines 119 to +123
try:
print 'Running Query: %s' % query
print('Running Query: %s' % query)
mysqlCmds = ['mysql', '--user=%s'%self.databaseusername, '--host=%s'%self.databasehostname, '--password=%s'%self.databaseuserpassword, '--skip-column-names', '-U', 'cloud', '-e "%s"'%query]
templateId = self.runCmd(mysqlCmds)
print 'TemplateId is : %s' % templateId
except Exception, e:
print('TemplateId is : %s' % templateId)
modfile = "%s/%s.py" % (modpath, cs.getName().lower())
me = os.path.abspath(__file__)
if os.path.isfile(modfile):
if hashlib.md5(open(me).read()).hexdigest() != hashlib.md5(open(modfile).read()).hexdigest():
sys.exit(2)
params = {}
pos = 0;
for i in range(len(paramList) / 2):
Comment on lines 594 to 595
if val in ["10", "100", "1000"]:
settings += ['duplex', 'val']
network_conf.close()
except Exception, e:
except Exception as e:
raise Error("failed to determine network backend:" + e)
if len(sys.argv) < 4:
print "Usage: prepare_kickstart_kerneal_initrd.py path_to_kernel path_to_initrd path_kernel_initrd_copy_to"
sys.exit(1)
print("Usage: prepare_kickstart_kerneal_initrd.py path_to_kernel path_to_initrd path_kernel_initrd_copy_to")

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.

😄

if __name__ == "__main__":
if len(sys.argv) < 12:
print "Usage: prepare_tftp_bootfile.py tftp_dir mac cifs_server share directory image_to_restor cifs_username cifs_password ip netmask gateway"
print("Usage: prepare_tftp_bootfile.py tftp_dir mac cifs_server share directory image_to_restor cifs_username cifs_password ip netmask gateway")

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.

😆

@weizhouapache weizhouapache left a comment

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.

code lgtm

if len(sys.argv) < 4:
print "Usage: prepare_kickstart_kerneal_initrd.py path_to_kernel path_to_initrd path_kernel_initrd_copy_to"
sys.exit(1)
print("Usage: prepare_kickstart_kerneal_initrd.py path_to_kernel path_to_initrd path_kernel_initrd_copy_to")

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.

😄

if __name__ == "__main__":
if len(sys.argv) < 12:
print "Usage: prepare_tftp_bootfile.py tftp_dir mac cifs_server share directory image_to_restor cifs_username cifs_password ip netmask gateway"
print("Usage: prepare_tftp_bootfile.py tftp_dir mac cifs_server share directory image_to_restor cifs_username cifs_password ip netmask gateway")

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.

😆

@daviftorres

Copy link
Copy Markdown
Contributor

Dear @vishesh92, just for clarification. The title says Ubuntu and the description says Debian. Which ones is this fix for? Or is it for the Debian-based, that includes Ubuntu?

@vishesh92

Copy link
Copy Markdown
Member Author

Dear @vishesh92, just for clarification. The title says Ubuntu and the description says Debian. Which ones is this fix for? Or is it for the Debian-based, that includes Ubuntu?

The packages are same for both Ubuntu and Debian.

@vishesh92 vishesh92 changed the title Fix Ubuntu package installation Fix Ubuntu/Debian package installation May 27, 2026
@weizhouapache

Copy link
Copy Markdown
Member

@vishesh92
is this ready for review and testing ?

@vishesh92

Copy link
Copy Markdown
Member Author

@vishesh92 is this ready for review and testing ?

I couldn't confirm if some of the scripts works as expected before and after changes. Should we rely on just BO for this?

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@vishesh92 a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

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

@blueorangutan

Copy link
Copy Markdown

[SF] Trillian Build Failed (tid-16503)

@weizhouapache

Copy link
Copy Markdown
Member

@blueorangutan test ubuntu24 xenserver-84

@blueorangutan

Copy link
Copy Markdown

@weizhouapache a [SL] Trillian-Jenkins test job (ubuntu24 mgmt + xenserver-84) has been kicked to run smoke tests

@blueorangutan

Copy link
Copy Markdown

[SF] Trillian test result (tid-16504)
Environment: xenserver-84 (x2), zone: Advanced Networking with Mgmt server u24
Total time taken: 65629 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr13207-t16504-xenserver-84.zip
Smoke tests completed. 144 look OK, 9 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File
test_01_events_resource Error 166.08 test_events_resource.py
test_12_deploy_vm_with_root_disk_encryption Error 21.87 test_kms_lifecycle.py
test_01_non_strict_host_anti_affinity Error 142.87 test_nonstrict_affinity_group.py
test_02_non_strict_host_affinity Error 82.53 test_nonstrict_affinity_group.py
test_05_disk_offering_strictness_true Failure 621.46 test_service_offerings.py
test_06_disk_offering_strictness_false Failure 636.62 test_service_offerings.py
test_02_list_snapshots_with_removed_data_store Error 11.49 test_snapshots.py
test_02_list_snapshots_with_removed_data_store Error 11.49 test_snapshots.py
test_01_volume_usage Failure 88.47 test_usage.py
test_01_vpn_usage Error 1.13 test_usage.py
test_06_autoscaling_vmgroup_on_project_network Failure 363.15 test_vm_autoscaling.py
test_06_autoscaling_vmgroup_on_project_network Error 363.16 test_vm_autoscaling.py
ContextSuite context=TestVmAutoScaling>:teardown Error 736.59 test_vm_autoscaling.py
test_11_destroy_vm_and_volumes Error 18.32 test_vm_life_cycle.py
test_01_migrate_vm_strict_tags_success Error 72.96 test_vm_strict_host_tags.py

@weizhouapache weizhouapache modified the milestones: 4.23.0, 4.24.0 Jul 10, 2026
@weizhouapache

Copy link
Copy Markdown
Member

@blueorangutan test ubuntu22 kvm-ubuntu22

@blueorangutan

Copy link
Copy Markdown

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

@weizhouapache weizhouapache modified the milestones: 4.24.0, 4.23.0 Jul 12, 2026
@blueorangutan

Copy link
Copy Markdown

[SF] Trillian test result (tid-16540)
Environment: kvm-ubuntu22 (x2), zone: Advanced Networking with Mgmt server u22
Total time taken: 57163 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr13207-t16540-kvm-ubuntu22.zip
Smoke tests completed. 153 look OK, 0 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File

@weizhouapache

Copy link
Copy Markdown
Member

@vishesh92
can you address the review comments ? I think this is required for 4.23

@weizhouapache

Copy link
Copy Markdown
Member

this fixes the issues with cloudstack installation on ubuntu 22

Setting up libiscsi7:amd64 (1.19.0-3build2) ...
Setting up qemu-block-extra (1:6.2+dfsg-2ubuntu6.31) ...
Created symlink /etc/systemd/system/multi-user.target.wants/run-qemu.mount -> /lib/systemd/system/run-qemu.mount.
Setting up libc-devtools (2.35-0ubuntu3.13) ...
Setting up cloudstack-common (4.23.0.0-shapeblue19506~xenial) ...
<string>:1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
<string>:1: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
  File "/usr/share/cloudstack-common/scripts/vm/hypervisor/kvm/imageserver/backends/__init__.py", line 27
    def create_backend(cfg: Dict[str, Any]) -> ImageBackend:
                          ^
SyntaxError: invalid syntax

  File "/usr/share/cloudstack-common/scripts/vm/hypervisor/kvm/imageserver/backends/base.py", line 29
    def size(self) -> int:
                   ^
SyntaxError: invalid syntax

  File "/usr/share/cloudstack-common/scripts/vm/hypervisor/kvm/imageserver/backends/file.py", line 32
    def __init__(self, path: str):
                           ^
SyntaxError: invalid syntax

  File "/usr/share/cloudstack-common/scripts/vm/hypervisor/kvm/imageserver/backends/nbd.py", line 43
    socket_path: str,
               ^
SyntaxError: invalid syntax

  File "/usr/share/cloudstack-common/scripts/vm/hypervisor/kvm/imageserver/server.py", line 50
    registry: TransferRegistry,
            ^
SyntaxError: invalid syntax

  File "/usr/share/cloudstack-common/scripts/vm/hypervisor/kvm/imageserver/util.py", line 24
    extents: List[Dict[str, Any]],
           ^
SyntaxError: invalid syntax

  File "/usr/share/cloudstack-common/scripts/vm/hypervisor/kvm/imageserver/tests/test_http11_lifecycle.py", line 34
    def _read_http_headers(sock: socket.socket, timeout: float = HTTP_TIMEOUT) -> bytes:
                               ^
SyntaxError: invalid syntax

  File "/usr/share/cloudstack-common/scripts/vm/hypervisor/kvm/imageserver/tests/test_stress_io.py", line 55
    def _qemu_img_virtual_size(path: str) -> int:
                                   ^
SyntaxError: invalid syntax

  File "/usr/share/cloudstack-common/scripts/vm/hypervisor/kvm/imageserver/tests/test_nbd_backend.py", line 105
    self.assertEqual(resp.getheader("Content-Range"), f"bytes 0-99/{IMAGE_SIZE}")
                                                                               ^
SyntaxError: invalid syntax

  File "/usr/share/cloudstack-common/scripts/vm/hypervisor/kvm/imageserver/tests/test_base.py", line 89
    _tmp_dir: Optional[str] = None
            ^
SyntaxError: invalid syntax

  File "/usr/share/cloudstack-common/scripts/vm/hypervisor/kvm/imageserver/tests/test_combinations.py", line 71
    _fetch, url, headers={"Range": f"bytes={start}-{end}"}
                                                        ^
SyntaxError: invalid syntax

  File "/usr/share/cloudstack-common/scripts/vm/hypervisor/kvm/imageserver/tests/test_control_socket.py", line 44
    tid = f"test-{uuid.uuid4().hex[:8]}"
                                       ^
SyntaxError: invalid syntax

  File "/usr/share/cloudstack-common/scripts/vm/hypervisor/kvm/imageserver/tests/test_file_backend.py", line 100
    self.assertEqual(resp.getheader("Content-Range"), f"bytes 0-99/{size}")
                                                                         ^
SyntaxError: invalid syntax

  File "/usr/share/cloudstack-common/scripts/vm/hypervisor/kvm/imageserver/handler.py", line 47
    _registry: TransferRegistry
             ^
SyntaxError: invalid syntax

  File "/usr/share/cloudstack-common/scripts/vm/hypervisor/kvm/imageserver/config.py", line 28
    def parse_idle_timeout_seconds(obj: dict) -> int:
                                      ^
SyntaxError: invalid syntax

  File "/usr/share/cloudstack-common/scripts/vm/network/security_group.py", line 164
    logging.warning(f"Could not parse one of the IP addresses in the list {ips}: {str(e)}")
                                                                                         ^
SyntaxError: invalid syntax

dpkg: error processing package cloudstack-common (--configure):
 installed cloudstack-common package post-installation script subprocess returned error exit status 101
Setting up g++-11 (11.4.0-1ubuntu1~22.04.3) ...
dpkg: dependency problems prevent configuration of cloudstack-management:
 cloudstack-management depends on cloudstack-common (= 4.23.0.0-shapeblue19506~xenial); however:
  Package cloudstack-common is not configured yet.

dpkg: error processing package cloudstack-management (--configure):
 dependency problems - leaving unconfigured
Setting up libpython3.10-dev:amd64 (3.10.12-1~22.04.16) ...

@blueorangutan

Copy link
Copy Markdown

[SF] Trillian Build Failed (tid-16545)

@blueorangutan

Copy link
Copy Markdown

[SF] Trillian Build Failed (tid-16546)

Copilot AI review requested due to automatic review settings July 13, 2026 13:34

Copilot AI 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.

Pull request overview

Copilot reviewed 22 out of 22 changed files in this pull request and generated 12 comments.

print ("Copying new private key file as it is not matching with old file")
shutil.copyfile(newKey, currDir + pathSep + "id_rsa.cloud")
os.chmod(currDir + pathSep + "id_rsa.cloud", 0644)
os.chmod(currDir + pathSep + "id_rsa.cloud", 0o644)
import os, re, sys
import xml.dom.minidom
import xmlrpclib
import xmlrpc.client
util.SMlog("scanning2 (target=%s)" % target)
dom = nfs.scan_exports(target)
print >>sys.stderr,dom.toprettyxml()
print(dom.toprettyxml(), file=sys.stderr)
util.SMlog("scanning2 (target=%s)" % target)
dom = nfs.scan_exports(target)
print >>sys.stderr,dom.toprettyxml()
print(dom.toprettyxml(), file=sys.stderr)
util.SMlog("scanning2 (target=%s)" % target)
dom = nfs.scan_exports(target)
print >>sys.stderr,dom.toprettyxml()
print(dom.toprettyxml(), file=sys.stderr)
util.SMlog("scanning2 (target=%s)" % target)
dom = nfs.scan_exports(target)
print >>sys.stderr,dom.toprettyxml()
print(dom.toprettyxml(), file=sys.stderr)
syslog.syslog(s)
else:
print >>sys.stderr, s
print(s, file=sys.stderr)
Comment on lines 516 to +517
def get_pif_by_uuid(self, uuid):
pifs = map(lambda (ref,rec): ref,
filter(lambda (ref,rec): uuid == rec['uuid'],
self.__pifs.items()))
pifs = [ref_rec3[0] for ref_rec3 in [ref_rec for ref_rec in list(self.__pifs.items()) if uuid == ref_rec[1]['uuid']]]
Comment on lines 525 to +529
def get_pifs_by_device(self, device):
return map(lambda (ref,rec): ref,
filter(lambda (ref,rec): rec['device'] == device,
self.__pifs.items()))
return [ref_rec4[0] for ref_rec4 in [ref_rec1 for ref_rec1 in list(self.__pifs.items()) if ref_rec1[1]['device'] == device]]

def get_pif_by_bridge(self, bridge):
networks = map(lambda (ref,rec): ref,
filter(lambda (ref,rec): rec['bridge'] == bridge,
self.__networks.items()))
networks = [ref_rec5[0] for ref_rec5 in [ref_rec2 for ref_rec2 in list(self.__networks.items()) if ref_rec2[1]['bridge'] == bridge]]

from xen.util.xmlrpcclient import ServerProxy
from xmlrpclib import Error
from xmlrpc.client import Error
@weizhouapache

Copy link
Copy Markdown
Member

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@weizhouapache a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

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

@weizhouapache

Copy link
Copy Markdown
Member

@blueorangutan test ubuntu24 xcpng82

@blueorangutan

Copy link
Copy Markdown

@weizhouapache a [SL] Trillian-Jenkins test job (ubuntu24 mgmt + xcpng82) has been kicked to run smoke tests

@weizhouapache

Copy link
Copy Markdown
Member

@vishesh92
I think it is expected that some xenserver scripts are working with python2
#10684 has added some python3-compatible scripts for xcp/xenserver 8.3/8.4

I think we do not need to update the xen/xcpng scripts, what do you think ?

@weizhouapache weizhouapache modified the milestones: 4.23.0, 4.24.0 Jul 14, 2026
@weizhouapache

Copy link
Copy Markdown
Member

discussed with @vishesh92
moving this to 4.24.0, let's focus on #13602 for 4.23.0

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

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.

5 participants