]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/MetricTypes: condition encoding on feature bits 39206/head
authorSage Weil <sage@newdream.net>
Sun, 31 Jan 2021 16:29:51 +0000 (10:29 -0600)
committerSage Weil <sage@newdream.net>
Mon, 1 Feb 2021 20:25:42 +0000 (14:25 -0600)
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 <sage@newdream.net>
src/messages/MMgrConfigure.h
src/messages/MMgrReport.h
src/mgr/MetricTypes.h

index aaa36790a4c06b474585dd60b5d7ccbfe2ac39e0..7b27c9064eb37899283e8000c9772449ecffd961 100644 (file)
@@ -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<MetricConfigMessage> empty;
+      encode(empty, payload);
+    }
   }
 
   std::string_view get_type_name() const override { return "mgrconfigure"; }
index 767ee775d22a532ff05cc33493c1c557a68196ce..5cd5f3d5442a4c65c3a2ad6386755ddada10bb7c 100644 (file)
@@ -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<MetricReportMessage> empty;
+      encode(empty, payload);
+    }
   }
 
   std::string_view get_type_name() const override { return "mgrreport"; }
index 5f1adc6cf19f939412b606ae4d32e1d9ded677aa..586c470ca56973821b1de6deec8854a1ac7b1e29 100644 (file)
@@ -6,6 +6,7 @@
 
 #include <boost/variant.hpp>
 #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<MDSMetricPayload>(&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<MDSConfigPayload>(&payload)) {
+      return false;
+    }
+    return true;
+  }
+
   void encode(ceph::buffer::list &bl) const {
     boost::apply_visitor(EncodeConfigPayloadVisitor(bl), payload);
   }