Skip to content

Commit 16e04f5

Browse files
authored
Merge pull request ceph#61540 from idryomov/wip-69679
mon/OSDMonitor: relax cap enforcement for unmanaged snapshots Reviewed-by: Samuel Just <[email protected]> Reviewed-by: Radoslaw Zarzynski <[email protected]>
2 parents 0e4a0ee + d99367e commit 16e04f5

File tree

3 files changed

+45
-6
lines changed

3 files changed

+45
-6
lines changed

qa/workunits/rbd/permissions.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,13 @@ create_users() {
4949
ceph auth get-or-create client.snap_none mon 'allow r' >> $KEYRING
5050
ceph auth get-or-create client.snap_all mon 'allow r' osd 'allow w' >> $KEYRING
5151
ceph auth get-or-create client.snap_pool mon 'allow r' osd 'allow w pool=images' >> $KEYRING
52+
ceph auth get-or-create client.snap_pool_namespace mon 'allow r' osd 'allow w pool=images namespace=foo' >> $KEYRING
53+
ceph auth get-or-create client.snap_namespace mon 'allow r' osd 'allow w namespace=foo' >> $KEYRING
54+
ceph auth get-or-create client.snap_tag mon 'allow r' osd 'allow w tag fooapp *=*' >> $KEYRING
5255
ceph auth get-or-create client.snap_profile_all mon 'allow r' osd 'profile rbd' >> $KEYRING
5356
ceph auth get-or-create client.snap_profile_pool mon 'allow r' osd 'profile rbd pool=images' >> $KEYRING
57+
ceph auth get-or-create client.snap_profile_pool_namespace mon 'allow r' osd 'profile rbd pool=images namespace=foo' >> $KEYRING
58+
ceph auth get-or-create client.snap_profile_namespace mon 'allow r' osd 'profile rbd namespace=foo' >> $KEYRING
5459

5560
ceph auth get-or-create client.mon_write mon 'allow *' >> $KEYRING
5661
}
@@ -208,12 +213,27 @@ test_remove_self_managed_snapshots() {
208213
create_self_managed_snapshot snap_pool images
209214
expect 1 create_self_managed_snapshot snap_pool volumes
210215

216+
create_self_managed_snapshot snap_pool_namespace images
217+
expect 1 create_self_managed_snapshot snap_pool_namespace volumes
218+
219+
create_self_managed_snapshot snap_namespace images
220+
create_self_managed_snapshot snap_namespace volumes
221+
222+
expect 1 create_self_managed_snapshot snap_tag images
223+
expect 1 create_self_managed_snapshot snap_tag volumes
224+
211225
create_self_managed_snapshot snap_profile_all images
212226
create_self_managed_snapshot snap_profile_all volumes
213227

214228
create_self_managed_snapshot snap_profile_pool images
215229
expect 1 create_self_managed_snapshot snap_profile_pool volumes
216230

231+
create_self_managed_snapshot snap_profile_pool_namespace images
232+
expect 1 create_self_managed_snapshot snap_profile_pool_namespace volumes
233+
234+
create_self_managed_snapshot snap_profile_namespace images
235+
create_self_managed_snapshot snap_profile_namespace volumes
236+
217237
# Ensure users cannot delete self-managed snapshots w/o permissions
218238
expect 1 remove_self_managed_snapshot snap_none images
219239
expect 1 remove_self_managed_snapshot snap_none volumes
@@ -224,11 +244,26 @@ test_remove_self_managed_snapshots() {
224244
remove_self_managed_snapshot snap_pool images
225245
expect 1 remove_self_managed_snapshot snap_pool volumes
226246

247+
remove_self_managed_snapshot snap_pool_namespace images
248+
expect 1 remove_self_managed_snapshot snap_pool_namespace volumes
249+
250+
remove_self_managed_snapshot snap_namespace images
251+
remove_self_managed_snapshot snap_namespace volumes
252+
253+
expect 1 remove_self_managed_snapshot snap_tag images
254+
expect 1 remove_self_managed_snapshot snap_tag volumes
255+
227256
remove_self_managed_snapshot snap_profile_all images
228257
remove_self_managed_snapshot snap_profile_all volumes
229258

230259
remove_self_managed_snapshot snap_profile_pool images
231260
expect 1 remove_self_managed_snapshot snap_profile_pool volumes
261+
262+
remove_self_managed_snapshot snap_profile_pool_namespace images
263+
expect 1 remove_self_managed_snapshot snap_profile_pool_namespace volumes
264+
265+
remove_self_managed_snapshot snap_profile_namespace images
266+
remove_self_managed_snapshot snap_profile_namespace volumes
232267
}
233268

234269
test_rbd_support() {

src/mon/OSDMonitor.cc

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,10 +270,14 @@ bool is_osd_writable(const OSDCapGrant& grant, const std::string* pool_name) {
270270
auto& match = grant.match;
271271
if (match.is_match_all()) {
272272
return true;
273-
} else if (pool_name != nullptr &&
274-
!match.pool_namespace.pool_name.empty() &&
275-
match.pool_namespace.pool_name == *pool_name) {
276-
return true;
273+
} else if (pool_name != nullptr) {
274+
if (!match.pool_namespace.pool_name.empty()) {
275+
if (match.pool_namespace.pool_name == *pool_name) {
276+
return true;
277+
}
278+
} else if (match.pool_tag.is_match_all()) {
279+
return true;
280+
}
277281
}
278282
}
279283
return false;

src/osd/OSDCap.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ struct OSDCapParser : qi::grammar<Iterator, OSDCap()>
445445
>> (lit('=') | spaces)
446446
>> estr >> -char_('*'));
447447

448-
// match := [pool[=]<poolname> [namespace[=]<namespace>]] [object_prefix <prefix>]
448+
// match := [pool[=]<poolname>] [namespace[=]<namespace>] [object_prefix <prefix>]
449449
object_prefix %= -(spaces >> lit("object_prefix") >> spaces >> str);
450450
pooltag %= (spaces >> lit("tag")
451451
>> spaces >> str // application
@@ -478,7 +478,7 @@ struct OSDCapParser : qi::grammar<Iterator, OSDCap()>
478478
(rwxa) [_val = phoenix::construct<OSDCapSpec>(_1)] |
479479
(class_name >> method_name) [_val = phoenix::construct<OSDCapSpec>(_1, _2)]);
480480

481-
// profile := profile <name> [pool[=]<pool> [namespace[=]<namespace>]]
481+
// profile := profile <name> [pool[=]<pool>] [namespace[=]<namespace>]
482482
profile_name %= (lit("profile") >> (lit('=') | spaces) >> str);
483483
profile = (
484484
(profile_name >> pool_name >> nspace) [_val = phoenix::construct<OSDCapProfile>(_1, _2, _3)] |

0 commit comments

Comments
 (0)