SchwarzIT / node-red-chart

Node-red Helm Chart
Apache License 2.0
38 stars 25 forks source link

npm installs fail if hardlinks not supported on file system #196

Closed beasteers closed 1 year ago

beasteers commented 1 year ago

What happened?

I'm running this on AKS using Azure Files for persistence, which doesn't support hard links. If I enable persistence on /data, I start getting errors when I try to run npm install (either through the manage palette page or running npm i manually).

Error log

2023-01-03T21:46:21.478Z npm install --no-audit --no-update-notifier --no-fund --save --save-prefix=~ --production --engine-strict node-red-contrib-postgresql@0.11.3
2023-01-03T21:46:22.189Z [err] npm
2023-01-03T21:46:22.189Z [err]  WARN
2023-01-03T21:46:22.189Z [err]  config production Use `--omit=dev` instead.
2023-01-03T21:46:22.644Z [err] npm
2023-01-03T21:46:22.644Z [err]  ERR! code ENOTSUP
2023-01-03T21:46:22.644Z [err] npm
2023-01-03T21:46:22.644Z [err]  ERR!
2023-01-03T21:46:22.644Z [err]  syscall link
2023-01-03T21:46:22.644Z [err] npm ERR!
2023-01-03T21:46:22.644Z [err]  
2023-01-03T21:46:22.645Z [err] path /data/.npm/_cacache/tmp/78da15c8
2023-01-03T21:46:22.645Z [err] npm ERR! dest /data/.npm/_cacache/content-v2/sha512/71/6f/d7852a119e0ba4879feb7f584dc48ed54bd579c78f809b3af2188d89a3fc5fd14a421e419c3fa720905d8b7b5f2f42c76816907b0a160a50c78c3d57825b
2023-01-03T21:46:22.645Z [err] npm ERR! errno ENOTSUP
2023-01-03T21:46:22.647Z [err] npm ERR! Invalid response body while trying to fetch https://registry.npmjs.org/node-red-contrib-postgresql: ENOTSUP: operation not supported on socket, link '/data/.npm/_cacache/tmp/78da15c8' -> '/data/.npm/_cacache/content-v2/sha512/71/6f/d7852a119e0ba4879feb7f584dc48ed54bd579c78f809b3af2188d89a3fc5fd14a421e419c3fa720905d8b7b5f2f42c76816907b0a160a50c78c3d57825b'
2023-01-03T21:46:22.648Z [err] 
2023-01-03T21:46:22.648Z [err] npm ERR!
2023-01-03T21:46:22.648Z [err]  A complete log of this run can be found in:
2023-01-03T21:46:22.648Z [err] npm ERR!     /data/.npm/_logs/2023-01-03T21_46_22_092Z-debug-0.log
2023-01-03T21:46:22.674Z rc=1

How can we reproduce this?

Here's my configuration

aks storage class (terraform config) and helm chart

resource "kubernetes_storage_class" "nodered" {
  metadata {
    name = "nodered"
  }
  storage_provisioner = "file.csi.azure.com"
  reclaim_policy      = "Retain"
  parameters = {
    skuName = "Standard_LRS"
  }

  mount_options = ["dir_mode=0777", "file_mode=0777", "uid=10003", "gid=10003", "serverino", "mfsymlinks"]
}

resource "helm_release" "nodered" {
  chart      = "node-red"
  name       = "nodered"
  repository = "https://schwarzit.github.io/node-red-chart/"
  namespace  = var.namespace

  values = [
    replace(templatefile("${path.module}/values/nodered.values.yml", {
      domain             = "${var.nodered_subdomain}.${var.domain}"
      settings_config    = kubernetes_config_map.nodered_settings.metadata[0].name
      storage_class_name = kubernetes_storage_class.nodered.metadata[0].name
    }), "/^\\s*#.*\\n?/", "") # removes comment lines :)
  ]
}

values.yaml

metrics:
  enabled: true
persistence:
  enabled: true
  storageClass: "${storage_class_name}"
ingress:
  enabled: true
  annotations: # {}
    kubernetes.io/ingress.class: traefik
    traefik.ingress.kubernetes.io/router.entrypoints: websecure,web
  hosts:
    - host: ${domain}
      paths:
        - path: /
          pathType: ImplementationSpecific
settings:
  name: nodered-settings-config
  configMapName: ${settings_config}

Helm Chart version

0.21.3

Search

Code of Conduct

Additional context

Solution

I was able to solve it by:

  1. allowing the user to write to /usr/src/node-red

    securityContext:
    readOnlyRootFilesystem: false
    runAsGroup: 1000
    runAsUser: 1000
  2. writing this to /usr/src/node-red/.npmrc

    cache="/usr/src/node-red/.cache"

But it would be great if your npmrc: config field accepted a free-text field (e.g. npmrc.contents) to insert values like this from the values.yaml file.

dirien commented 1 year ago

Hi @beasteers,

Thanks for creating the issue!

I added now a new value nmprc.content, where you can set all your custom npmrc config.

npmrc:
  # -- Enable custom npmrc config
  enabled: false
  # -- Configuration to use any compatible registry
  registry: "https://registry.npmjs.org"
  # -- Configuration to add custom npmrc config
  content: |
    # Custom npmrc config

This feature is now available in the chart version > 0.22.0

beasteers commented 1 year ago

thanks so much! that was fast ✨