Merge pull request #43355 from rzarzynski/wip-crimson-write_meta

crimson/osd: write the 'osd_key' meta on OSD::mkfs(). 

Reviewed-by: Chunmei Liu <chunmei.liu@intel.com>
Reviewed-by: Samuel Just <sjust@redhat.com>
Reviewed-by: Kefu Chai <tchaikov@gmail.com>
This commit is contained in:
Kefu Chai 2021-09-30 22:16:51 +08:00 committed by GitHub
commit 96edb523c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 1 deletions

View File

@ -39,6 +39,7 @@
#include "crimson/admin/osd_admin.h"
#include "crimson/admin/pg_commands.h"
#include "crimson/common/buffer_io.h"
#include "crimson/common/exception.h"
#include "crimson/mon/MonClient.h"
#include "crimson/net/Connection.h"
@ -170,7 +171,9 @@ seastar::future<> OSD::mkfs(uuid_d osd_uuid, uuid_d cluster_fsid)
}).then([cluster_fsid, this] {
return when_all_succeed(
store.write_meta("ceph_fsid", cluster_fsid.to_string()),
store.write_meta("whoami", std::to_string(whoami)));
store.write_meta("whoami", std::to_string(whoami)),
_write_key_meta(),
store.write_meta("ready", "ready"));
}).then_unpack([cluster_fsid, this] {
fmt::print("created object store {} for osd.{} fsid {}\n",
local_conf().get_val<std::string>("osd_data"),
@ -215,6 +218,33 @@ seastar::future<> OSD::_write_superblock()
});
}
// this `to_string` sits in the `crimson::osd` namespace, so we don't brake
// the language rule on not overloading in `std::`.
static std::string to_string(const seastar::temporary_buffer<char>& temp_buf)
{
return {temp_buf.get(), temp_buf.size()};
}
seastar::future<> OSD::_write_key_meta()
{
if (auto key = local_conf().get_val<std::string>("key"); !std::empty(key)) {
return store.write_meta("osd_key", key);
} else if (auto keyfile = local_conf().get_val<std::string>("keyfile");
!std::empty(keyfile)) {
return read_file(keyfile).then([this] (const auto& temp_buf) {
// it's on a truly cold path, so don't worry about memcpy.
return store.write_meta("osd_key", to_string(temp_buf));
}).handle_exception([keyfile] (auto ep) {
logger().error("_write_key_meta: failed to handle keyfile {}: {}",
keyfile, ep);
ceph_abort();
});
} else {
return seastar::now();
}
}
namespace {
entity_addrvec_t pick_addresses(int what) {
entity_addrvec_t addrs;

View File

@ -145,6 +145,7 @@ public:
private:
seastar::future<> _write_superblock();
seastar::future<> _write_key_meta();
seastar::future<> start_boot();
seastar::future<> _preboot(version_t oldest_osdmap, version_t newest_osdmap);
seastar::future<> _send_boot();