Installation fails when files associated to package ubuntu-advantage-tools have local changes (e.g. juju managed files)

Bug #1962284 reported by Jose Guedez
This bug affects 1 person
Affects Status Importance Assigned to Milestone
In Progress
Jose Guedez

Bug Description

While replacing the `canonical-livepatch` charm for `ubuntu-advantage` the units hit errors, due to for example juju managed logrotate configurations.

Using current edge channel, code seems to match commit 5d93cdba18d77c1562c7e7542ac280bc47dfdb17

For example:

(initial install of canonical-livepatch, also with a logrotated subordinate)
juju remove-relation <app>:juju-info canonical-livepatch:juju-info # units are removed cleanly
juju add-relation <app>:juju-info ubuntu-advantage:juju-info

The new ubuntu-advantage/X unit enters ERROR state with this stacktrace:

2022-02-25 03:50:14 INFO unit.ubuntu-advantage/0.juju-log server.go:327 Installing package ubuntu-advantage-tools
2022-02-25 03:50:15 WARNING unit.ubuntu-advantage/0.config-changed logger.go:60 WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
2022-02-25 03:50:17 WARNING unit.ubuntu-advantage/0.config-changed logger.go:60 E: Sub-process /usr/bin/dpkg returned an error code (1)
2022-02-25 03:50:17 ERROR unit.ubuntu-advantage/0.juju-log server.go:327 Uncaught exception while in charm code:
Traceback (most recent call last):
  File "./src/", line 170, in <module>
  File "/var/lib/juju/agents/unit-ubuntu-advantage-0/charm/venv/ops/", line 402, in main
    _emit_charm_event(charm, dispatcher.event_name)
  File "/var/lib/juju/agents/unit-ubuntu-advantage-0/charm/venv/ops/", line 140, in _emit_charm_event
    event_to_emit.emit(*args, **kwargs)
  File "/var/lib/juju/agents/unit-ubuntu-advantage-0/charm/venv/ops/", line 278, in emit
  File "/var/lib/juju/agents/unit-ubuntu-advantage-0/charm/venv/ops/", line 722, in _emit
  File "/var/lib/juju/agents/unit-ubuntu-advantage-0/charm/venv/ops/", line 767, in _reemit
  File "./src/", line 89, in config_changed
  File "./src/", line 121, in _handle_package_state
  File "./src/", line 34, in install_package
    subprocess.check_call(["apt", "install", "--yes", "--quiet", package])
  File "/usr/lib/python3.8/", line 364, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['apt', 'install', '--yes', '--quiet', 'ubuntu-advantage-tools']' returned non-zero exit status 100.

Running the command manually shows the actual error which is that file `/etc/logrotate.d/ubuntu-advantage-tools` has been modified by juju. Perhaps it would be convenient to install the package with `-o Dpkg::Options::="--force-confold"` to preserve the juju changes.

root@prometheus-3:~# apt install ubuntu-advantage-tools
Reading package lists... Done
Building dependency tree
Reading state information... Done
ubuntu-advantage-tools is already the newest version (27.6~20.04.1).
0 upgraded, 0 newly installed, 0 to remove and 45 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n]
Setting up ubuntu-advantage-tools (27.6~20.04.1) ...

Configuration file '/etc/logrotate.d/ubuntu-advantage-tools'
 ==> Modified (by you or by a script) since installation.
 ==> Package distributor has shipped an updated version.
   What would you like to do about it ? Your options are:
    Y or I : install the package maintainer's version
    N or O : keep your currently-installed version
      D : show the differences between the versions
      Z : start a shell to examine the situation
 The default action is to keep your current version.
*** ubuntu-advantage-tools (Y/I/N/O/D/Z) [default=N] ? D
--- /etc/logrotate.d/ubuntu-advantage-tools 2022-02-25 03:17:03.798595388 +0000
+++ /etc/logrotate.d/ubuntu-advantage-tools.dpkg-new 2022-01-20 21:02:27.000000000 +0000
@@ -1,6 +1,8 @@
-# Configuration file maintained by Juju. Local changes may be overwritten
-/var/log/ubuntu-advantage.log {
- rotate 1
+# use the root group by default, since this is the owning group
+# of /var/log/ubuntu-advantage*.log files.
+/var/log/ubuntu-advantage*.log {
+ su root root
+ rotate 6

Related branches

Jose Guedez (jfguedez)
summary: - Installation fails when files associated to package ubuntu-advantage
- tools have local changes
+ Installation fails when files associated to package ubuntu-advantage-
+ tools have local changes (e.g. juju managed files)
Jose Guedez (jfguedez)
Changed in charm-ubuntu-advantage:
assignee: nobody → Jose Guedez (jfguedez)
status: New → In Progress
Revision history for this message
Tom Haddon (mthaddon) wrote :

I've released revision 17 to the edge channel which should address this. Please give it a try and confirm, once we've done that we can promote that release to the stable channel.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.