arangodb / arangojs

The official ArangoDB JavaScript driver.
https://arangodb.github.io/arangojs
Apache License 2.0
600 stars 106 forks source link

basePath not set in v8.0.0 #777

Closed jgoodall closed 1 year ago

jgoodall commented 1 year ago

We deploy ArangoDB using kube-arangodb into a Kubernetes cluster. Access to the database is through ingress-nginx, which forwards data to https://<server>/arangodb to the arango cluster, and https://<server>/ to our application (which uses the arangojs library). Everything worked fine with arangojs 7.8.0. When we updated our app to 8.0.0, it stopped working. The only thing that changed is the arangojs library and the handful of changes needed to compile the update.

The application now seems to be trying to connect to https://<server>/ instead of https://<server>/arangodb/ - for example, a call to get the version of arangodb results in this request in 7.8.0: https://<server>/arangodb/_db/torro/_api/version?details=true, but this in 8.0.0: https://<server>/_db/torro/_api/version?details=true

Do we need to set a basePath somewhere now? I dont see that as an option on the database configuration. And I am not seeing anything in the migration guide.

Relevant info:

jgoodall commented 1 year ago

Given the lack of a response, I am going to ask this a different way. Something appears to have changed between arangojs v7.8.0 and v8.0.0, but I do not see anything relevant in the migration guide. I dont see any option in the Database config to set something like a basePath, but it appears that is what we may now need. I just do not see a way to set it.

This is how we set up the connection for the db object in the arangojs app:

export const db = new arangojs.Database({
  url: "https://localhost/arangodb",
  databaseName: "dbName"
})

Our ingress-nginx controller forwards everything with /arangodb path prefix to the arango server. This is the kubernetes ingress config for that:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: db-ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$1
    nginx.ingress.kubernetes.io/configuration-snippet: |
      proxy_set_header X-Script-Name  /arangodb;
spec:
  ingressClassName: nginx
  rules:
  - host: localhost
    http:
      paths:
      - pathType: Prefix
        path: /arangodb/?(.*)
        backend:
          service:
            name: arangodb-cluster-ea
            port:
              number: 8529
  tls:
  - hosts:
    - localhost
    secretName: ingress-cert

Any pointers are appreciated!

jgoodall commented 1 year ago

We gave up on this, and took advantage of the fact that everything to the arangodb server starts with /_db, so we set our path prefix rule to /_db and that works for version 8.0.0.