Skip to content
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

Merged
merged 7 commits into from Mar 26, 2018

Conversation

sebastian-philipp
Copy link
Contributor

@sebastian-philipp sebastian-philipp commented Mar 13, 2018

Requires #20863

Local testing is affected by http://tracker.ceph.com/issues/23345

Also:

  • Add API test
  • Fixed @RESTController.args_from_json
  • Refactor send_command into single method …
  • Minor tweak to DashboardTestCase._request

Copy link
Contributor

@LenzGr LenzGr left a 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.

@sebastian-philipp sebastian-philipp force-pushed the dashboard_v2_pool-create branch 3 times, most recently from 24e5b91 to 59f02c7 Compare March 13, 2018 15:46
@sebastian-philipp sebastian-philipp changed the title [WIP] mgr/dashboard_v2: Add create() to Pool controller mgr/dashboard_v2: Add create() to Pool controller Mar 13, 2018
Copy link
Contributor

@rjfd rjfd left a 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
Copy link
Contributor

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?

Copy link
Contributor Author

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 \
Copy link
Contributor

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.

Copy link
Contributor Author

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'] \
Copy link
Contributor

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.

Copy link
Contributor Author

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)
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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)):
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

@LenzGr LenzGr changed the title mgr/dashboard_v2: Add create() to Pool controller mgr/dashboard: Add create() to Pool controller Mar 16, 2018
@sebastian-philipp sebastian-philipp changed the title mgr/dashboard: Add create() to Pool controller [WIP] mgr/dashboard: Add create() to Pool controller Mar 20, 2018
@sebastian-philipp sebastian-philipp force-pushed the dashboard_v2_pool-create branch 2 times, most recently from 4913bd0 to fc9d785 Compare March 21, 2018 13:58
@sebastian-philipp sebastian-philipp changed the title [WIP] mgr/dashboard: Add create() to Pool controller [WIP] mgr/dashboard: Add Pool-create to the backend Mar 21, 2018
@sebastian-philipp
Copy link
Contributor Author

please split the pool create commit in two, so that the args_from_json fix is done in a separate commit.

done.

@sebastian-philipp sebastian-philipp changed the title [WIP] mgr/dashboard: Add Pool-create to the backend mgr/dashboard: Add Pool-create to the backend Mar 21, 2018
@rjfd
Copy link
Contributor

rjfd commented Mar 22, 2018

@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:

diff --git a/src/pybind/mgr/dashboard/run-backend-api-tests.sh b/src/pybind/mgr/dashboard/run-backend-api-tests.sh
index e7b78e9126..6bc4297d93 100755
--- a/src/pybind/mgr/dashboard/run-backend-api-tests.sh
+++ b/src/pybind/mgr/dashboard/run-backend-api-tests.sh
@@ -91,6 +91,7 @@ EOF
 
     MGR=2 RGW=1 ../src/vstart.sh -n -d
     sleep 10
+    ./bin/ceph config set mon osd_pool_default_erasure_code_profile "plugin=jerasure technique=reed_sol_van k=2 m=1 crush-failure-domain=osd"
     cd $CURR_DIR
 }

The second issue is something that was already broken (not introduced in this PR) but only now is exposed when running test_pool.py. I fixed the issue with the following patch:

diff --git a/qa/tasks/mgr/dashboard/test_auth.py b/qa/tasks/mgr/dashboard/test_auth.py
index b176dd041b..1c71687a4d 100644
--- a/qa/tasks/mgr/dashboard/test_auth.py
+++ b/qa/tasks/mgr/dashboard/test_auth.py
@@ -10,7 +10,6 @@ from .helper import DashboardTestCase
 class AuthTest(DashboardTestCase):
     def setUp(self):
         self.reset_session()
-        self._ceph_cmd(['dashboard', 'set-session-expire', '2'])
         self._ceph_cmd(['dashboard', 'set-login-credentials', 'admin', 'admin'])
 
     def test_a_set_login_credentials(self):
@@ -60,6 +59,7 @@ class AuthTest(DashboardTestCase):
         self.assertStatus(401)
 
     def test_session_expire(self):
+        self._ceph_cmd(['dashboard', 'set-session-expire', '2'])
         self._post("/api/auth", {'username': 'admin', 'password': 'admin'})
         self.assertStatus(201)
         self._get("/api/host")
@@ -67,6 +67,7 @@ class AuthTest(DashboardTestCase):
         time.sleep(3)
         self._get("/api/host")
         self.assertStatus(401)
+        self._ceph_cmd(['dashboard', 'set-session-expire', '1200'])
 
     def test_unauthorized(self):
         self._get("/api/host")

Can you add each patch as a single commit to this PR?

@sebastian-philipp
Copy link
Contributor Author

@rjfd thanks for the patches! Regarding the run-backend-api-tests.sh issue: @jecluis Do you mind, if we add this workaround for now?

@rjfd
Copy link
Contributor

rjfd commented Mar 22, 2018

@sebastian-philipp forget about the first patch on run-backend-api-tests.sh script since that problem is now fixed in master due to the merge of this PR #20986

@sebastian-philipp
Copy link
Contributor Author

@rjfd regarding the second patch: I've created a PR for that: #21021

Copy link
Contributor

@rjfd rjfd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@rjfd
Copy link
Contributor

rjfd commented Mar 23, 2018

jenkins retest this please

@rjfd
Copy link
Contributor

rjfd commented Mar 23, 2018

@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>
@sebastian-philipp
Copy link
Contributor Author

@rjfd rebased, but now I'm running into #21004 (comment)

@rjfd rjfd merged commit d5763de into ceph:master Mar 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants