Skip to content

Commit d7353ad

Browse files
authored
Merge pull request ceph#56005 from cbodley/wip-qa-rgw-realm
qa/rgw: teach rgw.py to create an optional realm Reviewed-by: Yuval Lifshitz <[email protected]>
2 parents 1c34945 + 7ef94cd commit d7353ad

File tree

2 files changed

+72
-17
lines changed

2 files changed

+72
-17
lines changed

qa/suites/rgw/notifications/overrides.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,5 @@ overrides:
99
rgw crypt s3 kms encryption keys: testkey-1=YmluCmJvb3N0CmJvb3N0LWJ1aWxkCmNlcGguY29uZgo= testkey-2=aWIKTWFrZWZpbGUKbWFuCm91dApzcmMKVGVzdGluZwo=
1010
rgw crypt require ssl: false
1111
rgw:
12-
storage classes: LUKEWARM, FROZEN
13-
s3tests:
12+
realm: default
1413
storage classes: LUKEWARM, FROZEN

qa/tasks/rgw.py

Lines changed: 71 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,43 @@ def assign_endpoints(ctx, config, default_cert):
300300

301301
return role_endpoints
302302

303+
@contextlib.contextmanager
304+
def create_realm(ctx, clients):
305+
if ctx.rgw.realm:
306+
log.info('Creating realm {}'.format(ctx.rgw.realm))
307+
308+
client = next(iter(clients))
309+
(remote,) = ctx.cluster.only(client).remotes.keys()
310+
cluster_name, daemon_type, client_id = teuthology.split_role(client)
311+
312+
# create the realm/zonegroup/zone and set as default
313+
rgwadmin(ctx, client,
314+
cmd=['realm', 'create',
315+
'--rgw-realm', ctx.rgw.realm,
316+
'--default'],
317+
check_status=True)
318+
rgwadmin(ctx, client,
319+
cmd=['zonegroup', 'create',
320+
'--rgw-realm', ctx.rgw.realm,
321+
'--rgw-zonegroup', ctx.rgw.zonegroup,
322+
'--master', '--default'],
323+
check_status=True)
324+
rgwadmin(ctx, client,
325+
cmd=['zone', 'create',
326+
'--rgw-realm', ctx.rgw.realm,
327+
'--rgw-zonegroup', ctx.rgw.zonegroup,
328+
'--rgw-zone', ctx.rgw.zone,
329+
'--master', '--default'],
330+
check_status=True)
331+
332+
rgwadmin(ctx, client,
333+
cmd=['period', 'update', '--commit',
334+
'--rgw-realm', ctx.rgw.realm,
335+
'--rgw-zonegroup', ctx.rgw.zonegroup,
336+
'--rgw-zone', ctx.rgw.zone],
337+
check_status=True)
338+
yield
339+
303340
@contextlib.contextmanager
304341
def create_pools(ctx, clients):
305342
"""Create replicated or erasure coded data pools for rgw."""
@@ -308,7 +345,7 @@ def create_pools(ctx, clients):
308345
for client in clients:
309346
log.debug("Obtaining remote for client {}".format(client))
310347
(remote,) = ctx.cluster.only(client).remotes.keys()
311-
data_pool = 'default.rgw.buckets.data'
348+
data_pool = '{}.rgw.buckets.data'.format(ctx.rgw.zone)
312349
cluster_name, daemon_type, client_id = teuthology.split_role(client)
313350

314351
if ctx.rgw.ec_data_pool:
@@ -317,7 +354,7 @@ def create_pools(ctx, clients):
317354
else:
318355
create_replicated_pool(remote, data_pool, ctx.rgw.data_pool_pg_size, cluster_name, 'rgw')
319356

320-
index_pool = 'default.rgw.buckets.index'
357+
index_pool = '{}.rgw.buckets.index'.format(ctx.rgw.zone)
321358
create_replicated_pool(remote, index_pool, ctx.rgw.index_pool_pg_size, cluster_name, 'rgw')
322359

323360
if ctx.rgw.cache_pools:
@@ -331,12 +368,13 @@ def configure_compression(ctx, clients, compression):
331368
""" set a compression type in the default zone placement """
332369
log.info('Configuring compression type = %s', compression)
333370
for client in clients:
334-
# XXX: the 'default' zone and zonegroup aren't created until we run RGWRados::init_complete().
335-
# issue a 'radosgw-admin user list' command to trigger this
336-
rgwadmin(ctx, client, cmd=['user', 'list'], check_status=True)
371+
if not ctx.rgw.realm:
372+
# XXX: the 'default' zone and zonegroup aren't created until we run RGWRados::init_complete().
373+
# issue a 'radosgw-admin user list' command to trigger this
374+
rgwadmin(ctx, client, cmd=['user', 'list'], check_status=True)
337375

