maas-cli stack trace if .maascli.db unreadable

Bug #1319600 reported by Seth Arnold
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
MAAS
Invalid
High
Unassigned

Bug Description

The maas command line client is brittle to unexpected inputs. On trusty, I tried to run the 'sudo maas createsuperuser' command that I used on precise, quantal, and saucy, but it failed. I wanted detailed help, so I ran 'maas -h', and that dumped a stack trace because the file /home/ubuntu/.maascli.db was owned by root. I tried running a bare 'maas' to get help, and that gave an error message with instruction to run a command that isn't actually executable.

I expected the 'createsuperuser' command to be useful -- hints about its replacement would be welcome.

I expected a simple error message if a database file isn't readable rather than a stack trace.

I expected some simple help regardless of database ownership.

I expected the advice about getting help to be usable with copy-and-paste.

Thanks

Here's my full transcript:

ubuntu@server-335f9ebe-bbba-4c94-a356-22adcb7a6a5d:/tmp/qrt-test-django$ sudo maas createsuperuser
usage: /usr/lib/python2.7/dist-packages/maascli/__main__.py [-h] COMMAND ...
/usr/lib/python2.7/dist-packages/maascli/__main__.py: error: argument COMMAND: invalid choice: u'createsuperuser' (choose from u'list', u'login', u'logout', u'refresh')
ubuntu@server-335f9ebe-bbba-4c94-a356-22adcb7a6a5d:/tmp/qrt-test-django$ maas -h
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/usr/lib/python2.7/dist-packages/maascli/__main__.py", line 20, in <module>
    main()
  File "/usr/lib/python2.7/dist-packages/maascli/__init__.py", line 41, in main
    parser = prepare_parser(argv)
  File "/usr/lib/python2.7/dist-packages/maascli/parser.py", line 73, in prepare_parser
    api.register_api_commands(parser)
  File "/usr/lib/python2.7/dist-packages/maascli/api.py", line 493, in register_api_commands
    with ProfileConfig.open() as config:
  File "/usr/lib/python2.7/contextlib.py", line 17, in __enter__
    return self.gen.next()
  File "/usr/lib/python2.7/dist-packages/maascli/config.py", line 81, in open
    os.close(os.open(dbpath, os.O_CREAT | os.O_APPEND, 0600))
OSError: [Errno 13] Permission denied: '/home/ubuntu/.maascli.db'
ubuntu@server-335f9ebe-bbba-4c94-a356-22adcb7a6a5d:/tmp/qrt-test-django$ maas
Error: no arguments given.
Run /usr/lib/python2.7/dist-packages/maascli/__main__.py --help for usage details.
ubuntu@server-335f9ebe-bbba-4c94-a356-22adcb7a6a5d:/tmp/qrt-test-django$ /usr/lib/python2.7/dist-packages/maascli/__main__.py --help
-bash: /usr/lib/python2.7/dist-packages/maascli/__main__.py: Permission denied
ubuntu@server-335f9ebe-bbba-4c94-a356-22adcb7a6a5d:/tmp/qrt-test-django$ ls -l /usr/lib/python2.7/dist-packages/maascli/__main__.py
-rw-r--r-- 1 root root 362 Apr 15 16:06 /usr/lib/python2.7/dist-packages/maascli/__main__.py
ubuntu@server-335f9ebe-bbba-4c94-a356-22adcb7a6a5d:/tmp/qrt-test-django$ maas --help
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/usr/lib/python2.7/dist-packages/maascli/__main__.py", line 20, in <module>
    main()
  File "/usr/lib/python2.7/dist-packages/maascli/__init__.py", line 41, in main
    parser = prepare_parser(argv)
  File "/usr/lib/python2.7/dist-packages/maascli/parser.py", line 73, in prepare_parser
    api.register_api_commands(parser)
  File "/usr/lib/python2.7/dist-packages/maascli/api.py", line 493, in register_api_commands
    with ProfileConfig.open() as config:
  File "/usr/lib/python2.7/contextlib.py", line 17, in __enter__
    return self.gen.next()
  File "/usr/lib/python2.7/dist-packages/maascli/config.py", line 81, in open
    os.close(os.open(dbpath, os.O_CREAT | os.O_APPEND, 0600))
