Skip to content

CLOUDSTACK-8858: listVolumes API fails for a particular domain with NPE.#830

Merged
asfgit merged 1 commit into
apache:masterfrom
sureshanaparti:CLOUDSTACK-8858
Jan 27, 2016
Merged

CLOUDSTACK-8858: listVolumes API fails for a particular domain with NPE.#830
asfgit merged 1 commit into
apache:masterfrom
sureshanaparti:CLOUDSTACK-8858

Conversation

@sureshanaparti

Copy link
Copy Markdown
Contributor

CLOUDSTACK-8858: listVolumes API fails for a particular domain with NPE.

Summary: listVolumes API fails when volume associated vm instance has NULL or invalid state. Fix the code to guard this situation since this should not block volume listing.

Summary: listVolumes API fails when volume associated vm instance has NULL or invalid state. Fix the code to guard this situation since this should not block volume listing.
@remibergsma

Copy link
Copy Markdown
Contributor

PIng @DaanHoogland can you review this please? I'll run some tests.

@DaanHoogland

Copy link
Copy Markdown
Contributor

Though I would like to see how this situation is reproduced, the code is fine and sensible.

LGTM

@ustcweizhou

Copy link
Copy Markdown
Contributor

I have the same concern with Daan. How to reproduce this issue ?
Check my env

mysql> select * from volumes where volume_type is null or provisioning_type is null or state is null;
Empty set (0.00 sec)

@sureshanaparti

Copy link
Copy Markdown
Contributor Author

@DaanHoogland , @ustcweizhou
This issue is reproduced when the volume associated vm instance has null or invalid state (vm_state in volume_view). The code changes would guard this situation since it should not block volume listing.

mysql> SELECT id, name, volume_type, state, vm_state FROM cloud.volume_view where vm_state is null;
+----+----------------------+-------------+----------+----------+
| id | name | volume_type | state | vm_state |
+----+----------------------+-------------+----------+----------+
| 57 | ROOT-57 | ROOT | Expunged | NULL |
| 69 | mytestvolume | DATADISK | Ready | NULL |
| 71 | DATA-69 | DATADISK | Expunged | NULL |
| 73 | DATA-70 | DATADISK | Expunged | NULL |
| 78 | testvolcreated | DATADISK | Ready | NULL |
| 81 | test2volume | DATADISK | Destroy | NULL |
| 83 | testvol07 | DATADISK | Ready | NULL |
| 87 | testattachvolcreated | DATADISK | Ready | NULL |
+----+----------------------+-------------+----------+----------+
8 rows in set (0.00 sec)

@DaanHoogland

Copy link
Copy Markdown
Contributor

@sureshanaparti How do we force such a situation to occur?
It seems to me that should be guarded on input and alerted on on output instead of silently filtered.

@ustcweizhou

Copy link
Copy Markdown
Contributor

@sureshanaparti

mysql> SELECT id, name, volume_type, state, vm_state FROM cloud.volume_view where vm_state is null and vm_id is not null;
Empty set (0.00 sec)

even in vm_instance

mysql> select * from vm_instance where state is null;
Empty set (0.00 sec)

@sureshanaparti

Copy link
Copy Markdown
Contributor Author

@ustcweizhou , Same with my result set as well.
mysql> select * from vm_instance where state is null;
Empty set (0.00 sec)

mysql> SELECT id, name, volume_type, state, vm_state FROM cloud.volume_view where vm_state is null and vm_id is not null;
Empty set (0.00 sec)

@sureshanaparti

Copy link
Copy Markdown
Contributor Author

The volumes, in Ready state and are not attached to any VM have their vm_state has null and querying such volumes may result in NPE. These changes are only to safe guard.

@ustcweizhou

Copy link
Copy Markdown
Contributor

@sureshanaparti
I do not get NPE when listVolumes.

please notice the code:
long instanceId = volume.getVmId();
if (instanceId > 0 && volume.getState() != Volume.State.Destroy) {
...

if the volume is not attached, this judgment returns false.

@sureshanaparti

Copy link
Copy Markdown
Contributor Author

@ustcweizhou , Yes. I agree. In case on instance id, vm_state is not null.

@yadvr

yadvr commented Jan 25, 2016

Copy link
Copy Markdown
Member

LGTM

@yadvr

yadvr commented Jan 27, 2016

Copy link
Copy Markdown
Member

Merging as it has 2LGTMs

@asfgit
asfgit merged commit c377763 into apache:master Jan 27, 2016
asfgit pushed a commit that referenced this pull request Jan 27, 2016
CLOUDSTACK-8858: listVolumes API fails for a particular domain with NPE.CLOUDSTACK-8858: listVolumes API fails for a particular domain with NPE.

Summary: listVolumes API fails when volume associated vm instance has NULL or invalid state. Fix the code to guard this situation since this should not block volume listing.

* pr/830:
  CLOUDSTACK-8858: listVolumes API fails for a particular domain with NPE.

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
yadvr pushed a commit that referenced this pull request Jan 20, 2021
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants