From: Casey Bodley Date: Tue, 3 Oct 2023 18:12:35 +0000 (-0400) Subject: rgw: add free function rgw::get_zonegroup_endpoint() X-Git-Tag: v19.0.0~122^2~7 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=d2756f1509c79c992d29c8157584bea90d2d900a;p=ceph.git rgw: add free function rgw::get_zonegroup_endpoint() Signed-off-by: Casey Bodley --- diff --git a/src/rgw/driver/rados/rgw_zone.h b/src/rgw/driver/rados/rgw_zone.h index 140678fcdce5a..6d55fd52c5758 100644 --- a/src/rgw/driver/rados/rgw_zone.h +++ b/src/rgw/driver/rados/rgw_zone.h @@ -885,6 +885,9 @@ int set_default_zonegroup(const DoutPrefixProvider* dpp, optional_yield y, sal::ConfigStore* cfgstore, const RGWZoneGroup& info, bool exclusive = false); +/// Return an endpoint from the zonegroup or its master zone. +std::string get_zonegroup_endpoint(const RGWZoneGroup& info); + /// Add a zone to the zonegroup, or update an existing zone entry. int add_zone_to_group(const DoutPrefixProvider* dpp, RGWZoneGroup& zonegroup, diff --git a/src/rgw/rgw_zone.cc b/src/rgw/rgw_zone.cc index 784c9c53fdc60..f41d987ec549a 100644 --- a/src/rgw/rgw_zone.cc +++ b/src/rgw/rgw_zone.cc @@ -1268,6 +1268,19 @@ int init_zone_pool_names(const DoutPrefixProvider *dpp, optional_yield y, return 0; } +std::string get_zonegroup_endpoint(const RGWZoneGroup& info) +{ + if (!info.endpoints.empty()) { + return info.endpoints.front(); + } + // use zonegroup's master zone endpoints + auto z = info.zones.find(info.master_zone); + if (z != info.zones.end() && !z->second.endpoints.empty()) { + return z->second.endpoints.front(); + } + return ""; +} + int add_zone_to_group(const DoutPrefixProvider* dpp, RGWZoneGroup& zonegroup, const RGWZoneParams& zone_params, const bool *pis_master, const bool *pread_only,