Comment 1 for bug 2023170

Revision history for this message
DUFOUR Olivier (odufourc) wrote : Re: OVN Charms should allow to specify internal repository for OVN packages with ovn-source option

After experimenting a lot with ovn-chassis and ovn-central. It appears it has a relation with charm-helpers.

The configuration option for "source", "openstack-origin" or "ovn-source" are relying from the function add_source from charmhelpers.
( https://github.com/juju/charm-helpers/blob/dc0dc74ac2debd328bd7846dbf1d2044563e255a/charmhelpers/fetch/ubuntu.py#L634 )
The main issue here is that adding a cloud repository, the charm will consequently create a file in /etc/apt/sources.list.d/ with either a file called "cloud-archive.list" or "cloud-archive-ovn.list".

But if adding a "deb http://myrepository/ubuntu focal-updates/ovn-22.03 main"
charmhelpers will use the command "add-apt-repository" which will edit instead /etc/apt/sources.list directly to create the entry.
( https://github.com/juju/charm-helpers/blob/dc0dc74ac2debd328bd7846dbf1d2044563e255a/charmhelpers/fetch/ubuntu.py#L757 )

This gets tricky with a new deployment on Focal with ovn-central and ovn-chassis being empty will lead to have automatically and implicitely "cloud:focal-ovn-22.03". And then changing to an internal repository will lead in having both the old entry in /etc/apt/sources.list.d/cloud-archive-ovn.list and the new entry /etc/apt/sources.list to be present at the same time.

This doesn't concern only "ovn-source" but also "source" or "openstack-origin" configuration option.
It has been observed that when using an URL type entry ("deb http://myrepository/ubuntu XXX"), the previous entry is never cleared and the new repository is simply added in /etc/apt/sources.list .
So for instance, when upgrading a cloud with :
"deb http://myrepository/ubuntu focal-updates/victoria main"
then
"deb http://myrepository/ubuntu focal-updates/wallaby main"
and then
"deb http://myrepository/ubuntu focal-updates/xena main"

"/etc/apt/sources.list" will contain 3 times the previous value of repository without being cleared and will continue to reference old versions of pockets.

At first glance, this looks like a limitation of the charm, where ideally, if using add-apt-repository, we should run add-apt-repository --remove "the previous entry", before adding the new repository/entry, but it looks difficult to retrieve the previous value of a config entry from a charm.

An idea would be to avoid using "add-apt-repository" command, and create manually the file as /etc/apt/sources.list.d/ with the same name like "/etc/apt/sources.list.d/cloud-archive(-ovn).list". That way, whenever there is an update, the previous entry is properly cleared and when moving between a cloud pocket and an internal repository there is no leftover of configuration.