Skip to content

Commit c2d226a

Browse files
committed
rgw/cloudtier: Correct option ordering in RGWZoneGroupPlacementTier
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 <[email protected]>
1 parent d492e85 commit c2d226a

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

src/rgw/rgw_zone_types.h

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -548,26 +548,27 @@ struct RGWZoneGroupPlacementTier {
548548
std::string tier_type;
549549
std::string storage_class;
550550
bool retain_head_object = false;
551-
bool allow_read_through = false;
552-
uint64_t read_through_restore_days = 1;
553551

554552
struct _tier {
555553
RGWZoneGroupPlacementTierS3 s3;
556554
} t;
557555

556+
bool allow_read_through = false;
557+
uint64_t read_through_restore_days = 1;
558+
558559
int update_params(const JSONFormattable& config);
559560
int clear_params(const JSONFormattable& config);
560561

561562
void encode(bufferlist& bl) const {
562-
ENCODE_START(2, 1, bl);
563+
ENCODE_START(3, 1, bl);
563564
encode(tier_type, bl);
564565
encode(storage_class, bl);
565566
encode(retain_head_object, bl);
566-
encode(allow_read_through, bl);
567-
encode(read_through_restore_days, bl);
568567
if (tier_type == "cloud-s3") {
569568
encode(t.s3, bl);
570569
}
570+
encode(allow_read_through, bl);
571+
encode(read_through_restore_days, bl);
571572
ENCODE_FINISH(bl);
572573
}
573574

@@ -576,12 +577,22 @@ struct RGWZoneGroupPlacementTier {
576577
decode(tier_type, bl);
577578
decode(storage_class, bl);
578579
decode(retain_head_object, bl);
579-
if (struct_v >= 2) {
580+
if (struct_v == 1) {
581+
if (tier_type == "cloud-s3") {
582+
decode(t.s3, bl);
583+
}
584+
} else if (struct_v == 2) {
585+
decode(allow_read_through, bl);
586+
decode(read_through_restore_days, bl);
587+
if (tier_type == "cloud-s3") {
588+
decode(t.s3, bl);
589+
}
590+
} else if (struct_v >= 3) {
591+
if (tier_type == "cloud-s3") {
592+
decode(t.s3, bl);
593+
}
580594
decode(allow_read_through, bl);
581595
decode(read_through_restore_days, bl);
582-
}
583-
if (tier_type == "cloud-s3") {
584-
decode(t.s3, bl);
585596
}
586597
DECODE_FINISH(bl);
587598
}

0 commit comments

Comments
 (0)