novuhq / novu

Open-Source Notification Platform. Embeddable Notification Center, E-mail, Push and Slack Integrations.
https://novu.co
Other
34.37k stars 3.5k forks source link

πŸ› Bug Report: Unable to deploy to Openshift #5412

Open victorcarnaval opened 4 months ago

victorcarnaval commented 4 months ago

πŸ“œ Description

Some scripts that are run as root user, such as npm i pm2 -g, are not feasible on the OpenShift infrastructure due to non-root rules. Is it possible to adopt a different approach without changing the OpenShift user policies? Are you considering modifying the base image to one that already includes PM2?

πŸ‘Ÿ Reproduction steps

  1. Apply the following deployment file with the Novu API image on OpenShift.
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: novu-api
  name: novu-api
spec:
  replicas: 1
  selector:
    matchLabels:
      app: novu-api
  template:
    metadata:
      labels:
        app: novu-api
    spec:
      containers:
        - envFrom:
            - configMapRef:
                name: novu-cfg
          image: ghcr.io/novuhq/novu/api:0.22.0
          name: api
          livenessProbe:
            httpGet:
              path: /v1/health-check
              port: 3000
            initialDelaySeconds: 300
            periodSeconds: 300
          resources:
            limits:
              cpu: 400m
              memory: 500Mi
            requests:
              cpu: 200m
              memory: 200Mi

πŸ‘ Expected behavior

The pod is expected to start without any errors.

πŸ‘Ž Actual Behavior with Screenshots

Error: EACCES: permission denied, mkdir '/.pm2/logs'
    at Object.mkdirSync (node:fs:1382:3)
    at mkdirpNativeSync (/usr/local/lib/node_modules/pm2/node_modules/mkdirp/lib/mkdirp-native.js:29:10)
    at Function.mkdirpSync [as sync] (/usr/local/lib/node_modules/pm2/node_modules/mkdirp/index.js:21:7)
    at module.exports.Client.initFileStructure (/usr/local/lib/node_modules/pm2/lib/Client.js:133:25)
    at new module.exports (/usr/local/lib/node_modules/pm2/lib/Client.js:38:8)
    at new API (/usr/local/lib/node_modules/pm2/lib/API.js:107:19)
    at Object.<anonymous> (/usr/local/lib/node_modules/pm2/index.js:11:18)
    at Module._compile (node:internal/modules/cjs/loader:1198:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1252:10)
    at Module.load (node:internal/modules/cjs/loader:1076:32)
Error: EACCES: permission denied, mkdir '/.pm2/pids'
    at Object.mkdirSync (node:fs:1382:3)
    at mkdirpNativeSync (/usr/local/lib/node_modules/pm2/node_modules/mkdirp/lib/mkdirp-native.js:29:10)
    at Function.mkdirpSync [as sync] (/usr/local/lib/node_modules/pm2/node_modules/mkdirp/index.js:21:7)
    at module.exports.Client.initFileStructure (/usr/local/lib/node_modules/pm2/lib/Client.js:141:25)
    at new module.exports (/usr/local/lib/node_modules/pm2/lib/Client.js:38:8)
    at new API (/usr/local/lib/node_modules/pm2/lib/API.js:107:19)
    at Object.<anonymous> (/usr/local/lib/node_modules/pm2/index.js:11:18)
    at Module._compile (node:internal/modules/cjs/loader:1198:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1252:10)
    at Module.load (node:internal/modules/cjs/loader:1076:32)
Error: ENOENT: no such file or directory, open '/.pm2/module_conf.json'
    at Object.openSync (node:fs:590:3)
    at Object.writeFileSync (node:fs:2202:35)
    at module.exports.Client.initFileStructure (/usr/local/lib/node_modules/pm2/lib/Client.js:149:10)
    at new module.exports (/usr/local/lib/node_modules/pm2/lib/Client.js:38:8)
    at new API (/usr/local/lib/node_modules/pm2/lib/API.js:107:19)
    at Object.<anonymous> (/usr/local/lib/node_modules/pm2/index.js:11:18)
    at Module._compile (node:internal/modules/cjs/loader:1198:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1252:10)
    at Module.load (node:internal/modules/cjs/loader:1076:32)
    at Function.Module._load (node:internal/modules/cjs/loader:911:12)
