Broken bash completion with old ppa packages present

Bug #1600257 reported by Matt Bruzek
20
This bug affects 3 people
Affects Status Importance Assigned to Milestone
juju-core
Invalid
High
Unassigned
juju-core (Ubuntu)
Fix Released
Undecided
Unassigned
Xenial
Fix Released
Undecided
Unassigned

Bug Description

I am using juju 2.0-beta11-xenial-amd64 and when I tried to tab complete an application name, I got a Traceback with a KeyError. I was trying to tab-complete "kubernetes" an application that is deployed by juju.

$ juju ssh kuberTraceback (most recent call last):
  File "<string>", line 5, in <module>
KeyError: 'services'

We renamed 'services' to 'application' in 2.0 and I suspect something is not up to date. This also looks like a Python Traceback. If someone can tell me where the python code is I can take a shot at fixing this problem.

Revision history for this message
Matt Bruzek (mbruzek) wrote :

The bash completion file is in etc/bash_completion.d/juju-2.0 and the file currently in github has no references to "services".

The files on my system however, do have references to "services": http://pastebin.ubuntu.com/18798379/

I would propose this is a packaging problem because I was told that beta11 should have included updating the bash_completion.d files.

Revision history for this message
Matt Bruzek (mbruzek) wrote :

OK after some research I see the packaging file changed the name and where it copies the completion files.

http://bazaar.launchpad.net/~juju-qa/juju-release-tools/packaging-juju2-default/changes?filter_file_id=rules-20130424225108-69i3ibg07hkw7keh-960

Since I installed every beta from the ppa it looks like my system has some left over files: juju2, juju-core, and juju-core2

mbruzek@warhorse:/etc/bash_completion.d$ diff juju2 juju-core
0a1
> #!/bin/bash
mbruzek@warhorse:/etc/bash_completion.d$ diff juju-core juju-core2
mbruzek@warhorse:/etc/bash_completion.d$ ls -al *juju*
-rw-r--r-- 1 root root 5122 Mar 24 14:04 juju2
-rw-r--r-- 1 root root 5134 Feb 10 12:41 juju-core
-rw-r--r-- 1 root root 5134 Feb 19 18:01 juju-core2
mbruzek@warhorse:/etc/bash_completion.d$

These files were favored over the juju-2.0 and juju-version files in /usr/share/bash-completion/completions/ directory.
mbruzek@warhorse:/usr/share/bash-completion/completions$ ls -al *juju*
-rw-r--r-- 1 root root 12705 Jul 1 12:21 juju-2.0
-rw-r--r-- 1 root root 604 Jul 1 12:21 juju-version

The .bashrc file is pretty stock concerning completions (I have not edited that part):
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
  if [ -f /usr/share/bash-completion/bash_completion ]; then
    . /usr/share/bash-completion/bash_completion
  elif [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
  fi
fi

The file /usr/share/bash-completion/bash_completion does exist and is a long shell script that presumably handles completions out of /usr/share/bash-completion/completions/ directory. So I don't know why it seems my system is favoring files in /etc/bash_completion.d/ directory.

Matt Bruzek (mbruzek)
summary: - The tab completion on juju yeilds KeyError: 'services'
+ The tab completion on juju yields KeyError: 'services'
Revision history for this message
Martin Packman (gz) wrote : Re: The tab completion on juju yields KeyError: 'services'

Part of the issue here is having a mix of ppa packages and archive packages leads to a bunch of bash completion files on disk that may not correspond to the correct version of juju. We should make our conflicts/replaces robust on the ppa and archive packages so users can't have old ppa versions lying around confusing things.

tags: added: bash-completion packaging
Revision history for this message
Matt Bruzek (mbruzek) wrote :

After removing the old files from /etc/bash_completion.d/ I was not able to get *any* completion to work (in new terminals).

I tried 'juju-2.0 ssh kuber<TAB>' and that worked, it also started working to run 'juju ssh kuber<TAB>'

But it would not work with 'juju ssh kuber<TAB>' alone until I symbolically linked "juju" to "juju-2.0" in the /usr/share/bash-completion/completions/ directory.

Changed in juju-core:
status: New → Triaged
importance: Undecided → High
importance: High → Critical
importance: Critical → High
Revision history for this message
Matt Bruzek (mbruzek) wrote :

Before we can call this bug complete, the packaging should clean up the potentially old files that would prevent the bash completion from working correctly.

I understand we can include a post action that removes the bash completion files from the old /etc/bash_completion.d/ directory.

Something like this:

if [ -f /etc/bash_completion.d/juju2 ]; then
  rm /etc/bash_completion.d/juju2
fi
if [ -f /etc/bash_completion.d/juju-core ]; then
  rm /etc/bash_completion.d/juju-core
fi
if [ -f /etc/bash_completion.d/juju-core2 ]; then
  rm /etc/bash/completion.d/juju-core2
fi

Revision history for this message
Martin Packman (gz) wrote :

I think all we really want to do is make sure we conflict correctly with the old ppa package names, then dpkg will handle the removal of the old completion files before starting the install of the new juju-2.0 package.

summary: - The tab completion on juju yields KeyError: 'services'
+ Broken bash completion with old ppa packages present
Revision history for this message
Martin Packman (gz) wrote :

See irc log for more context:

<https://irclogs.ubuntu.com/2016/07/08/%23juju-dev.html#t17:57>

In particular, the completion files come from multiple old ppa packages:

<http://pastebin.ubuntu.com/18805007/>

juju2: /etc/bash_completion.d/juju2
juju-core2: /etc/bash_completion.d/juju-core2
juju-2.0: /usr/share/bash-completion/completions/juju-2.0
juju-2.0: /usr/share/bash-completion/completions/juju-version

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

But aren't the files in /etc/bash/completion.d conffiles? In that case they might not be deleted when that version of the package is upgraded.

Revision history for this message
Martin Packman (gz) wrote :

Hm, does it count as a purge-removed only conf file even if was placed there by dh_install as part of override_dh_auto_install in rules? If that's the case, what do you recommend we do to clean up?

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

I'm not actually completely sure how all this works. Which packages installed files to /etc/bash/completion.d? Can you link me to one?

If they are conffiles, the recommended fix I think is to remove them in a postinst, probably with rm_conffile ("man dpkg-maintscript-helper").

Revision history for this message
Martin Packman (gz) wrote :
Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote : Re: [Bug 1600257] Re: Broken bash completion with old ppa packages present

I meant actual debs. I tried building from those revisions but failed
-- I'm happy to do that if you give me a recipe :-) (possibly I've
just failed to remember how to use bzr...)

