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

Seeds Driven Cluster Bootstrap #6744

Merged
merged 21 commits into from
Oct 20, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion src/v/cluster/bootstrap_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,32 @@
#include "cluster/bootstrap_service.h"

#include "cluster/bootstrap_types.h"
#include "cluster/cluster_utils.h"
#include "cluster/logger.h"
#include "config/node_config.h"
#include "features/feature_table.h"
#include "storage/api.h"

namespace cluster {

ss::future<cluster_bootstrap_info_reply>
bootstrap_service::cluster_bootstrap_info(
cluster_bootstrap_info_request&&, rpc::streaming_context&) {
cluster_bootstrap_info_reply r{};
// TODO: add fields!
r.broker = make_self_broker(config::node());
r.version = features::feature_table::get_latest_logical_version();
const std::vector<config::seed_server>& seed_servers
= config::node().seed_servers();
r.seed_servers.reserve(seed_servers.size());
std::transform(
seed_servers.cbegin(),
seed_servers.cend(),
std::back_inserter(r.seed_servers),
[](const config::seed_server& seed_server) { return seed_server.addr; });
r.empty_seed_starts_cluster = config::node().empty_seed_starts_cluster();
r.cluster_uuid = _storage.local().get_cluster_uuid();

vlog(clusterlog.debug, "Replying cluster_bootstrap_info: {}", r);
co_return r;
}

Expand Down
16 changes: 12 additions & 4 deletions src/v/cluster/bootstrap_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,28 @@

#include "cluster/bootstrap_types.h"
#include "cluster/cluster_bootstrap_service.h"
#include "storage/fwd.h"

#include <seastar/core/sharded.hh>

namespace cluster {

// RPC service to be used when initialially bootstrapping a cluster.
// TODO: talk about how it's a slim service with few dependencies.
// RPC service used to determine cluster info when bootstrapping a cluster
// or to discover the existence of an existing cluster.
class bootstrap_service : public cluster_bootstrap_service {
public:
bootstrap_service(ss::scheduling_group sg, ss::smp_service_group ssg)
: cluster_bootstrap_service(sg, ssg) {}
bootstrap_service(
ss::scheduling_group sg,
ss::smp_service_group ssg,
ss::sharded<storage::api>& storage)
: cluster_bootstrap_service(sg, ssg)
, _storage(storage) {}

ss::future<cluster_bootstrap_info_reply> cluster_bootstrap_info(
cluster_bootstrap_info_request&&, rpc::streaming_context&) override;

private:
ss::sharded<storage::api>& _storage;
};

} // namespace cluster
28 changes: 25 additions & 3 deletions src/v/cluster/bootstrap_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
// by the Apache License, Version 2.0
#pragma once

#include "cluster/types.h"
#include "model/fundamental.h"
#include "serde/serde.h"

Expand All @@ -34,11 +35,32 @@ struct cluster_bootstrap_info_reply
: serde::envelope<cluster_bootstrap_info_reply, serde::version<0>> {
using rpc_adl_exempt = std::true_type;

auto serde_fields() { return std::tie(); }
model::broker broker;
cluster_version version;
std::vector<net::unresolved_address> seed_servers;
bool empty_seed_starts_cluster;
std::optional<model::cluster_uuid> cluster_uuid;

auto serde_fields() {
return std::tie(
broker,
version,
seed_servers,
empty_seed_starts_cluster,
cluster_uuid);
}

friend std::ostream&
operator<<(std::ostream& o, const cluster_bootstrap_info_reply&) {
fmt::print(o, "{{}}");
operator<<(std::ostream& o, const cluster_bootstrap_info_reply& v) {
fmt::print(
o,
"{{broker: {}, version: {}, seed_servers: {}, ESCB: {}, "
"cluster_UUID: {}}}",
v.broker,
v.version,
v.seed_servers,
v.empty_seed_starts_cluster,
v.cluster_uuid);
return o;
}
};
Expand Down
Loading