cli: maas logout causes KeyError for other profiles

Bug #1507712 reported by John George
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MAAS
Fix Released
Medium
Greg Lutostanski
2.2
Fix Released
Medium
Andres Rodriguez

Bug Description

maas cli commands fail if run at the same time as 'maas logout' for any other profile.

The setup where this bug is frequently seen involves a host which interacts with 4 separate MAAS servers. The host is a test driver and uses the maas cli, when a test is being run, to collect information about the nodes that have been allocated:
    1. maas login maas_A http://10.0.40.100/MAAS/api/1.0/ <apikey>
    2. <maas cli commands to query nodes>
    3. maas logout maas_A

Tests are run in parallel against all 4 MAAS server (maas_A, maas_B, maas_C, maas_D).

When the timing lines up is a way that 'maas logout' is called, for example against maas_A, within close proximity to maas cli commands against maas_B, maas_C or maas_D, the following error is reported back to the shell running the latter.

jenkins@finfolk:~$ maas maas_B nodes list
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 80, in prepare_parser
    api.register_api_commands(parser)
  File "/usr/lib/python2.7/dist-packages/maascli/api.py", line 480, in register_api_commands
    profile = config[profile_name]
  File "/usr/lib/python2.7/dist-packages/maascli/config.py", line 56, in __getitem__
    raise KeyError(name)
KeyError: u'maas_foo'

This bug can easily be re-produced by:
    1. Open two shells on the same host and log into two different MAAS servers.
    2. From one shell call 'maas logout <profile>'
    3. Immediately attempt to run any maas cli command from the second shell.

A re-try will generally work, so it seems there is a small window when this occurs but not so small that it's hard to reproduce.

ii maas-cli 1.9.0~alpha4+bzr4371-0ubuntu1~trusty1 all MAAS command line API tool
un maas-region-controller-min <none> <none> (no description available)
ii python-maas-client 1.9.0~alpha4+bzr4371-0ubuntu1~trusty1 all MAAS python API client

Related branches

Changed in maas:
milestone: none → 1.9.0
importance: Undecided → Low
importance: Low → Medium
John George (jog)
description: updated
Gavin Panella (allenap)
Changed in maas:
status: New → Triaged
Revision history for this message
John George (jog) wrote :

The workaround used is the test environment is to create a wrapper script, such as /usr/local/bin/maas with:
#!/bin/bash
flock -w 10 /var/lib/jenkins/maas.lock -c "/usr/bin/maas $*"

Changed in maas:
milestone: 1.9.0 → 2.3.0
Revision history for this message
Jason Hobbs (jason-hobbs) wrote :

This bug causes us a ton of issues. The flock workaround jog listed above isn't reliable because it depends on MAAS api calls finishing quickly, which they don't always do. Even with the timeout set to 120 seconds we still have failures.

We have had many many test failures due to this bug.

tags: added: cdo-qa-blocker
Chris Gregan (cgregan)
tags: added: cdo-qa
Changed in maas:
assignee: nobody → Blake Rouse (blake-rouse)
Changed in maas:
assignee: Blake Rouse (blake-rouse) → Greg Lutostanski (lutostag)
Revision history for this message
Greg Lutostanski (lutostag) wrote :
Changed in maas:
status: Triaged → In Progress
Changed in maas:
status: In Progress → Fix Committed
Changed in maas:
milestone: 2.3.0 → 2.3.0beta1
Changed in maas:
status: Fix Committed → Fix Released
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.