Response code '500 Internal Server Error' for POST /api/nodegroups/

Bug #1494320 reported by Alexander Bochkarev on 2015-09-10
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Fuel for OpenStack
High
Ihor Kalnytskyi
7.0.x
High
Ihor Kalnytskyi

Bug Description

To reproduce this bug in dev environment is required to perform the following curl request (don't forget to put the correct token):
curl 'http://127.0.0.1:8000/api/nodegroups/' -X POST -H 'Accept: application/json' -H 'Cookie: i18next=en-US; token=token1441899446' --data '{"cluster_id":100,"name":"cluster"}'
Please see traceback:
{
    "message": "Traceback (most recent call last):\n File \"/usr/lib/python2.6/site-packages/nailgun/api/v1/handlers/base.py\", line 166, in checked_data\n valid_data = method(data, **kwargs)\n File \"/usr/lib/python2.6/site-packages/nailgun/api/v1/validators/node_group.py\", line 32, in validate\n if cluster.net_provider == consts.CLUSTER_NET_PROVIDERS.nova_network:\nAttributeError: 'NoneType' object has no attribute 'net_provider'\n",
    "errors": []
}

Internal server error happens when an incorrect 'cluster_id' value is passed in the request body. In our case the incorrect cluster id is 100.
I suppose that NodeGroupValidator must be strengthened by checking on absence of a cluster. Also must be provided some error message which will inform about that.

Link to the block of code: https://github.com/stackforge/fuel-web/blob/master/nailgun/nailgun/api/v1/validators/node_group.py#L31-L35

Changed in fuel:
assignee: nobody → Fuel Python Team (fuel-python)
description: updated
Ivan Kliuk (ivankliuk) wrote :

Please add steps to reproduce.

Changed in fuel:
status: New → Incomplete
importance: Undecided → High
milestone: none → 8.0
description: updated
Changed in fuel:
status: Incomplete → New
Ivan Kliuk (ivankliuk) on 2015-09-11
Changed in fuel:
status: New → Confirmed
Changed in fuel:
assignee: Fuel Python Team (fuel-python) → Igor Kalnitsky (ikalnitsky)

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

Changed in fuel:
status: Confirmed → In Progress

Reviewed: https://review.openstack.org/225194
Committed: https://git.openstack.org/cgit/stackforge/fuel-web/commit/?id=6eb78b05cb02d7b472caff7a2e8b83d27c47e5ee
Submitter: Jenkins
Branch: master

commit 6eb78b05cb02d7b472caff7a2e8b83d27c47e5ee
Author: Igor Kalnitsky <email address hidden>
Date: Fri Sep 18 18:08:04 2015 +0300

    Validate cluster in node group creation

    Currently if user pass incorrect or invalid cluster ID to nodegroup
    creation POST request the 500 Internal Server error is occur. That's
    not the way we should handle invalid input data. Let's throw
    404 Not Found if invalid cluster ID is passed.

    Closes-Bug: #1494320

    Change-Id: Ief3754367690c83021f1e636f58311f0c02c941a
    Signed-off-by: Igor Kalnitsky <email address hidden>

Changed in fuel:
status: In Progress → Fix Committed
Dmitry Pyzhov (dpyzhov) on 2015-10-06
no longer affects: fuel/8.0.x
tags: added: on-verification
Vitaly Sedelnik (vsedelnik) wrote :

Igor, please review the fix and backport to 7.0 if applicable. If not, please update the status accordingly (Won't Fix or Invalid).

Reviewed: https://review.openstack.org/232553
Committed: https://git.openstack.org/cgit/stackforge/fuel-web/commit/?id=8529ce0a3ce316ab9fd87b0de5787b8ff2523498
Submitter: Jenkins
Branch: stable/7.0

commit 8529ce0a3ce316ab9fd87b0de5787b8ff2523498
Author: Igor Kalnitsky <email address hidden>
Date: Fri Sep 18 18:08:04 2015 +0300

    Validate cluster in node group creation

    Currently if user pass incorrect or invalid cluster ID to nodegroup
    creation POST request the 500 Internal Server error is occur. That's
    not the way we should handle invalid input data. Let's throw
    404 Not Found if invalid cluster ID is passed.

    Closes-Bug: #1494320

    Change-Id: Ief3754367690c83021f1e636f58311f0c02c941a
    Signed-off-by: Igor Kalnitsky <email address hidden>

Sergey Novikov (snovikov) wrote :

Verified on
VERSION:
  feature_groups:
    - mirantis
  production: "docker"
  release: "8.0"
  openstack_version: "2015.1.0-8.0"
  api: "1.0"
  build_number: "130"
  build_id: "130"
  fuel-nailgun_sha: "98211d5e4d2c9480f0a3a2dfab01f65675222a3b"
  python-fuelclient_sha: "501f8fb17462cebe689195089e1332cd2d98c8dc"
  fuel-agent_sha: "e881f0dabd09af4be4f3e22768b02fe76278e20e"
  fuel-nailgun-agent_sha: "d66f188a1832a9c23b04884a14ef00fc5605ec6d"
  astute_sha: "0f753467a3f16e4d46e7e9f1979905fb178e4d5b"
  fuel-library_sha: "42d4664fd3b51fd8fd1ab294485d0cb4e9eb406d"
  fuel-ostf_sha: "41aa5059243cbb25d7a80b97f8e1060a502b99dd"
  fuel-createmirror_sha: "df6a93f7e2819d3dfa600052b0f901d9594eb0db"
  fuelmain_sha: "f208d8963624ea9cd7810a20258fc6f5a44a33c3"

Changed in fuel:
status: Fix Committed → Fix Released
tags: removed: on-verification
tags: added: on-verification
Dmitriy Kruglov (dkruglov) wrote :

Verified on MOS 7.0, custom ISO. The issue is not reproduced.

ISO info:
VERSION:
  feature_groups:
    - mirantis
  production: "docker"
  release: "7.0"
  openstack_version: "2015.1.0-7.0"
  api: "1.0"
  build_number: "1260"
  build_id: "2015-10-09_12-02-12"
  nailgun_sha: "edbae54d510edbaa1d379e9523febe5a0e5acd41"
  python-fuelclient_sha: "486bde57cda1badb68f915f66c61b544108606f3"
  fuel-agent_sha: "50e90af6e3d560e9085ff71d2950cfbcca91af67"
  fuel-nailgun-agent_sha: "d7027952870a35db8dc52f185bb1158cdd3d1ebd"
  astute_sha: "6c5b73f93e24cc781c809db9159927655ced5012"
  fuel-library_sha: "713698e88c6e1e4ed9ebad759a21266890898d57"
  fuel-ostf_sha: "2cd967dccd66cfc3a0abd6af9f31e5b4d150a11c"
  fuelmain_sha: "a65d453215edb0284a2e4761be7a156bb5627677"

tags: removed: on-verification
Dmitry Pyzhov (dpyzhov) on 2015-10-22
tags: added: area-python
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers