diff options
author | A. Jesse Jiryu Davis <jesse@mongodb.com> | 2020-09-10 12:36:48 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-09-10 17:20:46 +0000 |
commit | ce0487190cf69d200028e7f9f4bcd3cefeea805d (patch) | |
tree | 1c887296b763f8a002cfd67c7052f67154274538 /src/mongo | |
parent | 93a5cd255c56e922cdfe052107b96dac6c2c31db (diff) | |
download | mongo-ce0487190cf69d200028e7f9f4bcd3cefeea805d.tar.gz |
SERVER-49858 Add Command::acceptsAnyApiVersionParameters
Diffstat (limited to 'src/mongo')
-rw-r--r-- | src/mongo/db/commands.h | 7 | ||||
-rw-r--r-- | src/mongo/db/initialize_api_parameters.cpp | 4 | ||||
-rw-r--r-- | src/mongo/db/s/config/configsvr_drop_collection_command.cpp | 8 | ||||
-rw-r--r-- | src/mongo/db/s/config/configsvr_drop_database_command.cpp | 8 |
4 files changed, 23 insertions, 4 deletions
diff --git a/src/mongo/db/commands.h b/src/mongo/db/commands.h index 57b3ce272ca..06803dbad84 100644 --- a/src/mongo/db/commands.h +++ b/src/mongo/db/commands.h @@ -365,6 +365,13 @@ public: */ virtual const std::set<std::string>& deprecatedApiVersions() const; + /* + * Some commands permit any values for apiVersion, apiStrict, and apiDeprecationErrors. + */ + virtual bool acceptsAnyApiVersionParameters() const { + return false; + } + /** * Like adminOnly, but even stricter: we must either be authenticated for admin db, * or, if running without auth, on the local interface. Used for things which diff --git a/src/mongo/db/initialize_api_parameters.cpp b/src/mongo/db/initialize_api_parameters.cpp index 9ad9fc4d026..575fd476827 100644 --- a/src/mongo/db/initialize_api_parameters.cpp +++ b/src/mongo/db/initialize_api_parameters.cpp @@ -53,6 +53,10 @@ const APIParametersFromClient initializeAPIParameters(OperationContext* opCtx, apiParamsFromClient.getApiVersion()); } + if (command->acceptsAnyApiVersionParameters()) { + return apiParamsFromClient; + } + if (apiParamsFromClient.getApiDeprecationErrors() || apiParamsFromClient.getApiStrict()) { uassert(4886600, "Provided apiStrict and/or apiDeprecationErrors without passing apiVersion", diff --git a/src/mongo/db/s/config/configsvr_drop_collection_command.cpp b/src/mongo/db/s/config/configsvr_drop_collection_command.cpp index 29b15c82a9e..6743958f1f5 100644 --- a/src/mongo/db/s/config/configsvr_drop_collection_command.cpp +++ b/src/mongo/db/s/config/configsvr_drop_collection_command.cpp @@ -59,8 +59,12 @@ class ConfigSvrDropCollectionCommand : public BasicCommand { public: ConfigSvrDropCollectionCommand() : BasicCommand("_configsvrDropCollection") {} - const std::set<std::string>& apiVersions() const { - return kApiVersions1; + /** + * We accept any apiVersion, apiStrict, and/or apiDeprecationErrors, and forward it with the + * "drop" command to shards. + */ + bool acceptsAnyApiVersionParameters() const override { + return true; } AllowedOnSecondary secondaryAllowed(ServiceContext*) const override { diff --git a/src/mongo/db/s/config/configsvr_drop_database_command.cpp b/src/mongo/db/s/config/configsvr_drop_database_command.cpp index 91513e5d2e4..896569a0afe 100644 --- a/src/mongo/db/s/config/configsvr_drop_database_command.cpp +++ b/src/mongo/db/s/config/configsvr_drop_database_command.cpp @@ -55,8 +55,12 @@ class ConfigSvrDropDatabaseCommand : public BasicCommand { public: ConfigSvrDropDatabaseCommand() : BasicCommand("_configsvrDropDatabase") {} - const std::set<std::string>& apiVersions() const { - return kApiVersions1; + /** + * We accept any apiVersion, apiStrict, and/or apiDeprecationErrors, and forward it with the + * "dropDatabase" command to shards. + */ + bool acceptsAnyApiVersionParameters() const override { + return true; } AllowedOnSecondary secondaryAllowed(ServiceContext*) const override { |