mon: create crush_ruleset_create_erasure helper

Move the code bloc verbatim, from "osd crush rule create-erasure" to the
new crush_ruleset_create_erasure() method helper. This step helps
separate the code changes from the code moving around unmodified.

Signed-off-by: Loic Dachary <loic@dachary.org>
mon: crush_ruleset_create_erasure reduce verbosity

Only add error message to the stream, not informative messages because
they depend on the caller context.

Signed-off-by: Loic Dachary <loic@dachary.org>
mon: crush_ruleset_create_erasure error codes

Replace goto reply with error return and meaningfull error codes.

Signed-off-by: Loic Dachary <loic@dachary.org>
mon: crush_ruleset_create_erasure set ruleset

Use get_rule_id() instead of rule_exists() to test the existence of a
ruleset and preserve the ruleset.

Signed-off-by: Loic Dachary <loic@dachary.org>
mon: crush_ruleset_create_erasure s/rule/err/

Avoid using rule instead of ruleset to help clarify the
terminology. Using err instead is also clearer in the context.

Signed-off-by: Loic Dachary <loic@dachary.org>
mon: crush_ruleset_create_erasure indent

Signed-off-by: Loic Dachary <loic@dachary.org>
mon: crush_ruleset_create_erasure s/_map//

Signed-off-by: Loic Dachary <loic@dachary.org>
mon: create-erasure uses crush_ruleset_create_erasure

Create the ruleset and branch depending on the result:

* If it succeeds, wait
* If it already exists and is pending (-EALREADY), wait
* If it already exists (-EEXIST), return immediately
* If it fails for other reasons, return immediately

Add an informative message when it succeeds.

Signed-off-by: Loic Dachary <loic@dachary.org>
mon: add pool name to prepare_pool_crush_ruleset

Signed-off-by: Loic Dachary <loic@dachary.org>
mon: pool create erasure implicit ruleset creation

If the crush_ruleset parameter is missing, set it to the pool name.

If the crush_ruleset parameter is set to a name that does not match any
of the existing rulesets, create one using the pool creation parameters.

If the ruleset exists and is in the pending map or if the ruleset was
just created (meaning it exists in the pending map), the
prepare_pool_crush_ruleset method returns EAGAIN so that the pool
creation message is retried after the pending map is proposed.

If the ruleset exists, it is used to initialize the newly created pool,
as before.

http://tracker.ceph.com/issues/7571 fixes #7571

Signed-off-by: Loic Dachary <loic@dachary.org>
mon: tests for pool create erasure implicit ruleset creation

* Remove the tests checking that a missing or wrong crush_ruleset
  parameters triggered an error.
* Add a test checking that a ruleset with the same name as the pool is
  created implicitly when no crush_ruleset is specified.

Signed-off-by: Loic Dachary <loic@dachary.org>
mon,osd,erasure-code: update copyright notices

Signed-off-by: Loic Dachary <loic@dachary.org>
common,erasure-code,mon: s/erasure-code-//

The parameters to erasure code do not need to be prefixed with the
erasure-code- string. There only are erasure-code parameters and the
prefix was originaly intended to desambiguate the erasure-code
properties, assuming that the properties map could be used for other
purposes.

Signed-off-by: Loic Dachary <loic@dachary.org>
erasure-code: remove dependency to the global context

Instead of relying on derr to display error messages, add them to an
ostream parameter given in argument to load() and factory(). The erasure
code convenience library no longer depends on the global context that is
indirectly referenced by debug.h

Signed-off-by: Loic Dachary <loic@dachary.org>
erasure-code: add ostream to factory()

Modify calls to ErasureCodePlugin::factory() to provide the new
ostream argument.

Signed-off-by: Loic Dachary <loic@dachary.org>
erasure-code: make libcommon include liberasure-code

So that it can be used in OSDMap which is part of libcommon.

Signed-off-by: Loic Dachary <loic@dachary.org>
osd: add OSDMap::erasure_code_profile

A map of key=value properties to be interpreted by the erasure code
plugins. For instance profile["default"] = { "k": 2, "m": 1 }

Signed-off-by: Loic Dachary <loic@dachary.org>
osd: OSDMap::erasure_code_profile accessors

For both the incremental and the OSDMap fields.

Signed-off-by: Loic Dachary <loic@dachary.org>
mon: add helper to selection functions implementing tests

The call_TEST_functions will lookup SHARE_MON_TEST_* shell functions and
run them after creating a mon. Each is expected to clean up and avoid
interferences. It will also lookup TEST_* shell functions and include them
in setup/teardown to provide them with a clean environment.

Signed-off-by: Loic Dachary <loic@dachary.org>
mon: functional tests teardown must be run on error

otherwise daemons will keep running and interfere with tests happening
afterwards.

Signed-off-by: Loic Dachary <loic@dachary.org>