OSError: [Errno 13] Permission denied: '/home/ubuntu/.maascli.db'
ubuntu@server-335f9ebe-bbba-4c94-a356-22adcb7a6a5d:/tmp/qrt-test-django$ ls -l ~/.maas*
-rw------- 1 root root 3072 May 14 23:11 /home/ubuntu/.maascli.db
ubuntu@server-335f9ebe-bbba-4c94-a356-22adcb7a6a5d:/tmp/qrt-test-django$ sudo maas --help
usage: /usr/lib/python2.7/dist-packages/maascli/__main__.py [-h] COMMAND ...
....

ProblemType: Bug
DistroRelease: Ubuntu 14.04
Package: maas 1.5+bzr2252-0ubuntu1
ProcVersionSignature: User Name 3.13.0-24.46-generic 3.13.9
Uname: Linux 3.13.0-24-generic x86_64
ApportVersion: 2.14.1-0ubuntu3.1
Architecture: amd64
Date: Wed May 14 23:14:12 2014
Ec2AMI: ami-000008a2
Ec2AMIManifest: FIXME
Ec2AvailabilityZone: nova
Ec2InstanceType: m1.large
Ec2Kernel: aki-0000022a
Ec2Ramdisk: ari-0000022a
PackageArchitecture: all
ProcEnviron:
 TERM=rxvt-unicode
 PATH=(custom, no user)
 XDG_RUNTIME_DIR=<set>
 LANG=en_US.UTF-8
 SHELL=/bin/bash
SourcePackage: maas
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Seth Arnold (seth-arnold) wrote :
Revision history for this message
Julian Edwards (julian-edwards) wrote : Re: [Bug 1319600] [NEW] maas command line client brittle to unexpected inputs

On 15/05/14 09:22, Seth Arnold wrote:
> Public bug reported:
>
> The maas command line client is brittle to unexpected inputs. On trusty,
> I tried to run the 'sudo maas createsuperuser' command that I used on
> precise, quantal, and saucy, but it failed. I wanted detailed help, so I
> ran 'maas -h', and that dumped a stack trace because the file
> /home/ubuntu/.maascli.db was owned by root. I tried running a bare
> 'maas' to get help, and that gave an error message with instruction to
> run a command that isn't actually executable.
>
> I expected the 'createsuperuser' command to be useful -- hints about its
> replacement would be welcome.

On this page
http://maas.ubuntu.com/docs1.5/install.html
It says to run "sudo maas-region-admin createadmin ..."

Is there any reason you missed that that we can help to fix?

(In the last release, the maas command was renamed to maas-region-admin,
and maas-cli to maas, which has caused some confusion)

> I expected a simple error message if a database file isn't readable
> rather than a stack trace.
>
> I expected some simple help regardless of database ownership.

This should have happened without the stacktrace, and is the real bug
here. I will amend the title accordingly.

> I expected the advice about getting help to be usable with copy-and-
> paste.

Please file a separate bug for that.

(Also please file bugs on the upstream maas project)

summary: - maas command line client brittle to unexpected inputs
+ maas-cli stack trace if .maascli.db unreadable
Changed in maas:
status: New → Triaged
importance: Undecided → High
tags: added: maas-cli
Revision history for this message
Seth Arnold (seth-arnold) wrote :

> Is there any reason you missed that that we can help to fix?

Only that in the middle of testing an update I followed the same directions for precise, quantal, saucy, and noticed no problems until trusty. Fair's fair, things change, but it would have been nice to have a hint in the right direction without resorting to the web.

Thanks

Raphaël Badin (rvb)
tags: added: cli
removed: maas-cli
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in maas (Ubuntu):
status: New → Confirmed
Revision history for this message
Mike Pontillo (mpontillo) wrote :

I think the bug here is that we display an unwieldy stack trace rather than a nice error message.

Running "sudo maas <anything>" may cause this bug to occur, since the ~/.maascli.db will be created by the root user, rather than the currently-logged-in user.

Changed in maas:
milestone: none → 2.3.0
Changed in maas:
milestone: 2.3.0 → 2.3.x
Revision history for this message
Andres Rodriguez (andreserl) wrote :

Hi!

**This is an automated message**

We believe this is may no longer be an issue in the latest MAAS release. Due to the original date of the bug report, we are currently marking it as Invalid. If you believe this bug report still valid against the latest release of MAAS, or if you are still interested in this, please re-open this bug report.

Thanks

Changed in maas:
status: Triaged → Invalid
no longer affects: maas (Ubuntu)
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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