New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mgr/dashboard: Add Pool-create to the backend #20865
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I wonder if it would make sense to separate the developer page functionality into a separate PR, though.
24e5b91
to
59f02c7
Compare
59f02c7
to
8f220c8
Compare
8f220c8
to
6a1ee39
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please split the pool create
commit in two, so that the args_from_json fix is done in a separate commit.
def create(self, pool, pg_num, pool_type, erasure_code_profile=None, cache_mode=None, | ||
tier_of=None, read_tier=None, flags=None, compression_required_ratio=None, | ||
application_metadata=None, crush_rule=None, rule_name=None, **kwargs): | ||
ecp = erasure_code_profile if erasure_code_profile else None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need this line, if the default value of erasure_code_profile
is already None
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also catches empty strings
CephService.send_command('mon', 'osd pool set', pool=pool, var='crush_rule', | ||
val=rule_name) | ||
for key, value in kwargs.items(): | ||
if type == 'replicated' and key not in \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is no type
variable declared in this method. I believe this must be evaluating to the builtin type
function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.
if type == 'replicated' and key not in \ | ||
['name', 'erasure_code_profile_id'] and value is not None: | ||
CephService.send_command('mon', 'osd pool set', pool=pool, var=key, val=value) | ||
elif self.type == 'erasure' and key not in ['name', 'size', 'min_size'] \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see anywhere in the Pool
class the type
instance attribute being assigned. I guess what you want to use here is pool_type
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.
for key, value in kwargs.items(): | ||
if type == 'replicated' and key not in \ | ||
['name', 'erasure_code_profile_id'] and value is not None: | ||
CephService.send_command('mon', 'osd pool set', pool=pool, var=key, val=value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this code a bit of dangerous? basically you are calling osd pool set
for unknown (key, value) pairs that come from kwargs
without any validation.
Since, the frontend is the consumer of this API we are in controll of all things that come inside the request JSON, therefore we should validate them in the backend.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have validation in C++ and I'm trusting the C++ validation. And if something is not properly validated, I'd favor fixing the C++ validation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I guess this is part of a more generic problem of handling the errors from Ceph library calls, which we still haven't tackled properly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed. let's tackle this after this PR.
var='compression_required_ratio', | ||
val=str(compression_required_ratio)) | ||
if application_metadata: | ||
for app in set(json.loads(application_metadata)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we parsing the application_metadata
variable? shouldn't this variable already be an array of strings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.
6a1ee39
to
243fdd1
Compare
4913bd0
to
fc9d785
Compare
fc9d785
to
a5910d0
Compare
done. |
@sebastian-philipp I found some problems while testing in my local environment. First is because of http://tracker.ceph.com/issues/23345 , and I applied this patch to overcome the issue:
The second issue is something that was already broken (not introduced in this PR) but only now is exposed when running
Can you add each patch as a single commit to this PR? |
@sebastian-philipp forget about the first patch on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
jenkins retest this please |
@sebastian-philipp "make check" failed, maybe you should rebase the PR on top of master and try "make check" again. |
* `CephService.send_command` is much easier to use. * Refactored `CephFSClients.get` and `Dashboard.load_bufer` Signed-off-by: Sebastian Wagner <sebastian.wagner@suse.com>
It now allows any keyword arguments. This is needed for ECP and Pool creation. Signed-off-by: Sebastian Wagner <sebastian.wagner@suse.com>
Also: * Added tests. * Renamed `DashboardTest` to `PoolTest`. * Added `delete()`. Signed-off-by: Sebastian Wagner <sebastian.wagner@suse.com>
…dialog Signed-off-by: Sebastian Wagner <sebastian.wagner@suse.com>
…name Signed-off-by: Sebastian Wagner <sebastian.wagner@suse.com>
Don't fall through silently. Signed-off-by: Sebastian Wagner <sebastian.wagner@suse.com>
Signed-off-by: Sebastian Wagner <sebastian.wagner@suse.com>
3e2365c
to
cbee371
Compare
@rjfd rebased, but now I'm running into #21004 (comment) |
Requires #20863Local testing is affected by http://tracker.ceph.com/issues/23345
Also:
@RESTController.args_from_json
send_command
into single method …DashboardTestCase._request