mgr/cephadm: rgw update period after realm, zone creation#36496
Merged
sebastian-philipp merged 1 commit intoceph:masterfrom Aug 21, 2020
Merged
mgr/cephadm: rgw update period after realm, zone creation#36496sebastian-philipp merged 1 commit intoceph:masterfrom
sebastian-philipp merged 1 commit intoceph:masterfrom
Conversation
5ef8b47 to
0ed0952
Compare
Contributor
|
@theanalyst or @cbodley can you have a quick look? |
Contributor
|
Hm. we have a 100loc monster already here. would it make sense to ease reviewing by refactoring this a bit? |
0ed0952 to
b4d32ce
Compare
Author
|
I broke this up into 2 commits because I was doing two things. |
sebastian-philipp
suggested changes
Aug 18, 2020
Contributor
There was a problem hiding this comment.
gm. I had to refactor this thing in order to review it:
def create_realm_zonegroup_zone(self, spec: RGWSpec, rgw_id: str):
if utils.get_cluster_health(self.mgr) != 'HEALTH_OK':
raise OrchestratorError('Health not ok, will try agin when health ok')
#get keyring needed to run rados commands and strip out just the keyring
keyring = self.get_keyring(rgw_id).split('key = ',1)[1].rstrip()
# We can call radosgw-admin within the container, cause cephadm gives the MGR the required keyring permissions
def get_realms() -> List[str]:
cmd = ['radosgw-admin',
'--key=%s'%keyring,
'--user', 'rgw.%s'%rgw_id,
'realm', 'list',
'--format=json']
result = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out = result.stdout
if not out:
return []
try:
j = json.loads(realms)
return j.get('realms', [])
except Exception as e:
raise OrchestratorError('failed to parse realm info')
def create_realm():
cmd = ['radosgw-admin',
'--key=%s'%keyring,
'--user', 'rgw.%s'%rgw_id,
'realm', 'create',
'--rgw-realm=%s'%spec.rgw_realm,
'--default']
result = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
self.mgr.log.info('created realm: %s'%spec.rgw_realm)
def get_zonegroups() -> List[str]:
# get zonegroup
cmd = ['radosgw-admin',
'--key=%s'%keyring,
'--user', 'rgw.%s'%rgw_id,
'zonegroup', 'list',
'--format=json']
result = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out = result.stdout
if not out:
return []
try:
j = json.loads(result.stdout)
return j.get('zonegroups', [])
except Exception as e:
raise OrchestratorError('failed to parse zonegroup info')
def create_zonegroup():
cmd = ['radosgw-admin',
'--key=%s'%keyring,
'--user', 'rgw.%s'%rgw_id,
'zonegroup', 'create',
'--rgw-zonegroup=default',
'--master', '--default']
result = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
self.mgr.log.info('created zonegroup: default')
# create default zonegroup (will be used below if zone needs to be created)
def create_zonegroup_if_requuired():
zonegroups = get_zonegroups()
if 'default' not in zonegroups:
create_zonegroup()
def get_zones() -> List[str]:
cmd = ['radosgw-admin',
'--key=%s'%keyring,
'--user', 'rgw.%s'%rgw_id,
'zone', 'list',
'--format=json']
result = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out = result.stdout
if not out:
return []
try:
j = json.loads(result.stdout)
return j.get('zones', [])
except Exception as e:
raise OrchestratorError('failed to parse zone info')
def create_zone():
cmd = ['radosgw-admin',
'--key=%s'%keyring,
'--user', 'rgw.%s'%rgw_id,
'zone', 'create',
'--rgw-zonegroup=default',
'--rgw-zone=%s'%spec.rgw_zone,
'--master', '--default']
result = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
self.mgr.log.info('created zone: %s'%spec.rgw_zone)
changes = False
realms = get_realms()
if spec.rgw_realm not in realms:
create_realm()
changes = True
zones = get_zones()
if spec.rgw_zone not in zones:
create_zonegroup_if_requuired()
create_zone()
changes = True
# update period if changes were made
if changes:
cmd = ['radosgw-admin',
'--key=%s'%keyring,
'--user', 'rgw.%s'%rgw_id,
'period', 'update',
'--rgw-realm=%s'%spec.rgw_realm,
'--commit']
result = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)this might be more readable?
b4d32ce to
0cc2aea
Compare
Signed-off-by: Daniel-Pivonka <dpivonka@redhat.com>
0cc2aea to
70b11a1
Compare
Contributor
sebastian-philipp
approved these changes
Aug 21, 2020
trociny
added a commit
to trociny/sesdev
that referenced
this pull request
Mar 12, 2021
This command was added to the upstream doc in this PR [1], and it fixes the issue with creating a rgw bucket via dashboard (InvalidLocationConstraint error). [1] ceph/ceph#36496 Signed-off-by: Mykola Golub <mgolub@suse.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes: https://tracker.ceph.com/issues/44926
Signed-off-by: Daniel-Pivonka dpivonka@redhat.com