On 19 July 2016 at 12:26, Martin Packman <email address hidden> wrote:
> Old versions of the ppa packaging, eg:
>
> <http://bazaar.launchpad.net/~juju-qa/juju-release-tools/packaging-juju2-default/view/100/debian/rules>
> <http://bazaar.launchpad.net/~juju-qa/juju-release-tools/packaging-juju2-default/view/109/debian/rules>
>
> --
> You received this bug notification because you are subscribed to juju-
> core.
> Matching subscriptions: juju packaging, juju-core packaging
> https://bugs.launchpad.net/bugs/1600257
>
> Title:
> Broken bash completion with old ppa packages present
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/juju-core/+bug/1600257/+subscriptions

Revision history for this message
Martin Packman (gz) wrote :

Thinking about it, CI debs of that vintage should do, eg:

<http://reports.vapour.ws/releases/3600/binaries>

Can try installing on of those in a fresh vm then installing new packaging over the top.

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Yep, that installed a conffile:

$ dpkg-deb -e /home/mwhudson/Downloads/juju-core_2.0-beta1-0ubuntu1-16.04.1-juju1_amd64.deb
$ cat DEBIAN/conffiles
/etc/bash_completion.d/juju-core

Will need a maintainer script to clean that up. You could use
rm_conffile, but as I think these files were only installed by PPA
versions of the package, not anything from the archive (?) and more
certainly we don't care at all about any local modifications the user
may have made (i.e. it probably should never have been a conffile), I
think just unconditionally deleting it in postinst might make most
sense.

On 21 July 2016 at 09:45, Martin Packman <email address hidden> wrote:
> Thinking about it, CI debs of that vintage should do, eg:
>
> <http://reports.vapour.ws/releases/3600/binaries>
>
> Can try installing on of those in a fresh vm then installing new
> packaging over the top.
>
> --
> You received this bug notification because you are subscribed to juju-
> core.
> Matching subscriptions: juju packaging, juju-core packaging
> https://bugs.launchpad.net/bugs/1600257
>
> Title:
> Broken bash completion with old ppa packages present
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/juju-core/+bug/1600257/+subscriptions

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package juju-core - 2.0~beta12-0ubuntu3.16.10.1

---------------
juju-core (2.0~beta12-0ubuntu3.16.10.1) yakkety; urgency=medium

  * Add skip to current-manual-provider for bug 1605313 and bug 1605050

 -- Nicholas Skaggs <email address hidden> Thu, 21 Jul 2016 15:12:52 -0400

Changed in juju-core (Ubuntu):
status: New → Fix Released
Revision history for this message
Chris J Arges (arges) wrote : Please test proposed package

Hello Matt, or anyone else affected,

Accepted juju-core into xenial-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/juju-core/2.0~beta12-0ubuntu1.16.04.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-needed to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Changed in juju-core (Ubuntu Xenial):
status: New → Fix Committed
tags: added: verification-needed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package juju-core - 2.0~beta12-0ubuntu1.16.04.1

---------------
juju-core (2.0~beta12-0ubuntu1.16.04.1) xenial-proposed; urgency=medium

  [ Nicholas Skaggs ]
  * New upstream release 2.0-beta12 (LP: #1604137).
  * Update debian/copyright.
  * Add skip to current-manual-provider for bug 1605313 and bug 1605050
  * Fix adt test for manual-provider

  [ Martin Packman ]
  * Allow stripping of go binaries (LP: #1564662).
  * Mark juju-2.0 as conflicting and replacing old ppas (LP: #1600257).
  * Adjust where bash completion script is installed (LP: #1588403).

 -- Nicholas Skaggs <email address hidden> Mon, 18 Jul 2016 14:00:19 -0400

Changed in juju-core (Ubuntu Xenial):
status: Fix Committed → Fix Released
Revision history for this message
Matt Bruzek (mbruzek) wrote :

Verified with juju version == 2.0-beta13-xenial-amd64:

$ ls -al /usr/share/bash-completion/completions/ju*
lrwxrwxrwx 1 root root 8 Jul 22 11:34 /usr/share/bash-completion/completions/juju -> juju-2.0
-rw-r--r-- 1 root root 12705 Jul 20 12:41 /usr/share/bash-completion/completions/juju-2.0
-rw-r--r-- 1 root root 604 Jul 20 12:41 /usr/share/bash-completion/completions/juju-version

Tab completion worked for me on this system.

tags: added: verification-done
removed: verification-needed
Changed in juju-core:
status: Triaged → Invalid
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.