Skip to content

Commit

Permalink
Fixed a bug where the slave crashes when the subnet is injected witho…
Browse files Browse the repository at this point in the history
…ut discovery info.(#51)

This happens because the call to mutable_discovery() creates an object
if none exists, the slave then crashes because said object does not have
its mandatory visibility field initiated.

Co-authored-by: Achref Hawech <a.hawech@criteo.com>
  • Loading branch information
zed3250 and Achref Hawech committed Feb 5, 2021
1 parent 328c7ac commit 37f49eb
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/slave/slave.cpp
Expand Up @@ -3665,16 +3665,18 @@ void Slave::launchExecutor(
NetworkInfo* criteoNet = containerInfo->add_network_infos();
criteoNet->set_name("criteo");

Ports ports = *containerConfig.mutable_executor_info()
->mutable_discovery()
->mutable_ports();

// We need to take the defined ports and map them in the public subnet
for (const auto port : *ports.mutable_ports()) {
auto p = criteoNet->add_port_mappings();
p->set_host_port(port.number());
p->set_container_port(port.number());
p->set_protocol(port.protocol());
if(containerConfig.mutable_executor_info()->has_discovery()){
// We need to take the defined ports and map them in the public subnet
Ports ports = *containerConfig.mutable_executor_info()
->mutable_discovery()
->mutable_ports();

for (const auto port : *ports.mutable_ports()) {
auto p = criteoNet->add_port_mappings();
p->set_host_port(port.number());
p->set_container_port(port.number());
p->set_protocol(port.protocol());
}
}
}
}
Expand Down

0 comments on commit 37f49eb

Please sign in to comment.