Skip to content

Commit 52a5c4f

Browse files
committed
Merge branch 'release.24.10' into release.24.12
2 parents 38107a5 + a4b4caa commit 52a5c4f

9 files changed

+145
-60
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ Fixes:
77
Features:
88
- [user-management] Global admins can now disable 2FA for individual users
99

10+
Fixes:
11+
- [gridfs] fixes for moving to Promises
12+
1013
Dependencies:
1114
- Bump express from 4.21.1 to 4.21.2
1215
- Bump mocha from 10.2.0 to 10.8.2

Dockerfile-api

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:hydrogen-bullseye-slim
1+
FROM node:iron-bookworm-slim
22

33
ARG COUNTLY_PLUGINS=mobile,web,desktop,plugins,density,locale,browser,sources,views,logger,systemlogs,populator,reports,crashes,push,star-rating,slipping-away-users,compare,server-stats,dbviewer,times-of-day,compliance-hub,alerts,onboarding,consolidate,remote-config,hooks,dashboards,sdk,data-manager,guides
44
# Countly Enterprise:
@@ -25,15 +25,14 @@ COPY . .
2525

2626
# install required dependencies which slim image doesn't have
2727
RUN apt-get update && \
28-
apt-get install -y iputils-ping procps net-tools telnet apt-transport-https curl wget git python2 make gcc g++ unzip && \
29-
ln -s /usr/bin/python2.7 /usr/bin/python
28+
apt-get install -y iputils-ping procps net-tools telnet apt-transport-https curl wget git make gcc g++ unzip xz-utils
3029

