Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvement/arsn 423 bump dependencies #2266

Open
wants to merge 9 commits into
base: development/8.2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions lib/storage/metadata/mongoclient/LogConsumer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'; // eslint-disable-line

const MongoClient = require('mongodb').MongoClient;
const { MongoClient } = require('mongodb');
const ListRecordStream = require('./ListRecordStream');
const MongoUtils = require('./utils');

Expand All @@ -16,10 +16,11 @@ class LogConsumer {
* @param {string} logger - logger
*/
constructor(mongoConfig, logger) {
const { authCredentials, replicaSetHosts, replicaSet, database } = mongoConfig;
const { authCredentials, replicaSetHosts, replicaSet, database, readPreference } = mongoConfig;
const cred = MongoUtils.credPrefix(authCredentials);
this._mongoUrl = `mongodb://${cred}${replicaSetHosts}/`;
this._replicaSet = replicaSet;
this._readPreference = readPreference;
this._logger = logger;
this._oplogNsRegExp = new RegExp(`^${database}\\.`);
// oplog collection
Expand All @@ -35,27 +36,29 @@ class LogConsumer {
* @return {undefined}
*/
connectMongo(done) {
MongoClient.connect(this._mongoUrl, {
const client = new MongoClient(this._mongoUrl, {
replicaSet: this._replicaSet,
useNewUrlParser: true,
},
(err, client) => {
if (err) {
this._logger.error('Unable to connect to MongoDB',
{ error: err });
return done(err);
}
useUnifiedTopology: true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be needed, I guess this one is deprecated and at least enabled by default, can we check?

readPreference: this._readPreference,
});

client.connect().then(client => {
this._logger.info('connected to mongodb');
// 'local' is the database where MongoDB has oplog.rs
// capped collection
// 'local' is the database where MongoDB has oplog.rs capped collection
const db = client.db('local', {
ignoreUndefined: true,
});
this._coll = db.collection('oplog.rs');
return done();
})
.catch(err => {
this._logger.error('Unable to connect to MongoDB', { error: err });
return done(err);
});
}


/**
* Open a tailable cursor to mongo oplog and retrieve a stream of
* records to read
Expand Down
13 changes: 10 additions & 3 deletions lib/storage/metadata/mongoclient/MongoClientInterface.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const BucketInfo = require('../../../models/BucketInfo').default;
const ObjectMD = require('../../../models/ObjectMD').default;
const jsutil = require('../../../jsutil');

const MongoClient = require('mongodb').MongoClient;
const { MongoClient } = require('mongodb');
const Uuid = require('uuid');
const diskusage = require('diskusage');

Expand Down Expand Up @@ -148,7 +148,9 @@ class MongoClientInterface {
!Number.isNaN(process.env.MONGO_POOL_SIZE)) {
options.poolSize = Number.parseInt(process.env.MONGO_POOL_SIZE, 10);
}
return MongoClient.connect(this.mongoUrl, options)
const client = new MongoClient(this.mongoUrl, options);

return client.connect()
.then(client => {
this.logger.info('connected to mongodb');
this.client = client;
Expand Down Expand Up @@ -477,6 +479,8 @@ class MongoClientInterface {
const m = this.getCollection(METASTORE);
m.findOneAndDelete({
_id: bucketName,
} , {
includeResultMetadata: true
}, {})
.then(result => {
if (result.ok !== 1) {
Expand Down Expand Up @@ -1296,6 +1300,7 @@ class MongoClientInterface {
_id: masterKey,
value: objVal,
}, {
includeResultMetadata: true,
upsert: true,
}).then(result => {
if (result.ok !== 1) {
Expand Down Expand Up @@ -1641,6 +1646,7 @@ class MongoClientInterface {
'value.deleted': true,
},
}, {
includeResultMetadata : true,
upsert: false,
}).then(doc => {
if (!doc.value) {
Expand Down Expand Up @@ -2645,8 +2651,9 @@ class MongoClientInterface {
value: objVal,
},
}, {
includeResultMetadata: true,
upsert: true,
}).then(res => {
},).then(res => {
if (res.ok !== 1) {
log.error('failed to update object', {
method,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"joi": "^17.13.3",
"level": "~5.0.1",
"level-sublevel": "~6.6.5",
"mongodb": "^5.2.0",
"mongodb": "^6.11.0",
"node-forge": "^1.3.1",
"prom-client": "^15.1.3",
"simple-glob": "^0.2.0",
Expand Down
Loading
Loading