Public bug reported:

When some of the values for Cinder quota are set to -1 (which means,
"infinity" quota), REST API call for getAbsoluteLimits [1] crashes.

That JavaScript function makes a request to
http://localshost/api/cinder/tenantabsolutelimits/

That request, generates a response, like:

{"totalSnapshotsUsed": 0, "total_volumes_standard": 10,
"maxTotalBackups": 10, "totalBackupsUsed": 0, "maxTotalBackupGigabytes":
1000, "maxTotalVolumes": 10, "used_volumes_standard": 1,
"maxTotalVolumeGigabytes": 1000, "totalVolumesUsed": 1,
"total_gigabytes_standard": 1000, "totalBackupGigabytesUsed": 0,
"maxTotalSnapshots": 0, "used_gigabytes_standard": 1,
"totalGigabytesUsed": 1}

So far, so good.

Now, update the cinder quota for your project, for example, the
snapshots quota, to -1. The response changes to:

{"totalSnapshotsUsed": 0, "total_volumes_standard": 10,
"maxTotalBackups": 10, "totalBackupsUsed": 0, "maxTotalBackupGigabytes":
1000, "maxTotalVolumes": 10, "used_volumes_standard": 1,
"maxTotalVolumeGigabytes": 1000, "totalVolumesUsed": 1,
"total_gigabytes_standard": 1000, "totalBackupGigabytesUsed": 0,
"maxTotalSnapshots": Infinity, "used_gigabytes_standard": 1,
"totalGigabytesUsed": 1}

Please note that "maxTotalSnapshots": Infinity.

That dictionary, for python, is not a problem. But, for the JavaScript
parser, is a big issue.

Now, please open your browser, for example, Firefox and open the Console
(from Developers tool) and execute this in the console:

>> JSON.parse('{"totalSnapshotsUsed": 0, "total_volumes_standard": 10,
"maxTotalBackups": 10, "totalBackupsUsed": 0, "maxTotalBackupGigabytes":
1000, "maxTotalVolumes": 10, "used_volumes_standard": 1,
"maxTotalVolumeGigabytes": 1000, "totalVolumesUsed": 1,
"total_gigabytes_standard": 1000, "totalBackupGigabytesUsed": 0,
"maxTotalSnapshots": 0, "used_gigabytes_standard": 1,
"totalGigabytesUsed": 1}')

That worked fine, no issues, but now try this (with infinity quota for
snapshots):

>> JSON.parse('{"totalSnapshotsUsed": 0, "total_volumes_standard": 10,
"maxTotalBackups": 10, "totalBackupsUsed": 0, "maxTotalBackupGigabytes":
1000, "maxTotalVolumes": 10, "used_volumes_standard": 1,
"maxTotalVolumeGigabytes": 1000, "totalVolumesUsed": 1,
"total_gigabytes_standard": 1000, "totalBackupGigabytesUsed": 0,
"maxTotalSnapshots": Infinity, "used_gigabytes_standard": 1,
"totalGigabytesUsed": 1}')

It fails raising this message: SyntaxError: JSON.parse: unexpected
character at line 1 column 329 of the JSON data.

Summarizing, the issue in Horizon is due to -1 values in cinder quota,
which is translated to python to infinity values (see here [2]) and the
"Infinity" values are not a proper value for JSON.parse function.

[1] 
https://github.com/openstack/horizon/blob/e1f07e27944b505dec57dda20d3c3b13eb3bb4d7/openstack_dashboard/static/app/core/openstack-service-api/cinder.service.js#L284
[2] 
https://github.com/openstack/horizon/blob/e1f07e27944b505dec57dda20d3c3b13eb3bb4d7/openstack_dashboard/api/cinder.py#L779

** Affects: horizon
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to OpenStack Dashboard (Horizon).
https://bugs.launchpad.net/bugs/1587893

Title:
  Infinity quota values are not parsed by JSON.parse for
  getAbsoluteLimits

Status in OpenStack Dashboard (Horizon):
  New

