From ff479a102dd340d109dd2c893d65cde3fb16039b Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Sat, 2 Sep 2023 17:55:53 +0300 Subject: [PATCH] Make MON filter OSDs by block layout to prevent "refusing to start PGs of this pool" errors on misconfiguration --- docs/config/pool.en.md | 21 ++++++++++----------- docs/config/pool.ru.md | 22 ++++++++++++---------- mon/mon.js | 33 +++++++++++++++++++++++++++++++++ src/osd_cluster.cpp | 4 +++- 4 files changed, 58 insertions(+), 22 deletions(-) diff --git a/docs/config/pool.en.md b/docs/config/pool.en.md index ef7a8e4d..304da227 100644 --- a/docs/config/pool.en.md +++ b/docs/config/pool.en.md @@ -205,9 +205,8 @@ This parameter usually doesn't require to be changed. - Default: 131072 Block size for this pool. The value from /vitastor/config/global is used when -unspecified. If your cluster has OSDs with different block sizes then pool must -be restricted by [osd_tags](#osd_tags) to only include OSDs with matching block -size. +unspecified. Only OSDs with matching block_size are used for each pool. If you +want to further restrict OSDs for the pool, use [osd_tags](#osd_tags). Read more about this parameter in [Cluster-Wide Disk Layout Parameters](layout-cluster.en.md#block_size). @@ -216,10 +215,9 @@ Read more about this parameter in [Cluster-Wide Disk Layout Parameters](layout-c - Type: integer - Default: 4096 -"Sector" size of virtual disks in this pool. The value from -/vitastor/config/global is used when unspecified. Similar to block_size, the -pool must be restricted by [osd_tags](#osd_tags) to only include OSDs with -matching bitmap_granularity. +"Sector" size of virtual disks in this pool. The value from /vitastor/config/global +is used when unspecified. Similarly to block_size, only OSDs with matching +bitmap_granularity are used for each pool. Read more about this parameter in [Cluster-Wide Disk Layout Parameters](layout-cluster.en.md#bitmap_granularity). @@ -229,10 +227,11 @@ Read more about this parameter in [Cluster-Wide Disk Layout Parameters](layout-c - Default: none Immediate commit setting for this pool. The value from /vitastor/config/global -is used when unspecified. Similar to block_size, the pool must be restricted by -[osd_tags](#osd_tags) to only include OSDs with compatible immediate_commit. -Compatible means that a pool with non-immediate commit will work with OSDs with -immediate commit enabled, but not vice versa. +is used when unspecified. Similarly to block_size, only OSDs with compatible +bitmap_granularity are used for each pool. "Compatible" means that a pool with +non-immediate commit will use OSDs with immediate commit enabled, but not vice +versa. I.e., pools with "none" use all OSDs, pools with "small" only use OSDs +with "all" or "small", and pools with "all" only use OSDs with "all". Read more about this parameter in [Cluster-Wide Disk Layout Parameters](layout-cluster.en.md#immediate_commit). diff --git a/docs/config/pool.ru.md b/docs/config/pool.ru.md index a6eb360d..2174aed4 100644 --- a/docs/config/pool.ru.md +++ b/docs/config/pool.ru.md @@ -208,8 +208,9 @@ PG в Vitastor эферемерны, то есть вы можете менят Размер блока для данного пула. Если не задан, используется значение из /vitastor/config/global. Если в вашем кластере есть OSD с разными размерами -блока, пул должен быть ограничен только OSD, блок которых равен блоку пула, -с помощью [osd_tags](#osd_tags). +блока, пул будет использовать только OSD с размером блока, равным размеру блока +пула. Если вы хотите сильнее ограничить набор используемых для пула OSD - +используйте [osd_tags](#osd_tags). О самом параметре читайте в разделе [Дисковые параметры уровня кластера](layout-cluster.ru.md#block_size). @@ -219,9 +220,8 @@ PG в Vitastor эферемерны, то есть вы можете менят - По умолчанию: 4096 Размер "сектора" виртуальных дисков в данном пуле. Если не задан, используется -значение из /vitastor/config/global. Аналогично block_size, пул должен быть -ограничен OSD со значением bitmap_granularity, равным значению пула, с помощью -[osd_tags](#osd_tags). +значение из /vitastor/config/global. Аналогично block_size, каждый пул будет +использовать только OSD с совпадающей с пулом настройкой bitmap_granularity. О самом параметре читайте в разделе [Дисковые параметры уровня кластера](layout-cluster.ru.md#bitmap_granularity). @@ -231,11 +231,13 @@ PG в Vitastor эферемерны, то есть вы можете менят - По умолчанию: none Настройка мгновенного коммита для данного пула. Если не задана, используется -значение из /vitastor/config/global. Аналогично block_size, пул должен быть -ограничен OSD со значением bitmap_granularity, совместимым со значением пула, с -помощью [osd_tags](#osd_tags). Совместимость означает, что пул с отключенным -мгновенным коммитом может работать на OSD с включённым мгновенным коммитом, но -не наоборот. +значение из /vitastor/config/global. Аналогично block_size, каждый пул будет +использовать только OSD с *совместимыми* настройками immediate_commit. +"Совместимыми" означает, что пул с отключенным мгновенным коммитом будет +использовать OSD с включённым мгновенным коммитом, но не наоборот. То есть, +пул со значением "none" будет использовать все OSD, пул со "small" будет +использовать OSD с "all" или "small", а пул с "all" будет использовать только +OSD с "all". О самом параметре читайте в разделе [Дисковые параметры уровня кластера](layout-cluster.ru.md#immediate_commit). diff --git a/mon/mon.js b/mon/mon.js index 3fbf3af7..9843fb1d 100644 --- a/mon/mon.js +++ b/mon/mon.js @@ -1156,6 +1156,33 @@ class Mon } } + filter_osds_by_block_layout(flat_tree, block_size, bitmap_granularity, immediate_commit) + { + for (const host in flat_tree) + { + let found = 0; + for (const osd in flat_tree[host]) + { + const osd_stat = this.state.osd.stats[osd]; + if (osd_stat && (osd_stat.bs_block_size && osd_stat.bs_block_size != block_size || + osd_stat.bitmap_granularity && osd_stat.bitmap_granularity != bitmap_granularity || + osd_stat.immediate_commit == 'small' && immediate_commit == 'all' || + osd_stat.immediate_commit == 'none' && immediate_commit != 'none')) + { + delete flat_tree[host][osd]; + } + else + { + found++; + } + } + if (!found) + { + delete flat_tree[host]; + } + } + } + get_affinity_osds(pool_cfg, up_osds, osd_tree) { let aff_osds = up_osds; @@ -1216,6 +1243,12 @@ class Mon pool_tree = pool_tree ? pool_tree.children : []; pool_tree = LPOptimizer.flatten_tree(pool_tree, levels, pool_cfg.failure_domain, 'osd'); this.filter_osds_by_tags(osd_tree, pool_tree, pool_cfg.osd_tags); + this.filter_osds_by_block_layout( + pool_tree, + pool_cfg.block_size || this.config.block_size || 131072, + pool_cfg.bitmap_granularity || this.config.bitmap_granularity || 4096, + pool_cfg.immediate_commit || this.config.immediate_commit || 'none' + ); // These are for the purpose of building history.osd_sets const real_prev_pgs = []; let pg_history = []; diff --git a/src/osd_cluster.cpp b/src/osd_cluster.cpp index f5c7bc2e..2df59d3e 100644 --- a/src/osd_cluster.cpp +++ b/src/osd_cluster.cpp @@ -186,10 +186,12 @@ json11::Json osd_t::get_statistics() if (bs) { st["blockstore_ready"] = bs->is_started(); - st["data_block_size"] = (uint64_t)bs->get_block_size(); st["size"] = bs->get_block_count() * bs->get_block_size(); st["free"] = bs->get_free_block_count() * bs->get_block_size(); } + st["data_block_size"] = (uint64_t)bs_block_size; + st["bitmap_granularity"] = (uint64_t)bs_bitmap_granularity; + st["immediate_commit"] = immediate_commit == IMMEDIATE_ALL ? "all" : (immediate_commit == IMMEDIATE_SMALL ? "small" : "none"); st["host"] = self_state["host"]; json11::Json::object op_stats, subop_stats; for (int i = OSD_OP_MIN; i <= OSD_OP_MAX; i++)