Skip to content
This repository was archived by the owner on Jan 7, 2022. It is now read-only.

Commit cb7f4ec

Browse files
MohamedBassemfacebook-github-bot
authored andcommitted
Remove the REQUIRES_RESTART restriction from the NCM source of truth flag
Summary: As per our discussion, we will allow the source of truth flag to be switched on/off during runtime without requiring a restart. Reviewed By: shixiao Differential Revision: D17450554 fbshipit-source-id: 84257552850354c814a56fb743f2afac6aa51ab8
1 parent 34a3710 commit cb7f4ec

3 files changed

Lines changed: 52 additions & 3 deletions

File tree

docs/settings.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ sidebar_label: Settings
7474
| server-default-dscp | Use default DSCP to setup to server sockets at Sender.Range was defined by https://tools.ietf.org/html/rfc4594#section-1.4.4 | 0 | requires restart, server only |
7575
| server\_based\_nodes\_configuration\_store\_polling\_extra\_requests | how many extra requests to send for server based Nodes Configuration Store polling in addition to the required response for each wave | 1 | |
7676
| shutdown-on-my-node-id-mismatch | Gracefully shutdown whenever the server's NodeID changes | true | server only |
77-
| use-nodes-configuration-manager-nodes-configuration | If true and enable\_nodes\_configuration\_manager is set, logdevice will use the nodes configuration from the NodesConfigurationManager. | false | requires restart |
77+
| use-nodes-configuration-manager-nodes-configuration | If true and enable\_nodes\_configuration\_manager is set, logdevice will use the nodes configuration from the NodesConfigurationManager. | false | |
7878
| zk-config-polling-interval | polling and retry interval for Zookeeper config source | 1000ms | CLI only |
7979

8080
## Core settings

logdevice/common/settings/Settings.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2626,7 +2626,7 @@ void Settings::defineSettings(SettingEasyInit& init) {
26262626
nullptr, // no custom validation necessary
26272627
"If true and enable_nodes_configuration_manager is set, logdevice will "
26282628
"use the nodes configuration from the NodesConfigurationManager.",
2629-
CLIENT | SERVER | REQUIRES_RESTART,
2629+
CLIENT | SERVER,
26302630
SettingsCategory::Configuration);
26312631

26322632
init("nodes-configuration-manager-store-polling-interval",

logdevice/test/UpdateableNodesConfigurationPublisherIntegrationTest.cpp

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
* LICENSE file in the root directory of this source tree.
77
*/
88

9+
#include "logdevice/admin/if/gen-cpp2/AdminAPI.h"
10+
#include "logdevice/admin/if/gen-cpp2/nodes_constants.h"
911
#include "logdevice/common/configuration/nodes/FileBasedNodesConfigurationStore.h"
1012
#include "logdevice/common/configuration/nodes/NodesConfigurationCodec.h"
1113
#include "logdevice/common/configuration/nodes/NodesConfigurationManagerFactory.h"
@@ -27,6 +29,8 @@ class NodesConfigurationPublisherIntegrationTest : public IntegrationTestBase {
2729
// Initialize the cluster
2830
cluster_ = IntegrationTestUtils::ClusterFactory{}
2931
.doNotSyncServerConfigToNodesConfiguration()
32+
.setNodesConfigurationSourceOfTruth(
33+
NodesConfigurationSourceOfTruth::SERVER_CONFIG)
3034
.create(5);
3135

3236
// Initialize a NCS pointing to the same data as the cluster to be able
@@ -63,7 +67,7 @@ class NodesConfigurationPublisherIntegrationTest : public IntegrationTestBase {
6367
std::shared_ptr<Client> client_;
6468
};
6569

66-
TEST_F(NodesConfigurationPublisherIntegrationTest, Publish) {
70+
TEST_F(NodesConfigurationPublisherIntegrationTest, ClientPublish) {
6771
auto client_impl = dynamic_cast<ClientImpl*>(client_.get());
6872
ASSERT_NE(nullptr, client_impl);
6973
auto processor = client_impl->getProcessorPtr();
@@ -185,3 +189,48 @@ TEST_F(NodesConfigurationPublisherIntegrationTest, Publish) {
185189
EXPECT_EQ(2, processor->getNodesConfiguration()->getVersion().val());
186190
}
187191
}
192+
193+
TEST_F(NodesConfigurationPublisherIntegrationTest, ServerPublish) {
194+
auto admin_client = cluster_->getNode(0).createAdminClient();
195+
196+
auto wait_until_version = [&](uint64_t version) {
197+
facebook::logdevice::thrift::NodesConfigResponse resp;
198+
wait_until(folly::sformat("NC version is: {}", version).c_str(), [&]() {
199+
admin_client->sync_getNodesConfig(
200+
resp, facebook::logdevice::thrift::NodesFilter{});
201+
ld_info("Current version: %ld", resp.version);
202+
return resp.version == version;
203+
});
204+
return resp.version;
205+
};
206+
207+
auto current_nc =
208+
cluster_->getConfig()->getNodesConfigurationFromServerConfigSource();
209+
EXPECT_EQ(current_nc->getVersion().val(),
210+
wait_until_version(current_nc->getVersion().val()));
211+
212+
// For the correctness of this test, let's make sure that the current NC
213+
// version is not equal to our arbitrary number.
214+
ASSERT_NE(123, current_nc->getVersion().val());
215+
216+
// Force the NCM NC to diverge
217+
auto new_nc =
218+
current_nc->withVersion(membership::MembershipVersion::Type{123});
219+
auto serialized = NodesConfigurationCodec::serialize(*new_nc);
220+
ASSERT_EQ(
221+
Status::OK, ncs_->updateConfigSync(std::move(serialized), folly::none));
222+
223+
// Switch the source of truth to the NCM NC and make sure that it's what
224+
// you get back from querying the server.
225+
cluster_->getNode(0).sendCommand(
226+
"set use-nodes-configuration-manager-nodes-configuration true --ttl max");
227+
EXPECT_EQ(123, wait_until_version(123));
228+
229+
// Flip the switch back to the server config and make sure you get the old
230+
// version back.
231+
cluster_->getNode(0).sendCommand(
232+
"set use-nodes-configuration-manager-nodes-configuration false --ttl "
233+
"max");
234+
EXPECT_EQ(current_nc->getVersion().val(),
235+
wait_until_version(current_nc->getVersion().val()));
236+
}

0 commit comments

Comments
 (0)