Skip to content

Commit

Permalink
REMOVE deprecated db related CLIs
Browse files Browse the repository at this point in the history
  • Loading branch information
fgalan committed Feb 29, 2024
1 parent 1bd44af commit 82941cc
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 163 deletions.
1 change: 1 addition & 0 deletions CHANGES_NEXT_RELEASE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Remove: `-dbhost`, `-rplSet`, `-dbTimeout`, `-dbuser`, `-dbAuthMech`, `-dbAuthDb`, `-dbSSL` and `-dbDisableRetryWrites` CLI parameters along with associated env vars, already deprecated in Orion 3.12.0 (use `-dbURI` instead`)
4 changes: 2 additions & 2 deletions doc/manuals/deprecated.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ A list of deprecated features and the version in which they were deprecated foll

* CLI parameters (and associated env vars): `-dbhost`, `-rplSet`, `-dbTimeout`, `-dbuser`,
`-dbAuthMech`, `-dbAuthDb`, `-dbSSL` and `-dbDisableRetryWrites` in Orion 3.12.0. Use `dbURI` instead,
checking [this section](#mapping-to-mongouri-from-old-cli-parameters) if you need to know hot to build the MongoDB URI.
checking [this section](#mapping-to-mongouri-from-old-cli-parameters) if you need to know hot to build the MongoDB URI (removed in Orion 3.13.0).
* `geo:point`, `geo:line`, `geo:box` and `geo:polygon` attribute types in Orion 3.10.0. Use `geo:json` instead.
* `GET /v2` operation in Orion 3.8.0. This operation is pretty useless and not actually used.
* Initial notification in subscriptions (along with `skipInitialNotification` option) in Orion 3.1.0.
Expand Down Expand Up @@ -134,12 +134,12 @@ The following table provides information about the last Orion version supporting

| **Removed feature** | **Last Orion version supporting feature** | **That version release date** |
|----------------------------------------------------------------------------|-------------------------------------------|---------------------------------|
| CLI `-dbhost`, `-rplSet`, `-dbTimeout`, `-dbuser`, `-dbAuthMech`, `-dbAuthDb`, `-dbSSL` and `-dbDisableRetryWrites` (and associated env vars) | Not yet defined | Not yet defined |
| `attributes` field in `POST /v2/entities` operation | Not yet defined | Not yet defined |
| `APPEND`, `UPDATE`, etc. action types in `POST /v2/op/update` | Not yet defined | Not yet defined |
| `dateCreated` and `dateModified` in `options` URI parameter | Not yet defined | Not yet defined |
| `GET /v2` operation | Not yet defined | Not yet defined |
| `geo:point`, `geo:line`, `geo:box` and `geo:polygon` attribute types | Not yet defined | Not yet defined |
| CLI `-dbhost`, `-rplSet`, `-dbTimeout`, `-dbuser`, `-dbAuthMech`, `-dbAuthDb`, `-dbSSL` and `-dbDisableRetryWrites` (and associated env vars) | 3.12.0 | February 29th, 2024 |
| `location` metadata to specify entity location | 3.10.1 | June 12th, 2023 |
| NGSIv1 API (along with CLI: `-strictNgsiv1Ids` and `-ngsiv1Autocast`) | 3.9.0 (*) | June 2nd, 2023 |
| `/ngsi10` and `/ngsi9` URL prefixes | 3.7.0 (*) | May 26th, 2022 |
Expand Down
24 changes: 1 addition & 23 deletions src/app/contextBroker/contextBroker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,8 @@ static bool isFatherProcess = false;
bool fg;
char bindAddress[MAX_LEN_IP];
int port;
char dbHost[256];
char rplSet[64];
char dbName[64];
char user[256];
char pwd[256];
char authMech[64];
char authDb[64];
bool dbSSL;
bool dbDisableRetryWrites;
char dbURI[1024];
char pidPath[256];
bool harakiri;
Expand All @@ -159,7 +152,6 @@ bool https;
bool mtenant;
char allowedOrigin[64];
int maxAge;
long dbTimeout;
long httpTimeout;
long mqttTimeout;
int dbPoolSize;
Expand Down Expand Up @@ -298,18 +290,9 @@ PaArgument paArgs[] =
{ "-pidpath", pidPath, "PID_PATH", PaString, PaOpt, PIDPATH, PaNL, PaNL, PIDPATH_DESC },

{ "-dbURI", dbURI, "MONGO_URI", PaString, PaOpt, _i "", PaNL, PaNL, DBURI_DESC },
{ "-dbhost", dbHost, "MONGO_HOST", PaString, PaOpt, LOCALHOST, PaNL, PaNL, DBHOST_DESC },
{ "-rplSet", rplSet, "MONGO_REPLICA_SET", PaString, PaOpt, _i "", PaNL, PaNL, RPLSET_DESC },
{ "-dbuser", user, "MONGO_USER", PaString, PaOpt, _i "", PaNL, PaNL, DBUSER_DESC },
{ "-dbpwd", pwd, "MONGO_PASSWORD", PaString, PaOpt, _i "", PaNL, PaNL, DBPASSWORD_DESC },

{ "-dbAuthMech", authMech, "MONGO_AUTH_MECH", PaString, PaOpt, _i "", PaNL, PaNL, DBAUTHMECH_DESC },
{ "-dbAuthDb", authDb, "MONGO_AUTH_SOURCE", PaString, PaOpt, _i "", PaNL, PaNL, DBAUTHDB_DESC },
{ "-dbSSL", &dbSSL, "MONGO_SSL", PaBool, PaOpt, false, false, true, DBSSL_DESC },
{ "-dbDisableRetryWrites", &dbDisableRetryWrites, "MONGO_DISABLE_RETRY_WRITES", PaBool, PaOpt, false, false, true, DBDISABLERETRYWRITES_DESC },

{ "-db", dbName, "MONGO_DB", PaString, PaOpt, _i "orion", PaNL, PaNL, DB_DESC },
{ "-dbTimeout", &dbTimeout, "MONGO_TIMEOUT", PaULong, PaOpt, 0, 0, UINT_MAX, DB_TMO_DESC },
{ "-dbPoolSize", &dbPoolSize, "MONGO_POOL_SIZE", PaInt, PaOpt, 10, 1, 10000, DBPS_DESC },

{ "-ipv4", &useOnlyIPv4, "USEIPV4", PaBool, PaOpt, false, false, true, USEIPV4_DESC },
Expand Down Expand Up @@ -1133,11 +1116,6 @@ int main(int argC, char* argV[])
LM_X(1, ("dbName too long (max %d characters)", DB_NAME_MAX_LEN));
}

if ((strlen(authMech) > 0) && (strncmp(authMech, "SCRAM-SHA-1", strlen("SCRAM-SHA-1")) != 0) && (strncmp(authMech, "SCRAM-SHA-256", strlen("SCRAM-SHA-256")) != 0))
{
LM_X(1, ("Fatal Error (-dbAuthMech must be either SCRAM-SHA-1 or SCRAM-SHA-256"));
}

if (useOnlyIPv6 && useOnlyIPv4)
{
LM_X(1, ("Fatal Error (-ipv4 and -ipv6 can not be activated at the same time. They are incompatible)"));
Expand Down Expand Up @@ -1220,7 +1198,7 @@ int main(int argC, char* argV[])
alarmMgr.init(relogAlarms);
mqttMgr.init(mqttTimeout);
orionInit(orionExit, ORION_VERSION, policy, statCounters, statSemWait, statTiming, statNotifQueue, strictIdv1);
mongoInit(dbURI, dbHost, rplSet, dbName, user, pwd, authMech, authDb, dbSSL, dbDisableRetryWrites, mtenant, dbTimeout, writeConcern, dbPoolSize, statSemWait);
mongoInit(dbURI, dbName, pwd, mtenant, writeConcern, dbPoolSize, statSemWait);
metricsMgr.init(!disableMetrics, statSemWait);
logSummaryInit(&lsPeriod);

Expand Down
16 changes: 0 additions & 16 deletions src/lib/mongoBackend/MongoGlobal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,9 @@ bool mongoMultitenant(void)
void mongoInit
(
const char* dbURI,
const char* dbHost,
const char* rplSet,
std::string dbName,
const char* user,
const char* pwd,
const char* mechanism,
const char* authDb,
bool dbSSL,
bool dbDisableRetryWrites,
bool mtenant,
int64_t timeout,
int writeConcern,
int dbPoolSize,
bool mutexTimeStat
Expand All @@ -125,17 +117,9 @@ void mongoInit
multitenant = mtenant;

if (orion::mongoConnectionPoolInit(dbURI,
dbHost,
dbName.c_str(),
rplSet,
user,
pwd,
mechanism,
authDb,
dbSSL,
dbDisableRetryWrites,
mtenant,
timeout,
writeConcern,
dbPoolSize,
mutexTimeStat) != 0)
Expand Down
8 changes: 0 additions & 8 deletions src/lib/mongoBackend/MongoGlobal.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,9 @@ extern bool mongoMultitenant(void);
void mongoInit
(
const char* dbURI,
const char* dbHost,
const char* rplSet,
std::string dbName,
const char* user,
const char* pwd,
const char* mechanism,
const char* authDb,
bool dbSSL,
bool dbDisableRetryWrites,
bool mtenant,
int64_t timeout,
int writeConcern,
int dbPoolSize,
bool mutexTimeStat
Expand Down
100 changes: 10 additions & 90 deletions src/lib/mongoDriver/mongoConnectionPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,100 +312,28 @@ static void mongoDriverLogger

/* ****************************************************************************
*
* mongoConnectionPoolInit -
* composeMongoUri -
*/
static std::string composeMongoUri
(
const char* dbURI,
const char* host,
const char* rplSet,
const char* username,
const char* passwd,
const char* mechanism,
const char* authDb,
bool dbSSL,
bool dbDisableRetryWrites,
int64_t timeout
)
static std::string composeMongoUri(const char* dbURI, const char* passwd)
{
// Compose the mongoUri, taking into account all information

std::string uri;

if (strlen(dbURI) != 0)
const char* pwd = strstr(dbURI, "${PWD}");
if (pwd != NULL)
{
if (strlen(username) != 0 || strlen(authDb) != 0 || strlen(rplSet) != 0 || strlen(mechanism) != 0 || dbSSL || dbDisableRetryWrites || timeout > 0)
if (strlen(passwd) == 0)
{
LM_X(1, ("Invalid Command Line Options: -dbURI cannot be combined with -dbhost, -rplSet, -dbTimeout, -dbuser, -dbAuthMech, -dbAuthDb, -dbSSL and -dbDisableRetryWrites"));
LM_X(1, ("Invalid Command Line Options: -dbURI is used with a password substitution, but no password (-dbpwd) is supplied"));
}

const char* pwd = strstr(dbURI, "${PWD}");
if (pwd != NULL)
{
if (strlen(passwd) == 0)
{
LM_X(1, ("Invalid Command Line Options: -dbURI is used with a password substitution, but no password (-dbpwd) is supplied"));
}

// +6 is the length of the "${PWD}"
uri = std::string(dbURI, pwd - dbURI) + passwd + (pwd + 6);
}
else
{
uri = dbURI;
}
// +6 is the length of the "${PWD}"
uri = std::string(dbURI, pwd - dbURI) + passwd + (pwd + 6);
}
else
{
uri = "mongodb://";

// Add auth parameter if included
if (strlen(username) != 0 && strlen(passwd) != 0)
{
uri += username + std::string(":") + passwd + "@";
}

uri += host + std::string("/");

if (strlen(authDb) != 0)
{
uri += authDb;
}

// First option prefix is '?' symbol
std::string optionPrefix = "?";

if (strlen(rplSet) != 0)
{
uri += optionPrefix + "replicaSet=" + rplSet;
optionPrefix = "&";
}

if (strlen(mechanism) != 0)
{
uri += optionPrefix + "authMechanism=" + mechanism;
optionPrefix = "&";
}

if (dbSSL)
{
uri += optionPrefix + "tls=true&tlsAllowInvalidCertificates=true";
optionPrefix = "&";
}

if (dbDisableRetryWrites)
{
uri += optionPrefix + "retryWrites=false";
optionPrefix = "&";
}

if (timeout > 0)
{
char buf[STRING_SIZE_FOR_LONG];
i2s(timeout, buf, sizeof(buf));
uri += optionPrefix + "connectTimeoutMS=" + buf;
optionPrefix = "&";
}
uri = dbURI;
}

LM_T(LmtMongo, ("MongoDB connection URI: '%s'", offuscatePassword(uri, passwd).c_str()));
Expand All @@ -422,17 +350,9 @@ static std::string composeMongoUri
int orion::mongoConnectionPoolInit
(
const char* dbURI,
const char* host,
const char* db,
const char* rplSet,
const char* username,
const char* passwd,
const char* mechanism,
const char* authDb,
bool dbSSL,
bool dbDisableRetryWrites,
bool mtenant,
int64_t timeout,
int writeConcern,
int poolSize,
bool semTimeStat
Expand All @@ -451,7 +371,7 @@ int orion::mongoConnectionPoolInit
atexit(shutdownClient);

// Set mongo Uri to connect
std::string uri = composeMongoUri(dbURI, host, rplSet, username, passwd, mechanism, authDb, dbSSL, dbDisableRetryWrites, timeout);
std::string uri = composeMongoUri(dbURI, passwd);

#ifdef UNIT_TEST
/* Basically, we are mocking all the DB pool with a single connection. The getMongoConnection() and mongoReleaseConnection() methods
Expand Down
8 changes: 0 additions & 8 deletions src/lib/mongoDriver/mongoConnectionPool.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,9 @@ extern void mongoVersionGet(int* mayor, int* minor);
extern int mongoConnectionPoolInit
(
const char* dbURI,
const char* host,
const char* db,
const char* rplSet,
const char* username,
const char* passwd,
const char* mechanism,
const char* authDb,
bool dbSSL,
bool dbDisableRetryWrites,
bool mtenant,
int64_t timeout,
int writeConcern = 1,
int poolSize = 10,
bool semTimeStat = false
Expand Down
18 changes: 2 additions & 16 deletions test/unittests/main_UnitTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,8 @@ unsigned long logLineMaxSize = 32 * 1024;
bool logDeprecate = false;

char dbURI[1024];
char dbHost[256];
char rplSet[64];
char dbName[64];
char user[64];
char pwd[64];
char authMech[64];
char authDb[64];
bool dbSSL;
int64_t dbTimeout;
int dbPoolSize;
int writeConcern;
char gtest_filter[1024];
Expand All @@ -109,15 +102,8 @@ unsigned long fcMaxInterval = 0;
PaArgument paArgs[] =
{
{ "-dbURI", dbURI, "DB_URI", PaString, PaOpt, (int64_t) "", PaNL, PaNL, "" },
{ "-dbhost", dbHost, "DB_HOST", PaString, PaOpt, (int64_t) "localhost", PaNL, PaNL, "" },
{ "-rplSet", rplSet, "RPL_SET", PaString, PaOpt, (int64_t) "", PaNL, PaNL, "" },
{ "-dbuser", user, "DB_USER", PaString, PaOpt, (int64_t) "", PaNL, PaNL, "" },
{ "-dbpwd", pwd, "DB_PASSWORD", PaString, PaOpt, (int64_t) "", PaNL, PaNL, "" },
{ "-dbAuthMech", authMech, "DB_AUTH_MECH", PaString, PaOpt, (int64_t) "", PaNL, PaNL, "" },
{ "-dbAuthDb", authDb, "DB_AUTH_DB", PaString, PaOpt, (int64_t) "", PaNL, PaNL, "" },
{ "-dbSSL", &dbSSL, "DB_AUTH_SSL", PaBool, PaOpt, false, false, true, "" },
{ "-db", dbName, "DB", PaString, PaOpt, (int64_t) "orion", PaNL, PaNL, "" },
{ "-dbTimeout", &dbTimeout, "DB_TIMEOUT", PaInt64, PaOpt, 0, PaNL, PaNL, "" },
{ "-dbPoolSize", &dbPoolSize, "DB_POOL_SIZE", PaInt, PaOpt, 10, 1, 10000, "" },
{ "-writeConcern", &writeConcern, "WRITE_CONCERN", PaInt, PaOpt, 1, 0, 1, "" },
{ "--gtest_filter=", gtest_filter, "", PaString, PaOpt, (int64_t) "", PaNL, PaNL, "" },
Expand Down Expand Up @@ -159,8 +145,8 @@ int main(int argC, char** argV)

LM_M(("Init tests"));
orionInit(exitFunction, orionUnitTestVersion, SemReadWriteOp, false, false, false, false, false);
// Note that disableRetryTries, multitenancy and mutex time stats are disabled for unit test mongo init
mongoInit(dbURI, dbHost, rplSet, dbName, user, pwd, authMech, authDb, dbSSL, false, false, dbTimeout, writeConcern, dbPoolSize, false);
// Note that multitenancy and mutex time stats are disabled for unit test mongo init
mongoInit(dbURI, dbName, pwd, false, writeConcern, dbPoolSize, false);
alarmMgr.init(false);
logSummaryInit(&lsPeriod);
// setupDatabase(); FIXME #3775: pending on mongo unit test re-enabling
Expand Down

0 comments on commit 82941cc

Please sign in to comment.