]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/cloudtier: Correct option ordering in RGWZoneGroupPlacementTier 61569/head
authorSoumya Koduri <skoduri@redhat.com>
Wed, 29 Jan 2025 16:17:45 +0000 (21:47 +0530)
committerSoumya Koduri <skoduri@redhat.com>
Tue, 4 Mar 2025 18:26:42 +0000 (23:56 +0530)
Two tier-config options (related to `cloud-restore`) were incorrectly added
in the middle of the encoding and decoding methods of RGWZoneGroupPlacementTier.
This modification can cause compatibility issues with older decoders when
attempting to read v2-encoded REST objects.

The fix is to correct the option order and update the decode() function to
properly interpret the structure based on the encoded version.

Signed-off-by: Soumya Koduri <skoduri@redhat.com>
src/rgw/rgw_zone_types.h

index d44761d7f5a95148ca23852a59acec620165c4ba..41c015692a90c532646ed569e7ac0caca7e3960f 100644 (file)
@@ -548,26 +548,27 @@ struct RGWZoneGroupPlacementTier {
   std::string tier_type;
   std::string storage_class;
   bool retain_head_object = false;
-  bool allow_read_through = false;
-  uint64_t read_through_restore_days = 1;
 
   struct _tier {
     RGWZoneGroupPlacementTierS3 s3;
   } t;
 
+  bool allow_read_through = false;
+  uint64_t read_through_restore_days = 1;
+
   int update_params(const JSONFormattable& config);
   int clear_params(const JSONFormattable& config);
 
   void encode(bufferlist& bl) const {
-    ENCODE_START(2, 1, bl);
+    ENCODE_START(3, 1, bl);
     encode(tier_type, bl);
     encode(storage_class, bl);
     encode(retain_head_object, bl);
-    encode(allow_read_through, bl);
-    encode(read_through_restore_days, bl);
     if (tier_type == "cloud-s3") {
       encode(t.s3, bl);
     }
+    encode(allow_read_through, bl);
+    encode(read_through_restore_days, bl);
     ENCODE_FINISH(bl);
   }
 
@@ -576,12 +577,22 @@ struct RGWZoneGroupPlacementTier {
     decode(tier_type, bl);
     decode(storage_class, bl);
     decode(retain_head_object, bl);
-    if (struct_v >= 2) {
+    if (struct_v == 1) {
+      if (tier_type == "cloud-s3") {
+        decode(t.s3, bl);
+      }
+    } else if (struct_v == 2) {
+      decode(allow_read_through, bl);
+      decode(read_through_restore_days, bl);
+      if (tier_type == "cloud-s3") {
+        decode(t.s3, bl);
+      }
+    } else if (struct_v >= 3) {
+      if (tier_type == "cloud-s3") {
+        decode(t.s3, bl);
+      }
       decode(allow_read_through, bl);
       decode(read_through_restore_days, bl);
-    }
-    if (tier_type == "cloud-s3") {
-      decode(t.s3, bl);
     }
     DECODE_FINISH(bl);
   }