]>
git.proxmox.com Git - ceph.git/blob - ceph/qa/tasks/radosgw_agent.py
2 Run rados gateway agent in test mode
8 from teuthology
.orchestra
import run
9 from teuthology
import misc
as teuthology
10 import util
.rgw
as rgw_utils
12 log
= logging
.getLogger(__name__
)
14 def run_radosgw_agent(ctx
, config
):
16 Run a single radosgw-agent. See task() for config format.
19 for (client
, cconf
) in config
.items():
20 # don't process entries that are not clients
21 log
.debug("client is %r", client
)
22 if not 'client.' in client
:
23 log
.debug('key {data} does not contain \'client.\', moving on'.format(
27 src_client
= cconf
['src']
28 dest_client
= cconf
['dest']
30 src_zone
= rgw_utils
.zone_for_client(ctx
, src_client
)
31 dest_zone
= rgw_utils
.zone_for_client(ctx
, dest_client
)
33 log
.info("source is %s", src_zone
)
34 log
.info("dest is %s", dest_zone
)
36 testdir
= teuthology
.get_testdir(ctx
)
37 (remote
,) = ctx
.cluster
.only(client
).remotes
.keys()
38 # figure out which branch to pull from
39 branch
= cconf
.get('force-branch', None)
41 branch
= cconf
.get('branch', 'master')
42 sha1
= cconf
.get('sha1')
45 'cd', testdir
, run
.Raw('&&'),
48 # 'https://github.com/ceph/radosgw-agent.git',
49 'git://git.ceph.com/radosgw-agent.git',
50 'radosgw-agent.{client}'.format(client
=client
),
56 'cd', testdir
, run
.Raw('&&'),
58 'git', 'reset', '--hard', sha1
,
63 'cd', testdir
, run
.Raw('&&'),
64 'cd', 'radosgw-agent.{client}'.format(client
=client
),
70 src_host
, src_port
= rgw_utils
.get_zone_host_and_port(ctx
, src_client
,
72 dest_host
, dest_port
= rgw_utils
.get_zone_host_and_port(ctx
, dest_client
,
74 src_access
, src_secret
= rgw_utils
.get_zone_system_keys(ctx
, src_client
,
76 dest_access
, dest_secret
= rgw_utils
.get_zone_system_keys(ctx
, dest_client
,
78 sync_scope
= cconf
.get('sync-scope', None)
79 port
= cconf
.get('port', 8000)
80 daemon_name
= '{host}.{port}.syncdaemon'.format(host
=remote
.name
, port
=port
)
84 '{tdir}/radosgw-agent.{client}/radosgw-agent'.format(tdir
=testdir
,
87 '--src-access-key', src_access
,
88 '--src-secret-key', src_secret
,
89 '--source', "http://{addr}:{port}".format(addr
=src_host
, port
=src_port
),
90 '--dest-access-key', dest_access
,
91 '--dest-secret-key', dest_secret
,
92 '--max-entries', str(cconf
.get('max-entries', 1000)),
93 '--log-file', '{tdir}/archive/rgw_sync_agent.{client}.log'.format(
96 '--object-sync-timeout', '30',
99 if cconf
.get('metadata-only', False):
100 in_args
.append('--metadata-only')
102 # the test server and full/incremental flags are mutually exclusive
103 if sync_scope
is None:
104 in_args
.append('--test-server-host')
105 in_args
.append('0.0.0.0')
106 in_args
.append('--test-server-port')
107 in_args
.append(str(port
))
108 log
.debug('Starting a sync test server on {client}'.format(client
=client
))
109 # Stash the radosgw-agent server / port # for use by subsequent tasks
110 ctx
.radosgw_agent
.endpoint
= (client
, str(port
))
112 in_args
.append('--sync-scope')
113 in_args
.append(sync_scope
)
114 log
.debug('Starting a {scope} sync on {client}'.format(scope
=sync_scope
,client
=client
))
116 # positional arg for destination must come last
117 in_args
.append("http://{addr}:{port}".format(addr
=dest_host
,
120 return_list
.append((client
, remote
.run(
124 logger
=log
.getChild(daemon_name
),
129 @contextlib.contextmanager
130 def task(ctx
, config
):
132 Run radosgw-agents in test mode.
134 Configuration is clients to run the agents on, with settings for
135 source client, destination client, and port to listen on. Binds
136 to 0.0.0.0. Port defaults to 8000. This must be run on clients
137 that have the correct zone root pools and rgw zone set in
138 ceph.conf, or the task cannot read the region information from the
141 By default, this task will start an HTTP server that will trigger full
142 or incremental syncs based on requests made to it.
143 Alternatively, a single full sync can be triggered by
144 specifying 'sync-scope: full' or a loop of incremental syncs can be triggered
145 by specifying 'sync-scope: incremental' (the loop will sleep
146 '--incremental-sync-delay' seconds between each sync, default is 30 seconds).
148 By default, both data and metadata are synced. To only sync
149 metadata, for example because you want to sync between regions,
150 set metadata-only: true.
159 rgw zone root pool = .root.pool
162 rgw zone root pool = .root.pool2
163 - rgw: # region configuration omitted for brevity
166 branch: wip-next-feature-branch
171 # port: 8000 (default)
177 assert isinstance(config
, dict), 'rgw_sync_agent requires a dictionary config'
178 log
.debug("config is %s", config
)
180 overrides
= ctx
.config
.get('overrides', {})
181 # merge each client section, but only if it exists in config since there isn't
182 # a sensible default action for this task
183 for client
in config
.iterkeys():
185 log
.debug('config[{client}]: {data}'.format(client
=client
, data
=config
[client
]))
186 teuthology
.deep_merge(config
[client
], overrides
.get('radosgw-agent', {}))
188 ctx
.radosgw_agent
= argparse
.Namespace()
189 ctx
.radosgw_agent
.config
= config
191 procs
= run_radosgw_agent(ctx
, config
)
193 ctx
.radosgw_agent
.procs
= procs
198 testdir
= teuthology
.get_testdir(ctx
)
200 for client
, proc
in procs
:
201 log
.info("shutting down sync agent on %s", client
)
205 for client
, proc
in procs
:
206 ctx
.cluster
.only(client
).run(
209 '{tdir}/radosgw-agent.{client}'.format(tdir
=testdir
,