3130
RUN apt-get update && \
3231
apt-get upgrade -y && \
3332
cd /usr/src && \
3433
wget https://www.python.org/ftp/python/3.8.12/Python-3.8.12.tar.xz && \
3534
tar -xf Python-3.8.12.tar.xz && \
36-
apt-get install -y build-essential sudo zlib1g-dev libssl1.1 libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libsqlite3-dev libreadline-dev libffi-dev curl libbz2-dev && \
35+
apt-get install -y build-essential sudo zlib1g-dev libssl3 libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libsqlite3-dev libreadline-dev libffi-dev curl libbz2-dev && \
3736
cd Python-3.8.12 && \
3837
./configure --enable-optimizations --enable-shared && \
3938
make && \
@@ -51,14 +50,15 @@ RUN curl -s -L -o /tmp/tini.deb "https://github.com/krallin/tini/releases/downlo
5150
# preinstall
5251
cp -n ./api/config.sample.js ./api/config.js && \
5352
cp -n ./frontend/express/config.sample.js ./frontend/express/config.js && \
53+
HOME=/tmp npm install -g npm@latest && \
5454
HOME=/tmp npm install --unsafe-perm=true --allow-root && \
5555
HOME=/tmp npm install argon2 --build-from-source --unsafe-perm=true --allow-root && \
5656
./bin/docker/preinstall.sh && \
5757
bash /opt/countly/bin/scripts/detect.init.sh && \
5858
\
5959
# cleanup & chown
6060
npm remove -y --no-save mocha nyc should supertest && \
61-
apt-get remove -y git gcc g++ make automake autoconf libtool pkg-config unzip sqlite3 && \
61+
apt-get remove -y git gcc g++ make automake autoconf libtool pkg-config unzip sqlite3 wget && \
6262
apt-get install -y libgbm-dev libgbm1 gconf-service libasound2 libatk1.0-0 libatk-bridge2.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils && \
6363
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
6464
rm -rf test /tmp/* /tmp/.??* /var/tmp/* /var/tmp/.??* /var/log/* /root/.npm && \

Dockerfile-centos-api

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ RUN yum update -y
3434
RUN curl -s -L -o /tmp/tini.rpm "https://github.com/krallin/tini/releases/download/v${TINI_VERSION}/tini_${TINI_VERSION}.rpm" && \
3535
rpm -i /tmp/tini.rpm && \
3636
\
37-
curl -sL https://rpm.nodesource.com/setup_18.x | bash - && \
37+
curl -sL https://rpm.nodesource.com/setup_20.x | bash - && \
3838
yum install -y nodejs python3.8 python2 python38-libs python38-devel python38-pip nss libdrm libgbm cyrus-sasl* && \
3939
ln -s /usr/bin/node /usr/bin/nodejs && \
4040
unlink /usr/bin/python3 && \
@@ -53,6 +53,7 @@ RUN curl -s -L -o /tmp/tini.rpm "https://github.com/krallin/tini/releases/downlo
5353
# preinstall
5454
cp -n ./api/config.sample.js ./api/config.js && \
5555
cp -n ./frontend/express/config.sample.js ./frontend/express/config.js && \
56+
HOME=/tmp npm install -g npm@latest && \
5657
HOME=/tmp npm install --unsafe-perm=true --allow-root && \
5758
HOME=/tmp npm install argon2 --build-from-source --unsafe-perm=true --allow-root && \
5859
./bin/docker/preinstall.sh && \

Dockerfile-centos-frontend

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ RUN yum update -y
3232
RUN curl -s -L -o /tmp/tini.rpm "https://github.com/krallin/tini/releases/download/v${TINI_VERSION}/tini_${TINI_VERSION}.rpm" && \
3333
rpm -i /tmp/tini.rpm && \
3434
\
35-
curl -sL https://rpm.nodesource.com/setup_18.x | bash - && \
35+
curl -sL https://rpm.nodesource.com/setup_20.x | bash - && \
3636
yum install -y nodejs python3.8 python2 python38-libs python38-devel python38-pip nss libdrm libgbm cyrus-sasl* && \
3737
ln -s /usr/bin/node /usr/bin/nodejs && \
3838
unlink /usr/bin/python3 && \
@@ -52,6 +52,7 @@ RUN curl -s -L -o /tmp/tini.rpm "https://github.com/krallin/tini/releases/downlo
5252
cp -n ./frontend/express/public/javascripts/countly/countly.config.sample.js ./frontend/express/public/javascripts/countly/countly.config.js && \
5353
cp -n ./frontend/express/config.sample.js ./frontend/express/config.js && \
5454
cp -n ./api/config.sample.js ./api/config.js && \
55+
HOME=/tmp npm install -g npm@latest && \
5556
HOME=/tmp npm install --unsafe-perm=true --allow-root && \
5657
HOME=/tmp npm install argon2 --build-from-source --unsafe-perm=true --allow-root && \
5758
./bin/docker/preinstall.sh && \

Dockerfile-core

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ RUN useradd -r -M -U -d /opt/countly -s /bin/false countly && \
4040
gcc g++ make binutils autoconf automake autotools-dev libtool pkg-config zlib1g-dev libcunit1-dev libssl-dev libxml2-dev libev-dev \
4141
libevent-dev libjansson-dev libjemalloc-dev cython python3-dev python-setuptools && \
4242
# node
43-
wget -qO- https://deb.nodesource.com/setup_18.x | bash - && \
43+
wget -qO- https://deb.nodesource.com/setup_20.x | bash - && \
4444
# data_migration (mongo clients)
4545
wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | sudo apt-key add - && \
4646
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list && \

Dockerfile-frontend

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:hydrogen-bullseye-slim
1+
FROM node:iron-bookworm-slim
22

33
ARG COUNTLY_PLUGINS=mobile,web,desktop,plugins,density,locale,browser,sources,views,logger,systemlogs,populator,reports,crashes,push,star-rating,slipping-away-users,compare,server-stats,dbviewer,times-of-day,compliance-hub,alerts,onboarding,consolidate,remote-config,hooks,dashboards,sdk,data-manager,guides
44
# Countly Enterprise:
@@ -21,15 +21,14 @@ WORKDIR /opt/countly
2121
COPY . .
2222
# install required dependencies which slim image doesn't have
2323
RUN apt-get update && \
24-
apt-get install -y iputils-ping net-tools telnet apt-transport-https procps curl wget git python2 make gcc g++ unzip && \
25-
ln -s /usr/bin/python2.7 /usr/bin/python
24+
apt-get install -y iputils-ping net-tools telnet apt-transport-https procps curl wget git make gcc g++ unzip xz-utils
2625

2726
RUN apt-get update && \
2827
apt-get upgrade -y && \
2928
cd /usr/src && \
3029
wget https://www.python.org/ftp/python/3.8.12/Python-3.8.12.tar.xz && \
3130
tar -xf Python-3.8.12.tar.xz && \
32-
apt-get install -y build-essential sudo zlib1g-dev libssl1.1 libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libsqlite3-dev libreadline-dev libffi-dev curl libbz2-dev && \
31+
apt-get install -y build-essential sudo zlib1g-dev libssl3 libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libsqlite3-dev libreadline-dev libffi-dev curl libbz2-dev && \
3332
cd Python-3.8.12 && \
3433
./configure --enable-optimizations --enable-shared && \
3534
make && \
@@ -48,6 +47,7 @@ RUN curl -s -L -o /tmp/tini.deb "https://github.com/krallin/tini/releases/downlo
4847
cp -n ./api/config.sample.js ./api/config.js && \
4948
cp -n ./frontend/express/config.sample.js ./frontend/express/config.js && \
5049
cp -n ./frontend/express/public/javascripts/countly/countly.config.sample.js ./frontend/express/public/javascripts/countly/countly.config.js && \
50+
HOME=/tmp npm install -g npm@latest && \
5151
HOME=/tmp npm install --unsafe-perm=true --allow-root && \
5252
HOME=/tmp npm install argon2 --build-from-source --unsafe-perm=true --allow-root && \
5353
./bin/docker/preinstall.sh && \
@@ -56,7 +56,7 @@ RUN curl -s -L -o /tmp/tini.deb "https://github.com/krallin/tini/releases/downlo
5656
\
5757
# cleanup & chown
5858
npm remove -y --no-save mocha nyc should supertest puppeteer && \
59-
apt-get remove -y git gcc g++ make automake autoconf libtool pkg-config unzip sqlite3 && \
59+
apt-get remove -y git gcc g++ make automake autoconf libtool pkg-config unzip sqlite3 wget && \
6060
apt-get autoremove -y && \
6161
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
6262
rm -rf test /tmp/* /tmp/.??* /var/tmp/* /var/tmp/.??* /var/log/* /root/.npm && \

api/utils/countlyFs.js

+71-42
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ countlyFs.gridfs = {};
6868
**/
6969
function beforeSave(category, filename, options, callback, done) {
7070
log.d("checking file", filename);
71-
ob.getId(category, filename, function(err, res) {
71+
ob.getId(category, filename, async function(err, res) {
7272
log.d("file state", filename, err, res);
7373
if (options.forceClean) {
7474
ob.clearFile(category, filename, done);
@@ -80,15 +80,20 @@ countlyFs.gridfs = {};
8080
else if (options.writeMode === "overwrite") {
8181
var bucket = new GridFSBucket(db, { bucketName: category });
8282
log.d("deleting file", filename);
83-
bucket.delete(res, function(error) {
84-
log.d("deleted", filename, error);
85-
if (!error) {
86-
setTimeout(done, 1);
87-
}
88-
else if (callback) {
89-
callback(error);
90-
}
91-
});
83+
let errHandle = null;
84+
try {
85+
await bucket.delete(res);
86+
}
87+
catch (error) {
88+
errHandle = error;
89+
}
90+
log.d("deleted", filename, errHandle);
91+
if (!errHandle) {
92+
setTimeout(done, 1);
93+
}
94+
else if (callback) {
95+
callback(errHandle);
96+
}
9297
}
9398
else {
9499
if (callback) {
@@ -116,6 +121,7 @@ countlyFs.gridfs = {};
116121
* });
117122
*/
118123
ob.getId = function(category, filename, callback) {
124+
log.d("getId", category, filename);
119125
db.collection(category + ".files").findOne({ filename: filename }, {_id: 1}, function(err, res) {
120126
if (callback) {
121127
callback(err, (res && res._id) ? res._id : false);
@@ -144,6 +150,7 @@ countlyFs.gridfs = {};
144150
if (!options) {
145151
options = {};
146152
}
153+
log.d("exists", category, dest, options);
147154
var query = {};
148155
if (options.id) {
149156
query._id = options.id;
@@ -184,7 +191,7 @@ countlyFs.gridfs = {};
184191
if (!options) {
185192
options = {};
186193
}
187-
194+
log.d("saveFile", category, dest, source, options);
188195
var filename = dest.split(path.sep).pop();
189196
beforeSave(category, filename, options, callback, function() {
190197
save(category, filename, fs.createReadStream(source), options, callback);
@@ -218,6 +225,7 @@ countlyFs.gridfs = {};
218225
if (!options) {
219226
options = {};
220227
}
228+
log.d("saveData", category, dest, typeof data, options);
221229
beforeSave(category, filename, options, callback, function() {
222230
var readStream = new Readable;
223231
readStream.push(data);
@@ -253,6 +261,7 @@ countlyFs.gridfs = {};
253261
if (!options) {
254262
options = {};
255263
}
264+
log.d("saveStream", category, dest, typeof readStream, options);
256265
beforeSave(category, filename, options, callback, function() {
257266
save(category, filename, readStream, options, callback);
258267
});
@@ -271,7 +280,7 @@ countlyFs.gridfs = {};
271280
* console.log("Finished", err);
272281
* });
273282
*/
274-
ob.rename = function(category, dest, source, options, callback) {
283+
ob.rename = async function(category, dest, source, options, callback) {
275284
var newname = dest.split(path.sep).pop();
276285
var oldname = source.split(path.sep).pop();
277286
if (typeof options === "function") {
@@ -281,25 +290,35 @@ countlyFs.gridfs = {};
281290
if (!options) {
282291
options = {};
283292
}
284-
293+
log.d("rename", category, dest, source, options);
285294
if (options.id) {
286295
let bucket = new GridFSBucket(db, { bucketName: category });
287-
bucket.rename(options.id, newname, function(error) {
288-
if (callback) {
289-
callback(error);
290-
}
291-
});
296+
let errHandle = null;
297+
try {
298+
await bucket.rename(options.id, newname);
299+
}
300+
catch (error) {
301+
errHandle = error;
302+
}
303+
if (callback) {
304+
callback(errHandle);
305+
}
292306
}
293307
else {
294-
db.collection(category + ".files").findOne({ filename: oldname }, {_id: 1}, function(err, res) {
308+
db.collection(category + ".files").findOne({ filename: oldname }, {_id: 1}, async function(err, res) {
295309
if (!err) {
296310
if (res && res._id) {
297311
let bucket = new GridFSBucket(db, { bucketName: category });
298-
bucket.rename(res._id, newname, function(error) {
299-
if (callback) {
300-
callback(error);
301-
}
302-
});
312+
let errHandle = null;
313+
try {
314+
await bucket.rename(res._id, newname);
315+
}
316+
catch (error) {
317+
errHandle = error;
318+
}
319+
if (callback) {
320+
callback(errHandle);
321+
}
303322
}
304323
else {
305324
if (callback) {
@@ -391,7 +410,7 @@ countlyFs.gridfs = {};
391410
if (!options) {
392411
options = {};
393412
}
394-
413+
log.d("deleteFile", category, dest, options);
395414
if (options.id) {
396415
ob.deleteFileById(category, options.id, callback);
397416
}
@@ -426,13 +445,19 @@ countlyFs.gridfs = {};
426445
* console.log("Finished", err);
427446
* });
428447
*/
429-
ob.deleteAll = function(category, dest, callback) {
448+
ob.deleteAll = async function(category, dest, callback) {
449+
log.d("deleteAll", category, dest);
430450
var bucket = new GridFSBucket(db, { bucketName: category });
431-
bucket.drop(function(error) {
432-
if (callback) {
433-
callback(error);
434-
}
435-
});
451+
let errHandle = null;
452+
try {
453+
await bucket.drop();
454+
}
455+
catch (error) {
456+
errHandle = error;
457+
}
458+
if (callback) {
459+
callback(errHandle);
460+
}
436461
};
437462

438463
/**
@@ -457,7 +482,7 @@ countlyFs.gridfs = {};
457482
if (!options) {
458483
options = {};
459484
}
460-
485+
log.d("getStream", category, dest, options);
461486
if (callback) {
462487
if (options.id) {
463488
ob.getStreamById(category, options.id, callback);
@@ -490,7 +515,7 @@ countlyFs.gridfs = {};
490515
if (!options) {
491516
options = {};
492517
}
493-
518+
log.d("getData", category, dest, options);
494519
if (options.id) {
495520
ob.getDataById(category, options.id, callback);
496521
}
@@ -536,7 +561,7 @@ countlyFs.gridfs = {};
536561
if (!options) {
537562
options = {};
538563
}
539-
564+
log.d("getSize", category, dest, options);
540565
var query = {};
541566
if (options.id) {
542567
query._id = options.id;
@@ -571,7 +596,7 @@ countlyFs.gridfs = {};
571596
if (!options) {
572597
options = {};
573598
}
574-
599+
log.d("getStats", category, dest, options);
575600
var query = {};
576601
if (options.id) {
577602
query._id = options.id;
@@ -608,6 +633,7 @@ countlyFs.gridfs = {};
608633
* });
609634
*/
610635
ob.getDataById = function(category, id, callback) {
636+
log.d("getDataById", category, id);
611637
var bucket = new GridFSBucket(db, { bucketName: category });
612638
var downloadStream = bucket.openDownloadStream(id);
613639
downloadStream.on('error', function(error) {
@@ -639,6 +665,7 @@ countlyFs.gridfs = {};
639665
* });
640666
*/
641667
ob.getStreamById = function(category, id, callback) {
668+
log.d("getStreamById", category, id);
642669
if (callback) {
643670
var bucket = new GridFSBucket(db, { bucketName: category });
644671
callback(null, bucket.openDownloadStream(id));
@@ -656,17 +683,17 @@ countlyFs.gridfs = {};
656683
* });
657684
*/
658685
ob.deleteFileById = async function(category, id, callback) {
686+
log.d("deleteFileById", category, id);
659687
var bucket = new GridFSBucket(db, { bucketName: category });
688+
let errHandle = null;
660689
try {
661690
await bucket.delete(id);
662-
if (callback) {
663-
callback(null);
664-
}
665691
}
666-
catch (ee) {
667-
if (callback) {
668-
callback(ee);
669-
}
692+
catch (error) {
693+
errHandle = error;
694+
}
695+
if (callback) {
696+
callback(errHandle);
670697
}
671698
};
672699

@@ -681,6 +708,7 @@ countlyFs.gridfs = {};
681708
* });
682709
*/
683710
ob.clearFile = function(category, filename, callback) {
711+
log.d("clearFile", category, filename);
684712
db.collection(category + ".files").deleteMany({ filename: filename }, function(err1, res1) {
685713
log.d("deleting files", category, { filename: filename }, err1, res1 && res1.result);
686714
db.collection(category + ".chunks").deleteMany({ files_id: filename }, function(err2, res2) {
@@ -697,6 +725,7 @@ countlyFs.gridfs = {};
697725
* @param {function} callback - function called when files found or query errored, providing error object as first param and a list of filename, creation date and size as secondas second
698726
*/
699727
ob.listFiles = function(category, callback) {
728+
log.d("listFiles", category);
700729
const bucket = new GridFSBucket(db, { bucketName: category });
701730
bucket.find().toArray()
702731
.then((records) => callback(

0 commit comments

Comments
 (0)