summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mongo/db/commands/feature_compatibility_version.cpp118
-rw-r--r--src/mongo/db/commands/feature_compatibility_version_command_parser.cpp34
-rw-r--r--src/mongo/db/commands/feature_compatibility_version_command_parser.h5
-rw-r--r--src/mongo/db/commands/set_feature_compatibility_version_command.cpp11
-rw-r--r--src/mongo/db/ops/parsed_update.cpp7
-rw-r--r--src/mongo/db/s/config/configsvr_set_feature_compatibility_version_command.cpp8
-rw-r--r--src/mongo/db/update/update_driver.cpp11
-rw-r--r--src/mongo/s/commands/cluster_set_feature_compatibility_version_cmd.cpp11
8 files changed, 120 insertions, 85 deletions
diff --git a/src/mongo/db/commands/feature_compatibility_version.cpp b/src/mongo/db/commands/feature_compatibility_version.cpp
index fedeed17dc1..14a2aad1aba 100644
--- a/src/mongo/db/commands/feature_compatibility_version.cpp
+++ b/src/mongo/db/commands/feature_compatibility_version.cpp
@@ -97,69 +97,72 @@ StatusWith<ServerGlobalParams::FeatureCompatibility::Version> FeatureCompatibili
} else if (fieldName == FeatureCompatibilityVersion::kVersionField) {
foundVersionField = true;
if (elem.type() != BSONType::String) {
- return Status(
- ErrorCodes::TypeMismatch,
- str::stream()
- << FeatureCompatibilityVersion::kVersionField
- << " must be of type String, but was of type "
- << typeName(elem.type())
- << ". Contents of "
- << FeatureCompatibilityVersion::kParameterName
- << " document in "
- << FeatureCompatibilityVersion::kCollection
- << ": "
- << featureCompatibilityVersionDoc
- << ". See http://dochub.mongodb.org/core/3.6-feature-compatibility.");
+ return Status(ErrorCodes::TypeMismatch,
+ str::stream() << FeatureCompatibilityVersion::kVersionField
+ << " must be of type String, but was of type "
+ << typeName(elem.type())
+ << ". Contents of "
+ << FeatureCompatibilityVersion::kParameterName
+ << " document in "
+ << FeatureCompatibilityVersion::kCollection
+ << ": "
+ << featureCompatibilityVersionDoc
+ << ". See "
+ << feature_compatibility_version::kDochubLink
+ << ".");
}
if (elem.String() == FeatureCompatibilityVersionCommandParser::kVersion36) {
version = ServerGlobalParams::FeatureCompatibility::Version::k36;
} else if (elem.String() == FeatureCompatibilityVersionCommandParser::kVersion34) {
version = ServerGlobalParams::FeatureCompatibility::Version::k34;
} else {
- return Status(
- ErrorCodes::BadValue,
- str::stream()
- << "Invalid value for "
- << FeatureCompatibilityVersion::kVersionField
- << ", found "
- << elem.String()
- << ", expected '"
- << FeatureCompatibilityVersionCommandParser::kVersion36
- << "' or '"
- << FeatureCompatibilityVersionCommandParser::kVersion34
- << "'. Contents of "
- << FeatureCompatibilityVersion::kParameterName
- << " document in "
- << FeatureCompatibilityVersion::kCollection
- << ": "
- << featureCompatibilityVersionDoc
- << ". See http://dochub.mongodb.org/core/3.6-feature-compatibility.");
+ return Status(ErrorCodes::BadValue,
+ str::stream() << "Invalid value for "
+ << FeatureCompatibilityVersion::kVersionField
+ << ", found "
+ << elem.String()
+ << ", expected '"
+ << FeatureCompatibilityVersionCommandParser::kVersion36
+ << "' or '"
+ << FeatureCompatibilityVersionCommandParser::kVersion34
+ << "'. Contents of "
+ << FeatureCompatibilityVersion::kParameterName
+ << " document in "
+ << FeatureCompatibilityVersion::kCollection
+ << ": "
+ << featureCompatibilityVersionDoc
+ << ". See "
+ << feature_compatibility_version::kDochubLink
+ << ".");
}
} else {
- return Status(
- ErrorCodes::BadValue,
- str::stream() << "Unrecognized field '" << elem.fieldName() << "''. Contents of "
- << FeatureCompatibilityVersion::kParameterName
- << " document in "
- << FeatureCompatibilityVersion::kCollection
- << ": "
- << featureCompatibilityVersionDoc
- << ". See http://dochub.mongodb.org/core/3.6-feature-compatibility.");
+ return Status(ErrorCodes::BadValue,
+ str::stream() << "Unrecognized field '" << elem.fieldName()
+ << "''. Contents of "
+ << FeatureCompatibilityVersion::kParameterName
+ << " document in "
+ << FeatureCompatibilityVersion::kCollection
+ << ": "
+ << featureCompatibilityVersionDoc
+ << ". See "
+ << feature_compatibility_version::kDochubLink
+ << ".");
}
}
if (!foundVersionField) {
return Status(ErrorCodes::BadValue,
- str::stream()
- << "Missing required field '"
- << FeatureCompatibilityVersion::kVersionField
- << "''. Contents of "
- << FeatureCompatibilityVersion::kParameterName
- << " document in "
- << FeatureCompatibilityVersion::kCollection
- << ": "
- << featureCompatibilityVersionDoc
- << ". See http://dochub.mongodb.org/core/3.6-feature-compatibility.");
+ str::stream() << "Missing required field '"
+ << FeatureCompatibilityVersion::kVersionField
+ << "''. Contents of "
+ << FeatureCompatibilityVersion::kParameterName
+ << " document in "
+ << FeatureCompatibilityVersion::kCollection
+ << ": "
+ << featureCompatibilityVersionDoc
+ << ". See "
+ << feature_compatibility_version::kDochubLink
+ << ".");
}
return version;
@@ -167,8 +170,13 @@ StatusWith<ServerGlobalParams::FeatureCompatibility::Version> FeatureCompatibili
void FeatureCompatibilityVersion::set(OperationContext* opCtx, StringData version) {
uassert(40284,
- "featureCompatibilityVersion must be '3.6' or '3.4'. See "
- "http://dochub.mongodb.org/core/3.6-feature-compatibility.",
+ str::stream() << "featureCompatibilityVersion must be '"
+ << FeatureCompatibilityVersionCommandParser::kVersion36
+ << "' or '"
+ << FeatureCompatibilityVersionCommandParser::kVersion34
+ << "'. See "
+ << feature_compatibility_version::kDochubLink
+ << ".",
version == FeatureCompatibilityVersionCommandParser::kVersion36 ||
version == FeatureCompatibilityVersionCommandParser::kVersion34);
@@ -299,14 +307,16 @@ public:
return Status(ErrorCodes::IllegalOperation,
str::stream() << FeatureCompatibilityVersion::kParameterName
<< " cannot be set via setParameter. See "
- "http://dochub.mongodb.org/core/3.6-feature-compatibility.");
+ << feature_compatibility_version::kDochubLink
+ << ".");
}
virtual Status setFromString(const std::string& str) {
return Status(ErrorCodes::IllegalOperation,
str::stream() << FeatureCompatibilityVersion::kParameterName
<< " cannot be set via setParameter. See "
- "http://dochub.mongodb.org/core/3.6-feature-compatibility.");
+ << feature_compatibility_version::kDochubLink
+ << ".");
}
} featureCompatibilityVersionParameter;
diff --git a/src/mongo/db/commands/feature_compatibility_version_command_parser.cpp b/src/mongo/db/commands/feature_compatibility_version_command_parser.cpp
index 5f80382e0f3..ae781c8137f 100644
--- a/src/mongo/db/commands/feature_compatibility_version_command_parser.cpp
+++ b/src/mongo/db/commands/feature_compatibility_version_command_parser.cpp
@@ -37,8 +37,10 @@
#include "mongo/util/version.h"
namespace mongo {
+namespace {
+constexpr StringData kVersion32 = "3.2"_sd;
+} // namespace
-constexpr StringData FeatureCompatibilityVersionCommandParser::kVersion32;
constexpr StringData FeatureCompatibilityVersionCommandParser::kVersion34;
constexpr StringData FeatureCompatibilityVersionCommandParser::kVersion36;
@@ -59,7 +61,9 @@ StatusWith<std::string> FeatureCompatibilityVersionCommandParser::extractVersion
<< typeName(versionElem.type())
<< " in: "
<< cmdObj
- << ". See http://dochub.mongodb.org/core/3.6-feature-compatibility."};
+ << ". See "
+ << feature_compatibility_version::kDochubLink
+ << "."};
}
// Ensure that the command does not contain any unrecognized parameters
@@ -69,20 +73,24 @@ StatusWith<std::string> FeatureCompatibilityVersionCommandParser::extractVersion
continue;
}
- uasserted(
- ErrorCodes::InvalidOptions,
- str::stream() << "Unrecognized field found " << cmdElem.fieldNameStringData() << " in "
- << cmdObj
- << ". See http ://dochub.mongodb.org/core/3.6-feature-compatibility.");
+ uasserted(ErrorCodes::InvalidOptions,
+ str::stream() << "Unrecognized field found " << cmdElem.fieldNameStringData()
+ << " in "
+ << cmdObj
+ << ". See "
+ << feature_compatibility_version::kDochubLink
+ << ".");
}
const std::string version = versionElem.String();
- if (version == FeatureCompatibilityVersionCommandParser::kVersion32) {
+ if (version == kVersion32) {
return {ErrorCodes::BadValue,
- "Invalid command argument: '3.2'. You must downgrade to MongoDB 3.4 to enable "
- "featureCompatibilityVersion 3.2. See "
- "http://dochub.mongodb.org/core/3.6-feature-compatibility."};
+ str::stream() << "Invalid command argument: '" << kVersion32
+ << "'. You must downgrade to MongoDB 3.4 to enable "
+ "featureCompatibilityVersion 3.2. See "
+ << feature_compatibility_version::kDochubLink
+ << "."};
}
if (version != FeatureCompatibilityVersionCommandParser::kVersion36 &&
@@ -96,7 +104,9 @@ StatusWith<std::string> FeatureCompatibilityVersionCommandParser::extractVersion
<< version
<< " in: "
<< cmdObj
- << ". See http://dochub.mongodb.org/core/3.6-feature-compatibility."};
+ << ". See "
+ << feature_compatibility_version::kDochubLink
+ << "."};
}
return version;
diff --git a/src/mongo/db/commands/feature_compatibility_version_command_parser.h b/src/mongo/db/commands/feature_compatibility_version_command_parser.h
index 3a57f2ca75b..c4544fdbff1 100644
--- a/src/mongo/db/commands/feature_compatibility_version_command_parser.h
+++ b/src/mongo/db/commands/feature_compatibility_version_command_parser.h
@@ -38,12 +38,15 @@ class BSONObj;
template <typename T>
class StatusWith;
+namespace feature_compatibility_version {
+constexpr StringData kDochubLink = "http://dochub.mongodb.org/core/3.6-feature-compatibility"_sd;
+} // namespace feature_compatibility_version
+
class FeatureCompatibilityVersionCommandParser {
public:
/**
* Known server release versions.
*/
- static constexpr StringData kVersion32 = "3.2"_sd;
static constexpr StringData kVersion34 = "3.4"_sd;
static constexpr StringData kVersion36 = "3.6"_sd;
diff --git a/src/mongo/db/commands/set_feature_compatibility_version_command.cpp b/src/mongo/db/commands/set_feature_compatibility_version_command.cpp
index a9d4be0b58a..f979e30c64d 100644
--- a/src/mongo/db/commands/set_feature_compatibility_version_command.cpp
+++ b/src/mongo/db/commands/set_feature_compatibility_version_command.cpp
@@ -76,10 +76,13 @@ public:
}
virtual void help(std::stringstream& help) const {
- help << "Set the API version exposed by this node. If set to \"3.4\", then 3.6 "
- "features are disabled. If \"3.6\", then 3.6 features are enabled, and all nodes "
- "in the cluster must be version 3.6. See "
- "http://dochub.mongodb.org/core/3.6-feature-compatibility.";
+ help << "Set the API version exposed by this node. If set to \""
+ << FeatureCompatibilityVersionCommandParser::kVersion34
+ << "\", then 3.6 features are disabled. If \""
+ << FeatureCompatibilityVersionCommandParser::kVersion36
+ << "\", then 3.6 features are enabled, and all nodes in the cluster must be version "
+ "3.6. See "
+ << feature_compatibility_version::kDochubLink << ".";
}
Status checkAuthForCommand(Client* client,
diff --git a/src/mongo/db/ops/parsed_update.cpp b/src/mongo/db/ops/parsed_update.cpp
index 313f511d3fd..5d1188d7493 100644
--- a/src/mongo/db/ops/parsed_update.cpp
+++ b/src/mongo/db/ops/parsed_update.cpp
@@ -30,6 +30,7 @@
#include "mongo/db/ops/parsed_update.h"
+#include "mongo/db/commands/feature_compatibility_version_command_parser.h"
#include "mongo/db/matcher/extensions_callback_real.h"
#include "mongo/db/ops/update_request.h"
#include "mongo/db/query/canonical_query.h"
@@ -148,8 +149,10 @@ Status ParsedUpdate::parseArrayFilters() {
serverGlobalParams.featureCompatibility.version.load() ==
ServerGlobalParams::FeatureCompatibility::Version::k34) {
return Status(ErrorCodes::InvalidOptions,
- "The featureCompatibilityVersion must be 3.6 to use arrayFilters. See "
- "http://dochub.mongodb.org/core/3.6-feature-compatibility.");
+ str::stream()
+ << "The featureCompatibilityVersion must be 3.6 to use arrayFilters. See "
+ << feature_compatibility_version::kDochubLink
+ << ".");
}
for (auto rawArrayFilter : _request->getArrayFilters()) {
diff --git a/src/mongo/db/s/config/configsvr_set_feature_compatibility_version_command.cpp b/src/mongo/db/s/config/configsvr_set_feature_compatibility_version_command.cpp
index a303e6df49d..2f00c152c44 100644
--- a/src/mongo/db/s/config/configsvr_set_feature_compatibility_version_command.cpp
+++ b/src/mongo/db/s/config/configsvr_set_feature_compatibility_version_command.cpp
@@ -66,7 +66,7 @@ public:
void help(std::stringstream& help) const override {
help << "Internal command, which is exported by the sharding config server. Do not call "
"directly. Sets featureCompatibilityVersion on all shards. See "
- "http://dochub.mongodb.org/core/3.6-feature-compatibility.";
+ << feature_compatibility_version::kDochubLink << ".";
}
bool slaveOk() const override {
@@ -99,9 +99,9 @@ public:
FeatureCompatibilityVersionCommandParser::extractVersionFromCommand(getName(), cmdObj));
uassert(ErrorCodes::IllegalOperation,
- str::stream() << getName()
- << " can only be run on config servers. See "
- "http://dochub.mongodb.org/core/3.6-feature-compatibility.",
+ str::stream() << getName() << " can only be run on config servers. See "
+ << feature_compatibility_version::kDochubLink
+ << ".",
serverGlobalParams.clusterRole == ClusterRole::ConfigServer);
// Remove after 3.4 -> 3.6 upgrade.
diff --git a/src/mongo/db/update/update_driver.cpp b/src/mongo/db/update/update_driver.cpp
index 52700a13f80..e8b33765444 100644
--- a/src/mongo/db/update/update_driver.cpp
+++ b/src/mongo/db/update/update_driver.cpp
@@ -34,6 +34,7 @@
#include "mongo/bson/mutable/algorithm.h"
#include "mongo/bson/mutable/document.h"
#include "mongo/db/bson/dotted_path_support.h"
+#include "mongo/db/commands/feature_compatibility_version_command_parser.h"
#include "mongo/db/field_ref.h"
#include "mongo/db/matcher/expression_leaf.h"
#include "mongo/db/matcher/extensions_callback_noop.h"
@@ -154,10 +155,12 @@ Status UpdateDriver::parse(
// If the featureCompatibilityVersion is 3.4, parse using the ModifierInterfaces.
if (serverGlobalParams.featureCompatibility.version.load() ==
ServerGlobalParams::FeatureCompatibility::Version::k34) {
- uassert(ErrorCodes::InvalidOptions,
- "The featureCompatibilityVersion must be 3.6 to use arrayFilters. See "
- "http://dochub.mongodb.org/core/3.6-feature-compatibility.",
- arrayFilters.empty());
+ uassert(
+ ErrorCodes::InvalidOptions,
+ str::stream() << "The featureCompatibilityVersion must be 3.6 to use arrayFilters. See "
+ << feature_compatibility_version::kDochubLink
+ << ".",
+ arrayFilters.empty());
for (auto&& mod : updateExpr) {
auto modType = validateMod(mod);
for (auto&& field : mod.Obj()) {
diff --git a/src/mongo/s/commands/cluster_set_feature_compatibility_version_cmd.cpp b/src/mongo/s/commands/cluster_set_feature_compatibility_version_cmd.cpp
index c186b56f693..07e19784bf6 100644
--- a/src/mongo/s/commands/cluster_set_feature_compatibility_version_cmd.cpp
+++ b/src/mongo/s/commands/cluster_set_feature_compatibility_version_cmd.cpp
@@ -65,10 +65,13 @@ public:
}
virtual void help(std::stringstream& help) const {
- help << "Set the API version for the cluster. If set to \"3.4\", then 3.6 features are "
- "disabled. If \"3.6\", then 3.6 features are enabled, and all nodes in the cluster "
- "must be version 3.6. See "
- "http://dochub.mongodb.org/core/3.6-feature-compatibility.";
+ help << "Set the API version for the cluster. If set to \""
+ << FeatureCompatibilityVersionCommandParser::kVersion34
+ << "\", then 3.6 features are disabled. If \""
+ << FeatureCompatibilityVersionCommandParser::kVersion36
+ << "\", then 3.6 features are enabled, and all nodes in the cluster must be version "
+ "3.6. See "
+ << feature_compatibility_version::kDochubLink << ".";
}
Status checkAuthForCommand(Client* client,