Node JS развернуто в Docker Контейнер в Cloud Run не получает данные из базы данных Mon go - PullRequest
0 голосов
/ 22 апреля 2020

TL: DR - Узел / Express API в Cloud Run не подключается к кластеру mon go в MongoDB Atlas

Наш API Express / Node развертывается в новом Google Cloud Run для контейнерных развертываний. API, при локальном запуске с docker с использованием docker run -p 8080:8080 <image_id>, отлично выбирает данные из нашей базы данных Mon go. Соответствующие журналы из Cloud Run:

2020-04-22T18:15:15.408778Z(node:1) UnhandledPromiseRejectionWarning: MongooseServerSelectionError: connection timed out
2020-04-22T18:15:15.408824Z at new MongooseServerSelectionError (/usr/app/node_modules/mongoose/lib/error/serverSelection.js:22:11)
2020-04-22T18:15:15.408834Z at NativeConnection.Connection.openUri (/usr/app/node_modules/mongoose/lib/connection.js:823:32)
2020-04-22T18:15:15.408844Z at Mongoose.connect (/usr/app/node_modules/mongoose/lib/index.js:333:15)
2020-04-22T18:15:15.408854Z at Object.<anonymous> (/usr/app/models/index.js:11:10)
2020-04-22T18:15:15.408862Z at Module._compile (internal/modules/cjs/loader.js:1123:30)
2020-04-22T18:15:15.408871Z at Object.Module._extensions..js (internal/modules/cjs/loader.js:1143:10)
2020-04-22T18:15:15.408880Z at Module.load (internal/modules/cjs/loader.js:972:32)
2020-04-22T18:15:15.408893Z at Function.Module._load (internal/modules/cjs/loader.js:872:14)
2020-04-22T18:15:15.408902Z at Module.require (internal/modules/cjs/loader.js:1012:19)
2020-04-22T18:15:15.408911Z at require (internal/modules/cjs/helpers.js:72:18)
2020-04-22T18:15:15.408919Z at Object.<anonymous> (/usr/app/config/passport.js:7:12)
2020-04-22T18:15:15.408927Z at Module._compile (internal/modules/cjs/loader.js:1123:30)
2020-04-22T18:15:15.408937Z at Object.Module._extensions..js (internal/modules/cjs/loader.js:1143:10)
2020-04-22T18:15:15.408946Z at Module.load (internal/modules/cjs/loader.js:972:32)
2020-04-22T18:15:15.408954Z at Function.Module._load (internal/modules/cjs/loader.js:872:14)
2020-04-22T18:15:15.408964Z at Module.require (internal/modules/cjs/loader.js:1012:19)
2020-04-22T18:15:15.608498Z(node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
2020-04-22T18:15:15.608686Z(node:1) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

...

2020-04-22T18:19:59.772303ZGET504296 B300.5 sChrome 81 https://node-api-deploy-q62r35344q-uw.a.run.app/api/cbb/home-page-stats
The request has been terminated because it has reached the maximum request timeout. To change this limit, see https://cloud.google.com/run/docs/configuring/request-timeout
2020-04-22T18:20:26.472145ZGET504290 B300 sChrome 81 https://node-api-deploy-q62r35344q-uw.a.run.app/api/cbb/teams/list
The request has been terminated because it has reached the maximum request timeout. To change this limit, see https://cloud.google.com/run/docs/configuring/request-timeout

Поясните, что данные не извлекаются, а запросы истекают. Моя база данных Mon go размещена в MongoDB Atlas, и я ничего конкретно не сделал (белый список IP-адреса сервера облачного запуска и т. Д. c.), Который мне, возможно, придется сделать для этой работы. Облако работает даже имеет IP, или нет, потому что это без сервера ... Может быть, я должен передать URI БД в облако, через переменную env? Я не уверен.

Любая помощь в этом очень приветствуется.

РЕДАКТИРОВАТЬ: Вот соответствующий пост StackOverflow , который также в основном остался без ответа.

...