Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions distbench_busybox.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ ABSL_FLAG(std::string, service_address, "",
"Incoming RPC address for the node_manager to report to the "
"test_sequencer. Useful if DNS cannot resolve the hostname. "
"Must include gRPC protocol host and port e.g. ipv4:///1.2.3.4:5678");
ABSL_FLAG(std::string, service_hostname, "",
"Hostname for the node_manager to use. Useful for multi-homed hosts");

int main(int argc, char** argv, char** envp) {
std::vector<char*> remaining_arguments = absl::ParseCommandLine(argc, argv);
Expand Down Expand Up @@ -348,6 +350,7 @@ int MainTestSequencer(std::vector<char*>& arguments) {
absl::GetFlag(FLAGS_default_data_plane_device),
.control_plane_device = absl::GetFlag(FLAGS_control_plane_device),
.port = &new_port,
.service_hostname = absl::GetFlag(FLAGS_service_hostname),
};
nodes.push_back(std::make_unique<distbench::NodeManager>());
absl::Status status = nodes.back()->Initialize(opts);
Expand Down Expand Up @@ -413,6 +416,7 @@ int MainNodeManager(std::vector<char*>& arguments) {
.port = &port,
.attributes = attributes,
.service_address = absl::GetFlag(FLAGS_service_address),
.service_hostname = absl::GetFlag(FLAGS_service_hostname),
};
distbench::NodeManager node_manager;
absl::Status status = node_manager.Initialize(opts);
Expand Down
11 changes: 7 additions & 4 deletions distbench_node_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ grpc::Status NodeManager::ConfigureNode(grpc::ServerContext* context,
}
auto& service_entry = service_map[service_name];
service_entry.set_endpoint_address(maybe_address.value());
service_entry.set_hostname(Hostname());
service_entry.set_hostname(opts_.service_hostname);
*service_entry.mutable_attributes() = registration_info_.attributes();
int dimensions = std::count(service_name.begin(), service_name.end(), '/');
Attribute* attribute;
Expand Down Expand Up @@ -277,6 +277,9 @@ NodeManager::~NodeManager() {

absl::Status NodeManager::Initialize(const NodeManagerOpts& opts) {
opts_ = opts;
if (opts_.service_hostname.empty()) {
opts_.service_hostname = Hostname();
}
if (opts_.test_sequencer_service_address.empty()) {
Shutdown();
return absl::InvalidArgumentError(
Expand Down Expand Up @@ -312,7 +315,7 @@ absl::Status NodeManager::Initialize(const NodeManagerOpts& opts) {
if (opts_.service_address.empty()) {
if (!registration_info_.has_control_ip()) {
opts_.service_address =
absl::StrCat("dns:///", Hostname(), ":", *opts_.port);
absl::StrCat("dns:///", opts_.service_hostname, ":", *opts_.port);
} else if (listening_address[0] == '[') {
opts_.service_address =
absl::StrCat("ipv6:///", listening_address);
Expand All @@ -327,10 +330,10 @@ absl::Status NodeManager::Initialize(const NodeManagerOpts& opts) {
return absl::UnknownError("NodeManager service failed to start");
}
LOG(INFO) << "NodeManager server listening on " << opts_.service_address
<< " on " << Hostname();
<< " on " << opts_.service_hostname;

registration_info_.set_preassigned_node_id(opts_.preassigned_node_id);
registration_info_.set_hostname(Hostname());
registration_info_.set_hostname(opts_.service_hostname);
registration_info_.set_control_port(*opts_.port);
for (const auto& attr : opts_.attributes) {
auto new_attr = registration_info_.add_attributes();
Expand Down
4 changes: 4 additions & 0 deletions distbench_node_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ struct NodeManagerOpts {
// resolve the hostname). This is passed to gRPC unmodified, so it must be
// a valid "target" (I.e. it must include a protocol, host and port).
std::string service_address;

// If the hostname reported by gethostname is unresolvable this will override
// it for node manager registrations:
std::string service_hostname;
};

class NodeManager final : public DistBenchNodeManager::Service {
Expand Down
1 change: 1 addition & 0 deletions distbench_test_sequencer_tester.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ absl::Status DistBenchTester::Resize(size_t num_nodes) {
nm_opts.port = &port;
nm_opts.test_sequencer_service_address = test_sequencer->service_address();
nm_opts.control_plane_device = "lo";
nm_opts.service_hostname = "localhost";
nodes[i] = std::make_unique<NodeManager>();
auto ret = nodes[i]->Initialize(nm_opts);
if (!ret.ok()) return ret;
Expand Down