]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
pybind/mgr/balancer: fix pool-deletion vs auto-optimization race
authorxie xingguo <xie.xingguo@zte.com.cn>
Mon, 5 Mar 2018 02:09:52 +0000 (10:09 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Sat, 10 Mar 2018 03:43:41 +0000 (11:43 +0800)
commitdcdeae324e51de98d3c8df7a084b0fabdc33b5d0
tree50bde948a93df37df84147c4153d930da75a548d
parente50a50cf10dc4abd2af385840db104285dbffebc
pybind/mgr/balancer: fix pool-deletion vs auto-optimization race

This patch fixes the error below:
```
File "/usr/lib/ceph/mgr/balancer/module.py", line 722, in optimize
  return self.do_crush_compat(plan)
File "/usr/lib/ceph/mgr/balancer/module.py", line 781, in do_crush_compat
  pe = self.calc_eval(ms, plan.pools)
File "/usr/lib/ceph/mgr/balancer/module.py", line 570, in calc_eval
  objects_by_osd[osd] += ms.pg_stat[pgid]['num_objects']
KeyError: ('5.1b',)
```

The root cause is that balancer is basically collecting cluster
information from two separate maps (OSDMap and PGMap), and hence
there is a small window/chance that the pool statistics might
become divergent. E.g.:
1) auto-optimization begin
2) get osdmap
3) a pool is gone (deleted by admin); pg_dump refreshed
4) get pg_dump (balancer is now with both the newest pg_dump
   and an obsolute osdmap in hand)
5) execute optimization; balancer complains some PGs are missing
   in the pg_dump map..

Fix the above problem by tracing pools existing in both maps only.

Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
(cherry picked from commit a57b803e7027a6bfb9d64e3e9810dbf0ef3217ac)
src/pybind/mgr/balancer/module.py