juju / charm-helpers

Apache License 2.0
18 stars 127 forks source link

get_os_codename_package returns an empty object if your Ubuntu release does not have a package named "openstack-release" #907

Open jadonn opened 1 month ago

jadonn commented 1 month ago

I am cross-posting this bug from a bug report on the Ceilometer charm bug tracker. In that bug the user is running OpenStack on Focal and attempted an upgrade. The charm threw an exception in the CompareOpenStackReleases class, but the problem lies in the call to get_os_codename_package right before the call for CompareOpenStackReleases.

It looks to me that if you do not have a package called "openstack-release" available for your Ubuntu release that get_os_codename_package returns an empty object {} instead of failing. The package exists on Jammy, Mantic, Noble, and Oracular, but not Focal.

I think one problem lies in the openstack_release method on the CompareOpenStackReleases class passing on a FileNotFound exception. There should be a FileNotFound exception when the script attempts to access /etc/openstack-release since that file will not exist if there is no openstack-release package. There are also several fatal=False arguments that could have caused the lack of a package to break this flow sooner.

Overall, this particular bit of logic probably needs better safeguards for when there is not an openstack-release package available for your Ubuntu release.