Flush pg stats from a list of OSD ids, ensuring they are reflected all the way to the monitor. Luminous and later only. :param osds: list of OSDs to flush :param no_wait: list of OSDs not to wait for seq id. by default, we wait for all speci
(self, osds, no_wait=None, wait_for_mon=300)
| 1800 | return tuple(socks) |
| 1801 | |
| 1802 | def flush_pg_stats(self, osds, no_wait=None, wait_for_mon=300): |
| 1803 | """ |
| 1804 | Flush pg stats from a list of OSD ids, ensuring they are reflected |
| 1805 | all the way to the monitor. Luminous and later only. |
| 1806 | |
| 1807 | :param osds: list of OSDs to flush |
| 1808 | :param no_wait: list of OSDs not to wait for seq id. by default, we |
| 1809 | wait for all specified osds, but some of them could be |
| 1810 | moved out of osdmap, so we cannot get their updated |
| 1811 | stat seq from monitor anymore. in that case, you need |
| 1812 | to pass a blocklist. |
| 1813 | :param wait_for_mon: wait for mon to be synced with mgr. 0 to disable |
| 1814 | it. (5 min by default) |
| 1815 | """ |
| 1816 | if no_wait is None: |
| 1817 | no_wait = [] |
| 1818 | |
| 1819 | def flush_one_osd(osd: int, wait_for_mon: int): |
| 1820 | need = int(self.raw_cluster_cmd('tell', 'osd.%d' % osd, 'flush_pg_stats')) |
| 1821 | if not wait_for_mon: |
| 1822 | return |
| 1823 | if osd in no_wait: |
| 1824 | return |
| 1825 | got = 0 |
| 1826 | while wait_for_mon > 0: |
| 1827 | got = int(self.raw_cluster_cmd('osd', 'last-stat-seq', 'osd.%d' % osd)) |
| 1828 | self.log('need seq {need} got {got} for osd.{osd}'.format( |
| 1829 | need=need, got=got, osd=osd)) |
| 1830 | if got >= need: |
| 1831 | break |
| 1832 | A_WHILE = 1 |
| 1833 | time.sleep(A_WHILE) |
| 1834 | wait_for_mon -= A_WHILE |
| 1835 | else: |
| 1836 | raise Exception('timed out waiting for mon to be updated with ' |
| 1837 | 'osd.{osd}: {got} < {need}'. |
| 1838 | format(osd=osd, got=got, need=need)) |
| 1839 | |
| 1840 | with parallel() as p: |
| 1841 | for osd in osds: |
| 1842 | p.spawn(flush_one_osd, osd, wait_for_mon) |
| 1843 | |
| 1844 | def flush_all_pg_stats(self): |
| 1845 | self.flush_pg_stats(range(len(self.get_osd_dump()))) |