Bug description:
  When some of the values for Cinder quota are set to -1 (which means,
  "infinity" quota), REST API call for getAbsoluteLimits [1] crashes.

  That JavaScript function makes a request to
  http://localshost/api/cinder/tenantabsolutelimits/

  That request, generates a response, like:

  {"totalSnapshotsUsed": 0, "total_volumes_standard": 10,
  "maxTotalBackups": 10, "totalBackupsUsed": 0,
  "maxTotalBackupGigabytes": 1000, "maxTotalVolumes": 10,
  "used_volumes_standard": 1, "maxTotalVolumeGigabytes": 1000,
  "totalVolumesUsed": 1, "total_gigabytes_standard": 1000,
  "totalBackupGigabytesUsed": 0, "maxTotalSnapshots": 0,
  "used_gigabytes_standard": 1, "totalGigabytesUsed": 1}

  So far, so good.

  Now, update the cinder quota for your project, for example, the
  snapshots quota, to -1. The response changes to:

  {"totalSnapshotsUsed": 0, "total_volumes_standard": 10,
  "maxTotalBackups": 10, "totalBackupsUsed": 0,
  "maxTotalBackupGigabytes": 1000, "maxTotalVolumes": 10,
  "used_volumes_standard": 1, "maxTotalVolumeGigabytes": 1000,
  "totalVolumesUsed": 1, "total_gigabytes_standard": 1000,
  "totalBackupGigabytesUsed": 0, "maxTotalSnapshots": Infinity,
  "used_gigabytes_standard": 1, "totalGigabytesUsed": 1}

  Please note that "maxTotalSnapshots": Infinity.

  That dictionary, for python, is not a problem. But, for the JavaScript
  parser, is a big issue.

  Now, please open your browser, for example, Firefox and open the
  Console (from Developers tool) and execute this in the console:

  >> JSON.parse('{"totalSnapshotsUsed": 0, "total_volumes_standard": 10,
  "maxTotalBackups": 10, "totalBackupsUsed": 0,
  "maxTotalBackupGigabytes": 1000, "maxTotalVolumes": 10,
  "used_volumes_standard": 1, "maxTotalVolumeGigabytes": 1000,
  "totalVolumesUsed": 1, "total_gigabytes_standard": 1000,
  "totalBackupGigabytesUsed": 0, "maxTotalSnapshots": 0,
  "used_gigabytes_standard": 1, "totalGigabytesUsed": 1}')

  That worked fine, no issues, but now try this (with infinity quota for
  snapshots):

  >> JSON.parse('{"totalSnapshotsUsed": 0, "total_volumes_standard": 10,
  "maxTotalBackups": 10, "totalBackupsUsed": 0,
  "maxTotalBackupGigabytes": 1000, "maxTotalVolumes": 10,
  "used_volumes_standard": 1, "maxTotalVolumeGigabytes": 1000,
  "totalVolumesUsed": 1, "total_gigabytes_standard": 1000,
  "totalBackupGigabytesUsed": 0, "maxTotalSnapshots": Infinity,
  "used_gigabytes_standard": 1, "totalGigabytesUsed": 1}')

  It fails raising this message: SyntaxError: JSON.parse: unexpected
  character at line 1 column 329 of the JSON data.

  Summarizing, the issue in Horizon is due to -1 values in cinder quota,
  which is translated to python to infinity values (see here [2]) and
  the "Infinity" values are not a proper value for JSON.parse function.

  [1] 
https://github.com/openstack/horizon/blob/e1f07e27944b505dec57dda20d3c3b13eb3bb4d7/openstack_dashboard/static/app/core/openstack-service-api/cinder.service.js#L284
  [2] 
https://github.com/openstack/horizon/blob/e1f07e27944b505dec57dda20d3c3b13eb3bb4d7/openstack_dashboard/api/cinder.py#L779

To manage notifications about this bug go to:
https://bugs.launchpad.net/horizon/+bug/1587893/+subscriptions

-- 
Mailing list: https://launchpad.net/~yahoo-eng-team
Post to     : yahoo-eng-team@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yahoo-eng-team
More help   : https://help.launchpad.net/ListHelp

Reply via email to