]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
mgr/orchestrator: do not try to iterate through None 31705/head
authorKefu Chai <kchai@redhat.com>
Mon, 18 Nov 2019 08:34:48 +0000 (16:34 +0800)
committerKefu Chai <kchai@redhat.com>
Thu, 21 Nov 2019 09:02:50 +0000 (17:02 +0800)
commit4174506f9249752f1282d721d924da92cd55f7a6
treea3b40fc16e295cdc7635f3c38a8bb8ac806dbd83
parente4b3036422df70e3c911240e3bba6a8bd3e9c792
mgr/orchestrator: do not try to iterate through None

`PlacementSpec` instances could be constructed with `nodes=None`, see
`OrchestratorCli._mds_add()` in orchestrator_cli/module.py, so we need
to handle the case of `None`.

also, it's dangerous to pass a list as the default parameter to a
method in python, as the value of reference point to that list will
be stored. and multiple calls of that method will share the same
instance of list. which is not expected under most circumstances.

in this change, list comprehension is unsed instead of more functional
`list(map(...))`, because, the behavior of `map()` in python3 is quite
different from that in python2. in python3, `map()` returns an iterator.
and `list()` actually materializes the iterator by walking through it,
and `list()` changes the iterator by advancing it. so, to improve the
readability and to reduce the menta load of developers, list
comprehension is better in most cases.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/pybind/mgr/orchestrator.py