From 5cf13459813228a2b8d78bba2d28a10528490c1f Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Sun, 31 Jan 2021 10:29:51 -0600 Subject: [PATCH] mgr/MetricTypes: condition encoding on feature bits Do not encode new metric|config types for older peers. The combination of boost::optional and boost::variant make this super awkward to condition on the features. :( Fixes: https://tracker.ceph.com/issues/49069 Signed-off-by: Sage Weil --- src/messages/MMgrConfigure.h | 7 ++++++- src/messages/MMgrReport.h | 7 ++++++- src/mgr/MetricTypes.h | 17 +++++++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/messages/MMgrConfigure.h b/src/messages/MMgrConfigure.h index aaa36790a4c06..7b27c9064eb37 100644 --- a/src/messages/MMgrConfigure.h +++ b/src/messages/MMgrConfigure.h @@ -59,7 +59,12 @@ public: encode(stats_period, payload); encode(stats_threshold, payload); encode(osd_perf_metric_queries, payload); - encode(metric_config_message, payload); + if (metric_config_message && metric_config_message->should_encode(features)) { + encode(metric_config_message, payload); + } else { + boost::optional empty; + encode(empty, payload); + } } std::string_view get_type_name() const override { return "mgrconfigure"; } diff --git a/src/messages/MMgrReport.h b/src/messages/MMgrReport.h index 767ee775d22a5..5cd5f3d5442a4 100644 --- a/src/messages/MMgrReport.h +++ b/src/messages/MMgrReport.h @@ -157,7 +157,12 @@ public: encode(config_bl, payload); encode(osd_perf_metric_reports, payload); encode(task_status, payload); - encode(metric_report_message, payload); + if (metric_report_message && metric_report_message->should_encode(features)) { + encode(metric_report_message, payload); + } else { + boost::optional empty; + encode(empty, payload); + } } std::string_view get_type_name() const override { return "mgrreport"; } diff --git a/src/mgr/MetricTypes.h b/src/mgr/MetricTypes.h index 5f1adc6cf19f9..586c470ca5697 100644 --- a/src/mgr/MetricTypes.h +++ b/src/mgr/MetricTypes.h @@ -6,6 +6,7 @@ #include #include "include/denc.h" +#include "include/ceph_features.h" #include "mgr/OSDPerfMetricTypes.h" #include "mgr/MDSPerfMetricTypes.h" @@ -104,6 +105,14 @@ struct MetricReportMessage { : payload(payload) { } + bool should_encode(uint64_t features) const { + if (!HAVE_FEATURE(features, SERVER_PACIFIC) && + boost::get(&payload)) { + return false; + } + return true; + } + void encode(ceph::buffer::list &bl) const { boost::apply_visitor(EncodeMetricPayloadVisitor(bl), payload); } @@ -229,6 +238,14 @@ struct MetricConfigMessage { : payload(payload) { } + bool should_encode(uint64_t features) const { + if (!HAVE_FEATURE(features, SERVER_PACIFIC) && + boost::get(&payload)) { + return false; + } + return true; + } + void encode(ceph::buffer::list &bl) const { boost::apply_visitor(EncodeConfigPayloadVisitor(bl), payload); } -- 2.39.5