Error: EACCES: permission denied, mkdir '/.pm2/modules'
    at Object.mkdirSync (node:fs:1382:3)
    at mkdirpNativeSync (/usr/local/lib/node_modules/pm2/node_modules/mkdirp/lib/mkdirp-native.js:29:10)
    at Function.mkdirpSync [as sync] (/usr/local/lib/node_modules/pm2/node_modules/mkdirp/index.js:21:7)
    at module.exports.Client.initFileStructure (/usr/local/lib/node_modules/pm2/lib/Client.js:157:25)
    at new module.exports (/usr/local/lib/node_modules/pm2/lib/Client.js:38:8)
    at new API (/usr/local/lib/node_modules/pm2/lib/API.js:107:19)
    at Object.<anonymous> (/usr/local/lib/node_modules/pm2/index.js:11:18)
    at Module._compile (node:internal/modules/cjs/loader:1198:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1252:10)
    at Module.load (node:internal/modules/cjs/loader:1076:32)
Error: ENOENT: no such file or directory, open '/.pm2/module_conf.json'
    at Object.openSync (node:fs:590:3)
    at Object.readFileSync (node:fs:458:35)
    at Object.Configuration.getAllSync (/usr/local/lib/node_modules/pm2/lib/Configuration.js:299:26)
    at Object.Configuration.getSync (/usr/local/lib/node_modules/pm2/lib/Configuration.js:270:30)
    at new API (/usr/local/lib/node_modules/pm2/lib/API.js:116:44)
    at Object.<anonymous> (/usr/local/lib/node_modules/pm2/index.js:11:18)
    at Module._compile (node:internal/modules/cjs/loader:1198:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1252:10)
    at Module.load (node:internal/modules/cjs/loader:1076:32)
    at Function.Module._load (node:internal/modules/cjs/loader:911:12)
Error: EACCES: permission denied, mkdir '/.pm2/logs'
    at Object.mkdirSync (node:fs:1382:3)
    at mkdirpNativeSync (/usr/local/lib/node_modules/pm2/node_modules/mkdirp/lib/mkdirp-native.js:29:10)
    at Function.mkdirpSync [as sync] (/usr/local/lib/node_modules/pm2/node_modules/mkdirp/index.js:21:7)
    at module.exports.Client.initFileStructure (/usr/local/lib/node_modules/pm2/lib/Client.js:133:25)
    at new module.exports (/usr/local/lib/node_modules/pm2/lib/Client.js:38:8)
    at new API (/usr/local/lib/node_modules/pm2/lib/API.js:107:19)
    at Object.instanciate (/usr/local/lib/node_modules/pm2/lib/binaries/Runtime4Docker.js:65:16)
    at Command.<anonymous> (/usr/local/lib/node_modules/pm2/lib/binaries/Runtime4Docker.js:54:13)
    at Command.listener (/usr/local/lib/node_modules/pm2/node_modules/commander/index.js:315:8)
    at Command.emit (node:events:513:28)
Error: EACCES: permission denied, mkdir '/.pm2/pids'
    at Object.mkdirSync (node:fs:1382:3)
    at mkdirpNativeSync (/usr/local/lib/node_modules/pm2/node_modules/mkdirp/lib/mkdirp-native.js:29:10)
    at Function.mkdirpSync [as sync] (/usr/local/lib/node_modules/pm2/node_modules/mkdirp/index.js:21:7)
    at module.exports.Client.initFileStructure (/usr/local/lib/node_modules/pm2/lib/Client.js:141:25)
    at new module.exports (/usr/local/lib/node_modules/pm2/lib/Client.js:38:8)
    at new API (/usr/local/lib/node_modules/pm2/lib/API.js:107:19)
    at Object.instanciate (/usr/local/lib/node_modules/pm2/lib/binaries/Runtime4Docker.js:65:16)
    at Command.<anonymous> (/usr/local/lib/node_modules/pm2/lib/binaries/Runtime4Docker.js:54:13)
    at Command.listener (/usr/local/lib/node_modules/pm2/node_modules/commander/index.js:315:8)
    at Command.emit (node:events:513:28)
Error: ENOENT: no such file or directory, open '/.pm2/module_conf.json'
    at Object.openSync (node:fs:590:3)
    at Object.writeFileSync (node:fs:2202:35)
    at module.exports.Client.initFileStructure (/usr/local/lib/node_modules/pm2/lib/Client.js:149:10)
    at new module.exports (/usr/local/lib/node_modules/pm2/lib/Client.js:38:8)
    at new API (/usr/local/lib/node_modules/pm2/lib/API.js:107:19)
    at Object.instanciate (/usr/local/lib/node_modules/pm2/lib/binaries/Runtime4Docker.js:65:16)
    at Command.<anonymous> (/usr/local/lib/node_modules/pm2/lib/binaries/Runtime4Docker.js:54:13)
    at Command.listener (/usr/local/lib/node_modules/pm2/node_modules/commander/index.js:315:8)
    at Command.emit (node:events:513:28)
    at Command.parseArgs (/usr/local/lib/node_modules/pm2/node_modules/commander/index.js:651:12)
