1
0
Fork 0

emit a warning when connecting with the client tools to a DBSERVER (#8397)

This commit is contained in:
Jan 2019-03-13 13:08:41 +01:00 committed by GitHub
parent be53ccda97
commit a841d472be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 49 additions and 11 deletions

View File

@ -1,6 +1,14 @@
devel
-----
* Under normal circumstances there should be no need to connect to a
database server in a cluster with one of the client tools, and it is
likely that any user operations carried out there with one of the client
tools may cause trouble.
The client tools arangosh, arangodump and arangorestore will now emit
a warning when connecting with them to a database server node in a cluster.
* fix compation behaviour of followers
* added "random" masking to mask any data type, added wildcard masking

View File

@ -215,6 +215,18 @@ entries, and will continue to work.
Existing `_modules` collections will also remain functional.
Client tools
------------
Under normal circumstances there should be no need to connect to a
database server in a cluster with one of the client tools, and it is
likely that any user operations carried out there with one of the client
tools may cause trouble.
The client tools arangosh, arangodump and arangorestore will now emit
a warning when connecting with them to a database server node in a cluster.
Internal
--------

View File

@ -1041,13 +1041,19 @@ void DumpFeature::start() {
// check if we are in cluster or single-server mode
Result result{TRI_ERROR_NO_ERROR};
std::tie(result, _options.clusterMode) = _clientManager.getArangoIsCluster(*httpClient);
std::string role;
std::tie(result, role) = _clientManager.getArangoIsCluster(*httpClient);
_options.clusterMode = (role == "COORDINATOR");
if (result.fail()) {
LOG_TOPIC(FATAL, arangodb::Logger::RESTORE)
LOG_TOPIC(FATAL, arangodb::Logger::DUMP)
<< "Error: could not detect ArangoDB instance type: " << result.errorMessage();
FATAL_ERROR_EXIT();
}
if (role == "DBSERVER" || role == "PRIMARY") {
LOG_TOPIC(WARN, arangodb::Logger::DUMP) << "You connected to a DBServer node, but operations in a cluster should be carried out via a Coordinator. This is an unsupported operation!";
}
// special cluster-mode parameter checks
if (_options.clusterMode) {
if (_options.tickStart != 0 || _options.tickEnd != 0) {

View File

@ -281,7 +281,6 @@ void ImportFeature::start() {
}
_httpClient->params().setLocationRewriter(static_cast<void*>(client),
&rewriteLocation);
_httpClient->params().setUserNamePassword("/", client->username(), client->password());

View File

@ -926,7 +926,7 @@ arangodb::Result processInputDirectory(
// wait for all jobs to finish, then check for errors
if (options.progress) {
LOG_TOPIC(INFO, Logger::RESTORE)
<< "# Dispatched " << stats.totalCollections << " job(s) to "
<< "# Dispatched " << stats.totalCollections << " job(s), using "
<< options.threadCount << " worker(s)";
double start = TRI_microtime();
@ -1337,14 +1337,19 @@ void RestoreFeature::start() {
FATAL_ERROR_EXIT();
}
// Version 1.4 did not yet have a cluster mode
std::tie(result, _options.clusterMode) = _clientManager.getArangoIsCluster(*httpClient);
std::string role;
std::tie(result, role) = _clientManager.getArangoIsCluster(*httpClient);
_options.clusterMode = (role == "COORDINATOR");
if (result.fail()) {
LOG_TOPIC(FATAL, arangodb::Logger::RESTORE)
<< "Error: could not detect ArangoDB instance type: " << result.errorMessage();
_exitCode = EXIT_FAILURE;
return;
}
if (role == "DBSERVER" || role == "PRIMARY") {
LOG_TOPIC(WARN, arangodb::Logger::RESTORE) << "You connected to a DBServer node, but operations in a cluster should be carried out via a Coordinator. This is an unsupported operation!";
}
std::tie(result, _options.indexesFirst) =
_clientManager.getArangoIsUsingEngine(*httpClient, "rocksdb");

View File

@ -348,6 +348,14 @@ bool V8ShellFeature::printHello(V8ClientConnection* v8connection) {
<< "', username: '" << v8connection->username() << "'";
_console->printLine(is.str());
if (v8connection->role() == "PRIMARY" || v8connection->role() == "DBSERVER") {
std::string msg("WARNING: You connected to a DBServer node, but operations in a cluster should be carried out via a Coordinator");
if (_console->colors()) {
msg = ShellColorsFeature::SHELL_COLOR_RED + msg + ShellColorsFeature::SHELL_COLOR_RESET;
}
_console->printErrorLine(msg);
}
} else {
std::ostringstream is;

View File

@ -159,7 +159,7 @@ std::string ClientManager::rewriteLocation(void* data, std::string const& locati
return "/_db/" + dbname + "/" + location;
}
std::pair<Result, bool> ClientManager::getArangoIsCluster(httpclient::SimpleHttpClient& client) {
std::pair<Result, std::string> ClientManager::getArangoIsCluster(httpclient::SimpleHttpClient& client) {
using arangodb::basics::VelocyPackHelper;
Result result{TRI_ERROR_NO_ERROR};
@ -168,7 +168,7 @@ std::pair<Result, bool> ClientManager::getArangoIsCluster(httpclient::SimpleHttp
if (response == nullptr || !response->isComplete()) {
result.reset(TRI_ERROR_INTERNAL, "no response from server!");
return {result, false};
return {result, ""};
}
std::string role = "UNDEFINED";
@ -194,7 +194,7 @@ std::pair<Result, bool> ClientManager::getArangoIsCluster(httpclient::SimpleHttp
client.disconnect();
}
return {result, (role == "COORDINATOR")};
return {result, role};
}
std::pair<Result, bool> ClientManager::getArangoIsUsingEngine(httpclient::SimpleHttpClient& client,

View File

@ -94,9 +94,9 @@ class ClientManager {
/**
* @brief Determines whether the ArangoDB instance is part of a cluster
* @param client Client to use for request
* @return status result; `true` if successful and part of a cluster
* @return status result; role name
*/
std::pair<Result, bool> getArangoIsCluster(httpclient::SimpleHttpClient& client);
std::pair<Result, std::string> getArangoIsCluster(httpclient::SimpleHttpClient& client);
/**
* Determines whether the ArangoDB instance is using the specified engine