[Plugins] Plugin v1.0 installation fails when -f flag is specified

Bug #1565883 reported by Carlos Novo
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Fuel for OpenStack
Fix Committed
Medium
Ovidiu Miron
Mitaka
Won't Fix
Medium
Ovidiu Miron

Bug Description

Detailed bug description:

If a plugin in the version 1.0 is tried to be installed and it doesn't update an already installed plugin, when the user specifies the option -f in order to force the reinstallation, a python error is raised:

```
[root@fuel objects]# fuel plugins --install /tmp/lbaas-1.0.0.fp -f
DEPRECATION WARNING: The plugin has old 1.0 package format, this format does not support many features, such as plugins updates, find plugin in new format or migrate and rebuild this one.
Traceback (most recent call last):
  File "/usr/bin/fuel", line 10, in <module>
    sys.exit(main())
  File "/usr/lib/python2.7/site-packages/fuelclient/cli/error.py", line 115, in wrapper
    return func(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/fuelclient/cli/parser.py", line 266, in main
    parser.parse()
  File "/usr/lib/python2.7/site-packages/fuelclient/cli/parser.py", line 143, in parse
    actions[parsed_params.action].action_func(parsed_params)
  File "/usr/lib/python2.7/site-packages/fuelclient/cli/actions/base.py", line 62, in action_func
    method(params)
  File "/usr/lib/python2.7/site-packages/fuelclient/cli/actions/plugins.py", line 88, in install
    results = Plugins.install(file_path, force=params.force)
  File "/usr/lib/python2.7/site-packages/fuelclient/objects/plugins.py", line 344, in install
    response = cls.register(name, version, force=force)
  File "/usr/lib/python2.7/site-packages/fuelclient/objects/plugins.py", line 299, in register
    return cls.update_or_create(metadata, force=force)
  File "/usr/lib/python2.7/site-packages/fuelclient/objects/plugins.py", line 454, in update_or_create
    url = cls.class_instance_path.format(id=resp['id'])
KeyError: 'id'
```

Steps to reproduce:

- Log into the fuel server
- Download any v1.0 plugin, eg

  wget http://plugins.mirantis.com/repository/l/b/lbaas/lbaas-1.0.0.fp

- Install the plugin

  fuel plugins --install /tmp/lbaas-1.0.0.fp

- Install the plugin again with -f

  fuel plugins --install /tmp/lbaas-1.0.0.fp -f

Expected results:

  The plugin is reinstalled

Actual result:

Traceback (most recent call last):
  File "/usr/bin/fuel", line 10, in <module>
    sys.exit(main())
  File "/usr/lib/python2.7/site-packages/fuelclient/cli/error.py", line 115, in wrapper
    return func(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/fuelclient/cli/parser.py", line 266, in main
    parser.parse()
  File "/usr/lib/python2.7/site-packages/fuelclient/cli/parser.py", line 143, in parse
    actions[parsed_params.action].action_func(parsed_params)
  File "/usr/lib/python2.7/site-packages/fuelclient/cli/actions/base.py", line 62, in action_func
    method(params)
  File "/usr/lib/python2.7/site-packages/fuelclient/cli/actions/plugins.py", line 88, in install
    results = Plugins.install(file_path, force=params.force)
  File "/usr/lib/python2.7/site-packages/fuelclient/objects/plugins.py", line 344, in install
    response = cls.register(name, version, force=force)
  File "/usr/lib/python2.7/site-packages/fuelclient/objects/plugins.py", line 299, in register
    return cls.update_or_create(metadata, force=force)
  File "/usr/lib/python2.7/site-packages/fuelclient/objects/plugins.py", line 454, in update_or_create
    url = cls.class_instance_path.format(id=resp['id'])
KeyError: 'id'

Reproducibility:

  Allways

Workaround:

  Doesn't exist

Impact:

  The user can not force the reinstallation of a v1.0 plugin

Description of the environment:

  Operation system: Linux fuel.domain.tld 3.10.0-229.20.1.el7.x86_64 #1 SMP Tue Nov 3 19:10:07
  Version of components: fuel 8.0.0

Aditional information:

In /usr/lib/python2.7/site-packages/fuelclient/objects/plugin.py, method update_or_create(), when resp status code is 409 ( Conflict ) and force flag is set, the put url is trying to be achieved using resp['id']

The problem is that, in that case, the resp has not such key. The 'id' key is in resp['message'] .

Proposed fix:

json.load(resp['message']) and get the 'id' from the resulting dictionary.

Carlos Novo (cnovo-k)
description: updated
Carlos Novo (cnovo-k)
description: updated
Changed in fuel:
milestone: none → 8.0-updates
tags: added: area-python
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-fuelclient (master)

Fix proposed to branch: master
Review: https://review.openstack.org/302357

Changed in fuel:
status: Confirmed → In Progress
tags: added: module-client
Revision history for this message
Dmitry Pyzhov (dpyzhov) wrote :

As I see fix is not merged yet. Moving the medium bug to 10.0 release.

Changed in fuel:
status: Fix Committed → In Progress
milestone: 9.0 → 10.0
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-fuelclient (master)

Reviewed: https://review.openstack.org/302357
Committed: https://git.openstack.org/cgit/openstack/python-fuelclient/commit/?id=4033bc83c324ea180852878a89ffdb890c4cba3d
Submitter: Jenkins
Branch: master

commit 4033bc83c324ea180852878a89ffdb890c4cba3d
Author: Ovidiu Miron <email address hidden>
Date: Wed Apr 6 17:35:52 2016 +0100

    Updated retrieval of 'id' in objects/plugins.py

    When updating a Fuel plugin which is the new format, the json response
    contains 'id' at the root of the json response.
    To support the old format I've updated code to retrieve 'id' from the
    'message' object.

    Closes-Bug: #1565883

    Change-Id: Ie411ef322fa9ebc5887fef9db53d4318b99ae857

Changed in fuel:
status: In Progress → Fix Committed
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.