@@ -43,77 +43,6 @@ void RGWDefaultZoneGroupInfo::decode_json(JSONObj *obj) {
4343 }
4444}
4545
46- int RGWZoneGroup::create_default (const DoutPrefixProvider *dpp, optional_yield y, bool old_format)
47- {
48- name = default_zonegroup_name;
49- api_name = default_zonegroup_name;
50- is_master = true ;
51-
52- RGWZoneGroupPlacementTarget placement_target;
53- placement_target.name = " default-placement" ;
54- placement_targets[placement_target.name ] = placement_target;
55- default_placement.name = " default-placement" ;
56-
57- RGWZoneParams zone_params (default_zone_name);
58-
59- int r = zone_params.init (dpp, cct, sysobj_svc, y, false );
60- if (r < 0 ) {
61- ldpp_dout (dpp, 0 ) << " create_default: error initializing zone params: " << cpp_strerror (-r) << dendl;
62- return r;
63- }
64-
65- r = zone_params.create_default (dpp, y);
66- if (r < 0 && r != -EEXIST) {
67- ldpp_dout (dpp, 0 ) << " create_default: error in create_default zone params: " << cpp_strerror (-r) << dendl;
68- return r;
69- } else if (r == -EEXIST) {
70- ldpp_dout (dpp, 10 ) << " zone_params::create_default() returned -EEXIST, we raced with another default zone_params creation" << dendl;
71- zone_params.clear_id ();
72- r = zone_params.init (dpp, cct, sysobj_svc, y);
73- if (r < 0 ) {
74- ldpp_dout (dpp, 0 ) << " create_default: error in init existing zone params: " << cpp_strerror (-r) << dendl;
75- return r;
76- }
77- ldpp_dout (dpp, 20 ) << " zone_params::create_default() " << zone_params.get_name () << " id " << zone_params.get_id ()
78- << dendl;
79- }
80-
81- RGWZone& default_zone = zones[zone_params.get_id ()];
82- default_zone.name = zone_params.get_name ();
83- default_zone.id = zone_params.get_id ();
84- master_zone = default_zone.id ;
85-
86- // initialize supported zone features
87- default_zone.supported_features .insert (rgw::zone_features::supported.begin (),
88- rgw::zone_features::supported.end ());
89- // enable default zonegroup features
90- enabled_features.insert (rgw::zone_features::enabled.begin (),
91- rgw::zone_features::enabled.end ());
92-
93- r = create (dpp, y);
94- if (r < 0 && r != -EEXIST) {
95- ldpp_dout (dpp, 0 ) << " error storing zone group info: " << cpp_strerror (-r) << dendl;
96- return r;
97- }
98-
99- if (r == -EEXIST) {
100- ldpp_dout (dpp, 10 ) << " create_default() returned -EEXIST, we raced with another zonegroup creation" << dendl;
101- id.clear ();
102- r = init (dpp, cct, sysobj_svc, y);
103- if (r < 0 ) {
104- return r;
105- }
106- }
107-
108- if (old_format) {
109- name = id;
110- }
111-
112- post_process_params (dpp, y);
113-
114- return 0 ;
115- }
116-
11746int RGWZoneGroup::equals (const string& other_zonegroup) const
11847{
11948 if (is_master && other_zonegroup.empty ())
@@ -122,168 +51,6 @@ int RGWZoneGroup::equals(const string& other_zonegroup) const
12251 return (id == other_zonegroup);
12352}
12453
125- int RGWZoneGroup::add_zone (const DoutPrefixProvider *dpp,
126- const RGWZoneParams& zone_params, bool *is_master, bool *read_only,
127- const list<string>& endpoints, const string *ptier_type,
128- bool *psync_from_all, list<string>& sync_from, list<string>& sync_from_rm,
129- string *predirect_zone, std::optional<int > bucket_index_max_shards,
130- RGWSyncModulesManager *sync_mgr,
131- const rgw::zone_features::set& enable_features,
132- const rgw::zone_features::set& disable_features,
133- optional_yield y)
134- {
135- auto & zone_id = zone_params.get_id ();
136- auto & zone_name = zone_params.get_name ();
137-
138- // check for duplicate zone name on insert
139- if (!zones.count (zone_id)) {
140- for (const auto & zone : zones) {
141- if (zone.second .name == zone_name) {
142- ldpp_dout (dpp, 0 ) << " ERROR: found existing zone name " << zone_name
143- << " (" << zone.first << " ) in zonegroup " << get_name () << dendl;
144- return -EEXIST;
145- }
146- }
147- }
148-
149- if (is_master) {
150- if (*is_master) {
151- if (!master_zone.empty () && master_zone != zone_id) {
152- ldpp_dout (dpp, 0 ) << " NOTICE: overriding master zone: " << master_zone << dendl;
153- }
154- master_zone = zone_id;
155- } else if (master_zone == zone_id) {
156- master_zone.clear ();
157- }
158- }
159-
160- RGWZone& zone = zones[zone_id];
161- zone.name = zone_name;
162- zone.id = zone_id;
163- if (!endpoints.empty ()) {
164- zone.endpoints = endpoints;
165- }
166- if (read_only) {
167- zone.read_only = *read_only;
168- }
169- if (ptier_type) {
170- zone.tier_type = *ptier_type;
171- if (!sync_mgr->get_module (*ptier_type, nullptr )) {
172- ldpp_dout (dpp, 0 ) << " ERROR: could not found sync module: " << *ptier_type
173- << " , valid sync modules: "
174- << sync_mgr->get_registered_module_names ()
175- << dendl;
176- return -ENOENT;
177- }
178- }
179-
180- if (psync_from_all) {
181- zone.sync_from_all = *psync_from_all;
182- }
183-
184- if (predirect_zone) {
185- zone.redirect_zone = *predirect_zone;
186- }
187-
188- if (bucket_index_max_shards) {
189- zone.bucket_index_max_shards = *bucket_index_max_shards;
190- }
191-
192- for (auto add : sync_from) {
193- zone.sync_from .insert (add);
194- }
195-
196- for (auto rm : sync_from_rm) {
197- zone.sync_from .erase (rm);
198- }
199-
200- zone.supported_features .insert (enable_features.begin (),
201- enable_features.end ());
202-
203- for (const auto & feature : disable_features) {
204- if (enabled_features.contains (feature)) {
205- lderr (cct) << " ERROR: Cannot disable zone feature \" " << feature
206- << " \" until it's been disabled in zonegroup " << name << dendl;
207- return -EINVAL;
208- }
209- auto i = zone.supported_features .find (feature);
210- if (i == zone.supported_features .end ()) {
211- ldout (cct, 1 ) << " WARNING: zone feature \" " << feature
212- << " \" was not enabled in zone " << zone.name << dendl;
213- continue ;
214- }
215- zone.supported_features .erase (i);
216- }
217-
218- post_process_params (dpp, y);
219-
220- return update (dpp,y);
221- }
222-
223-
224- int RGWZoneGroup::rename_zone (const DoutPrefixProvider *dpp,
225- const RGWZoneParams& zone_params,
226- optional_yield y)
227- {
228- RGWZone& zone = zones[zone_params.get_id ()];
229- zone.name = zone_params.get_name ();
230-
231- return update (dpp, y);
232- }
233-
234- void RGWZoneGroup::post_process_params (const DoutPrefixProvider *dpp, optional_yield y)
235- {
236- bool log_data = zones.size () > 1 ;
237-
238- if (master_zone.empty ()) {
239- auto iter = zones.begin ();
240- if (iter != zones.end ()) {
241- master_zone = iter->first ;
242- }
243- }
244-
245- for (auto & item : zones) {
246- RGWZone& zone = item.second ;
247- zone.log_data = log_data;
248-
249- RGWZoneParams zone_params (zone.id , zone.name );
250- int ret = zone_params.init (dpp, cct, sysobj_svc, y);
251- if (ret < 0 ) {
252- ldpp_dout (dpp, 0 ) << " WARNING: could not read zone params for zone id=" << zone.id << " name=" << zone.name << dendl;
253- continue ;
254- }
255-
256- for (auto & pitem : zone_params.placement_pools ) {
257- const string& placement_name = pitem.first ;
258- if (placement_targets.find (placement_name) == placement_targets.end ()) {
259- RGWZoneGroupPlacementTarget placement_target;
260- placement_target.name = placement_name;
261- placement_targets[placement_name] = placement_target;
262- }
263- }
264- }
265-
266- if (default_placement.empty () && !placement_targets.empty ()) {
267- default_placement.init (placement_targets.begin ()->first , RGW_STORAGE_CLASS_STANDARD);
268- }
269- }
270-
271- int RGWZoneGroup::remove_zone (const DoutPrefixProvider *dpp, const std::string& zone_id, optional_yield y)
272- {
273- auto iter = zones.find (zone_id);
274- if (iter == zones.end ()) {
275- ldpp_dout (dpp, 0 ) << " zone id " << zone_id << " is not a part of zonegroup "
276- << name << dendl;
277- return -ENOENT;
278- }
279-
280- zones.erase (iter);
281-
282- post_process_params (dpp, y);
283-
284- return update (dpp, y);
285- }
286-
28754void RGWDefaultSystemMetaObjInfo::dump (Formatter *f) const {
28855 encode_json (" default_id" , default_id, f);
28956}
0 commit comments