Error: EACCES: permission denied, mkdir '/.pm2/modules'
    at Object.mkdirSync (node:fs:1382:3)
    at mkdirpNativeSync (/usr/local/lib/node_modules/pm2/node_modules/mkdirp/lib/mkdirp-native.js:29:10)
    at Function.mkdirpSync [as sync] (/usr/local/lib/node_modules/pm2/node_modules/mkdirp/index.js:21:7)
    at module.exports.Client.initFileStructure (/usr/local/lib/node_modules/pm2/lib/Client.js:157:25)
    at new module.exports (/usr/local/lib/node_modules/pm2/lib/Client.js:38:8)
    at new API (/usr/local/lib/node_modules/pm2/lib/API.js:107:19)
    at Object.instanciate (/usr/local/lib/node_modules/pm2/lib/binaries/Runtime4Docker.js:65:16)
    at Command.<anonymous> (/usr/local/lib/node_modules/pm2/lib/binaries/Runtime4Docker.js:54:13)
    at Command.listener (/usr/local/lib/node_modules/pm2/node_modules/commander/index.js:315:8)
    at Command.emit (node:events:513:28)
Error: ENOENT: no such file or directory, open '/.pm2/module_conf.json'
    at Object.openSync (node:fs:590:3)
    at Object.readFileSync (node:fs:458:35)
    at Object.Configuration.getAllSync (/usr/local/lib/node_modules/pm2/lib/Configuration.js:299:26)
    at Object.Configuration.getSync (/usr/local/lib/node_modules/pm2/lib/Configuration.js:270:30)
    at new API (/usr/local/lib/node_modules/pm2/lib/API.js:116:44)
    at Object.instanciate (/usr/local/lib/node_modules/pm2/lib/binaries/Runtime4Docker.js:65:16)
    at Command.<anonymous> (/usr/local/lib/node_modules/pm2/lib/binaries/Runtime4Docker.js:54:13)
    at Command.listener (/usr/local/lib/node_modules/pm2/node_modules/commander/index.js:315:8)
    at Command.emit (node:events:513:28)
    at Command.parseArgs (/usr/local/lib/node_modules/pm2/node_modules/commander/index.js:651:12)
2024-04-15T19:25:28: PM2 error: Error: ENOENT: no such file or directory, open '/.pm2/module_conf.json'
    at Object.openSync (node:fs:590:3)
    at Object.readFileSync (node:fs:458:35)
    at Object.Configuration.getAllSync (/usr/local/lib/node_modules/pm2/lib/Configuration.js:299:26)
    at Object.Configuration.getSync (/usr/local/lib/node_modules/pm2/lib/Configuration.js:270:30)
    at Object.God.init (/usr/local/lib/node_modules/pm2/lib/God.js:71:38)
    at Object.<anonymous> (/usr/local/lib/node_modules/pm2/lib/God.js:574:5)
    at Module._compile (node:internal/modules/cjs/loader:1198:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1252:10)
    at Module.load (node:internal/modules/cjs/loader:1076:32)
    at Function.Module._load (node:internal/modules/cjs/loader:911:12)
2024-04-15T19:25:28: PM2 log: Launching in no daemon mode
2024-04-15T19:25:28: PM2 error: Error: ENOENT: no such file or directory, open '/.pm2/pm2.pid'
    at Object.openSync (node:fs:590:3)
    at Object.writeFileSync (node:fs:2202:35)
    at module.exports.Daemon.innerStart (/usr/local/lib/node_modules/pm2/lib/Daemon.js:91:8)
    at /usr/local/lib/node_modules/pm2/lib/Client.js:78:14
    at /usr/local/lib/node_modules/pm2/lib/Client.js:321:14
    at processTicksAndRejections (node:internal/process/task_queues:78:11)
    at runNextTicks (node:internal/process/task_queues:65:3)
    at listOnTimeout (node:internal/timers:528:9)
    at processTimers (node:internal/timers:502:7)

Novu version

0.22 (self-hosted on Openshift)

npm version

10.5.0

node version

v20.11.1

πŸ“ƒ Provide any additional context for the Bug.

No response

πŸ‘€ Have you spent some time to check if this bug has been raised before?

🏒 Have you read the Contributing Guidelines?

Are you willing to submit PR?

Yes I am willing to submit a PR!

linear[bot] commented 4 months ago

NV-3656 πŸ› Bug Report: Unable to deploy to Openshift