Project

General

Profile

Actions

Bug #7510

closed

Value error in ceph.py

Added by Anonymous about 10 years ago. Updated almost 10 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
-
Category:
-
% Done:

0%

Source:
other
Tags:
Backport:
Regression:
Severity:
3 - minor
Reviewed:
Affected Versions:
ceph-qa-suite:
Crash signature (v1):
Crash signature (v2):

Description

  File "/home/teuthworker/teuthology-master/teuthology/contextutil.py", line 25, in nested
    vars.append(enter())
  File "/usr/lib/python2.7/contextlib.py", line 17, in __enter__
    return self.gen.next()
  File "/home/teuthworker/teuthology-master/teuthology/task/ceph.py", line 566, in cluster
    (mon0_remote,) = ctx.cluster.only(firstmon).remotes.keys()
ValueError: too many values to unpack

I am pretty sure that the problem with the statement:

(mon0_remote,) = ctx.cluster.only(firstmon).remotes.keys()

is caused by the fact that there is more than one key in the list returned from keys(). I suspect that what we want here is:

(mon0_remote,) = ctx.cluster.only(firstmon).remotes.keys().iteritems()

There may also be a problem when iteritems() returns null so we probably need another check here too.

The x to firefly upgrade tests have exposed this problem. I will look through the logs for more/other instances.

Actions #1

Updated by Anonymous about 10 years ago

This problem also occurs in kernel.py

(role_remote,) = ctx.cluster.only(role).remotes.keys()
Actions #2

Updated by Anonymous about 10 years ago

The above two are the ones that hit on the test just run. I think that this is a problem all over teuthology/task. I have grepped for remote.keys() and found possible problems in:

autotest.py
ceph-deploy.py
ceph.py
common_fs_utils.py
kernel.py
qemu.py
rados_agent.py
rbd.py
s3readwrite.py
s3roundtrip.py
s3tests.py
swift.py

All of the above have statements of the form:

(x, ) = ctx.cluster.only(client).remotes.keys()

Actions #3

Updated by Anonymous about 10 years ago

Okay, it looks like this code is trying to extract keys but only expects to find one entry. It breaks if the key list ends up being of a length other than one.

>>> (z,) = []
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: need more than 0 values to unpack
>>> (z,) = ['x', 'y']
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: too many values to unpack
>>> (z,) = ['a']
>>> print z
a
Actions #4

Updated by Anonymous about 10 years ago

Note: My first iteritems comment is probably incorrect.

We should test for the keys list to be non-empty and just set using the first entry, if all we want is one key.

Actions #5

Updated by Anonymous about 10 years ago

  • Priority changed from Normal to High

Note: My first iteritems comment is probably incorrect.

Actions #6

Updated by Anonymous about 10 years ago

  • Assignee set to Anonymous
Actions #7

Updated by Anonymous about 10 years ago

Does anyone know why teuthology uses the following pattern?

(remote,) = ctx.cluster.only(first_mon).remotes.keys()

This throws a value error when remotes.keys() ends up having more than one item in the list. Code that would not throw a value error would be some thing like:

remote = ctx.cluster.only(first_mon).remotes.keys()[0]

If it is an error for remotes to have more than one entry, then we should probably catch that and print something more helpful than throwing a value error. Or we can check the size of remotes first (this would also catch problems if remotes is empty, too).

But getting back to my original question, what's the reason for doing (x,) = [list] rather than x = [list]0 ?

Actions #8

Updated by Josh Durgin about 10 years ago

A role is only assigned to one host, so there's a bug if it has more than one remote associated with it.

Actions #9

Updated by Anonymous about 10 years ago

I think that the change here should be to fail but print a more meaningful error message.

Actions #10

Updated by Anonymous about 10 years ago

  • Status changed from New to Fix Under Review
  • Assignee changed from Anonymous to Josh Durgin

The change has been pushed to https://github.com/ceph/teuthology/pull/214

The wip branch is wip-valueerror-messages-wusui

The code still throws a ValueError like it did previously, and the dump stack trace is still available for people to see. The change does add error messages that tell what extraneous values are seen in the remotes dictionary.

Actions #11

Updated by Josh Durgin about 10 years ago

  • Status changed from Fix Under Review to Resolved
  • Assignee changed from Josh Durgin to Anonymous
Actions #12

Updated by Zack Cerza about 10 years ago

Reverted the commit because of #7877.

I think the feature needs more review.

Edit: e.g. see https://github.com/ceph/teuthology/pull/214/files#r11031812

Actions #13

Updated by Zack Cerza about 10 years ago

  • Status changed from Resolved to 12
Actions #14

Updated by Anonymous about 10 years ago

  • Priority changed from High to Normal
Actions #15

Updated by Anonymous almost 10 years ago

I think that the problem here is that we want to preserve the ValueError behavior of throwing an exception and terminating when this condition occurs.

So I think a better fix may be to throw the exception and only catch it in run.main where a less confusing error message could be written.

Actions #16

Updated by Anonymous almost 10 years ago

  • Status changed from 12 to Resolved

Fix checked in to master.

SHA1: b4508a08489cdfdf1edec1a3deb16808deab4421

Actions

Also available in: Atom PDF