338376
rgwadmin(ctx, client,
339-
cmd=['zone', 'placement', 'modify', '--rgw-zone', 'default',
377+
cmd=['zone', 'placement', 'modify', '--rgw-zone', ctx.rgw.zone,
340378
'--placement-id', 'default-placement',
341379
'--compression', compression],
342380
check_status=True)
@@ -345,12 +383,13 @@ def configure_compression(ctx, clients, compression):
345383
@contextlib.contextmanager
346384
def disable_inline_data(ctx, clients):
347385
for client in clients:
348-
# XXX: the 'default' zone and zonegroup aren't created until we run RGWRados::init_complete().
349-
# issue a 'radosgw-admin user list' command to trigger this
350-
rgwadmin(ctx, client, cmd=['user', 'list'], check_status=True)
386+
if not ctx.rgw.realm:
387+
# XXX: the 'default' zone and zonegroup aren't created until we run RGWRados::init_complete().
388+
# issue a 'radosgw-admin user list' command to trigger this
389+
rgwadmin(ctx, client, cmd=['user', 'list'], check_status=True)
351390

352391
rgwadmin(ctx, client,
353-
cmd=['zone', 'placement', 'modify', '--rgw-zone', 'default',
392+
cmd=['zone', 'placement', 'modify', '--rgw-zone', ctx.rgw.zone,
354393
'--placement-id', 'default-placement',
355394
'--placement-inline-data', 'false'],
356395
check_status=True)
@@ -375,21 +414,22 @@ def configure_storage_classes(ctx, clients, storage_classes):
375414
sc = [s.strip() for s in storage_classes.split(',')]
376415

377416
for client in clients:
378-
# XXX: the 'default' zone and zonegroup aren't created until we run RGWRados::init_complete().
379-
# issue a 'radosgw-admin user list' command to trigger this
380-
rgwadmin(ctx, client, cmd=['user', 'list'], check_status=True)
417+
if not ctx.rgw.realm:
418+
# XXX: the 'default' zone and zonegroup aren't created until we run RGWRados::init_complete().
419+
# issue a 'radosgw-admin user list' command to trigger this
420+
rgwadmin(ctx, client, cmd=['user', 'list'], check_status=True)
381421

382422
for storage_class in sc:
383423
log.info('Configuring storage class type = %s', storage_class)
384424
rgwadmin(ctx, client,
385425
cmd=['zonegroup', 'placement', 'add',
386-
'--rgw-zone', 'default',
426+
'--rgw-zone', ctx.rgw.zone,
387427
'--placement-id', 'default-placement',
388428
'--storage-class', storage_class],
389429
check_status=True)
390430
rgwadmin(ctx, client,
391431
cmd=['zone', 'placement', 'add',
392-
'--rgw-zone', 'default',
432+
'--rgw-zone', ctx.rgw.zone,
393433
'--placement-id', 'default-placement',
394434
'--storage-class', storage_class,
395435
'--data-pool', 'default.rgw.buckets.data.' + storage_class.lower()],
@@ -429,6 +469,15 @@ def task(ctx, config):
429469
client.3:
430470
valgrind: [--tool=memcheck]
431471
472+
To create a custom realm, zonegroup and zone:
473+
474+
tasks:
475+
- ceph:
476+
- rgw:
477+
realm: MyRealm
478+
zonegroup: MyZoneGroup
479+
zone: MyZone
480+
432481
To configure data or index pool pg_size:
433482
434483
overrides:
@@ -463,6 +512,9 @@ def task(ctx, config):
463512
ctx.rgw.index_pool_pg_size = config.pop('index_pool_pg_size', 64)
464513
ctx.rgw.datacache = bool(config.pop('datacache', False))
465514
ctx.rgw.datacache_path = config.pop('datacache_path', None)
515+
ctx.rgw.realm = config.pop('realm', None)
516+
ctx.rgw.zonegroup = config.pop('zonegroup', 'default')
517+
ctx.rgw.zone = config.pop('zone', 'default')
466518
ctx.rgw.config = config
467519

468520
log.debug("config is {}".format(config))
@@ -473,6 +525,10 @@ def task(ctx, config):
473525
subtasks = [
474526
lambda: create_pools(ctx=ctx, clients=clients),
475527
]
528+
if ctx.rgw.realm:
529+
subtasks.extend([
530+
lambda: create_realm(ctx=ctx, clients=clients),
531+
])
476532
if ctx.rgw.compression_type:
477533
subtasks.extend([
478534
lambda: configure_compression(ctx=ctx, clients=clients,

0 commit comments

Comments
 (0)