artifacthub / hub

Find, install and publish Cloud Native packages
https://artifacthub.io
Apache License 2.0
1.71k stars 233 forks source link

Config File "hub" Not Found in "[/.cfg /artifacthub/.cfg]" #3718

Closed eralumin closed 8 months ago

eralumin commented 8 months ago

Hi,

I am trying to install the helm charts Artifact Hub on Openshift and I always have the following error on the artifact hub pod:

{"level":"fatal","error":"Config File \"hub\" Not Found in \"[/.cfg /artifacthub/.cfg]\"","time":"2024-03-18T10:08:49Z","message":"configuration setup failed"}

In fact every pods which need those configuration files at /home/*/.cfg got this kind of error message.

I checked by mounting on pods and those files exists and are correct.

Here is information about the context:

Here is my values.yaml:

imagePullSecrets:
  - name: foobar-pull-secret
  - name: spameggs-pull-secret

imageTag: ""
nameOverride: ""
pullPolicy: IfNotPresent

dynamicResourceNamePrefixEnabled: false
fullnameOverride: ""

restrictedHTTPClient: false

log:
  level: debug
  pretty: true

db:
  host: postgresql
  port: "5432"
  database: hub
  user: postgres
  password: mypassword
  sslmode: prefer

email:
  fromName: ""
  from: ""
  replyTo: ""
  smtp:
    auth: plain
    host: ""
    port: 587
    username: ""
    password: ""

creds:
  # Docker registry username
  dockerUsername: ""
  # Docker registry password
  dockerPassword: ""

images:
  store: pg

events:
  scanningErrors: false
  trackingErrors: false

dbMigrator:
  job:
    image:
      repository: artifacthub/db-migrator
    ttlSecondsAfterFinished: null
    resources:
      limits:
        cpu: 100m
        memory: 128Mi
      requests:
        cpu: 100m
        memory: 128Mi
  loadSampleData: false
  configDir: "/home/db-migrator/.cfg"

hub:
  ingress:
    enabled: true
    annotations:
      cert-manager.io/cluster-issuer: ca-issuer
    defaultBackendEnabled: true
    rules:
      - host: artifacthub.apps.mycluster.com
        http:
          paths:
            - path: /
              pathType: ImplementationSpecific
              backend:
                service:
                  name: hub
                  port:
                    number: 80
    tls:
      - hosts:
          - artifacthub.apps.mycluster.com
        secretName: artifact-hub-tls-secret
  service:
    type: ClusterIP
    port: 80
  serviceAccount:
    create: false
  rbac:
    create: false
  deploy:
    readinessGates: []
    replicaCount: 1
    image:
      repository: artifacthub/hub
    resources:
      limits:
        cpu: 100m
        memory: 128Mi
      requests:
        cpu: 100m
        memory: 128Mi
    initContainers:
      checkDbMigrator:
        image:
          repository: bitnami/kubectl
          tag: "1.25"
        resources:
          limits:
            cpu: 100m
            memory: 128Mi
          requests:
            cpu: 100m
            memory: 128Mi
      checkDbIsReady:
        image:
          repository: artifacthub/postgres
          tag: latest
        resources:
          limits:
            cpu: 100m
            memory: 128Mi
          requests:
            cpu: 100m
            memory: 128Mi
  server:
    allowPrivateRepositories: true
    allowUserSignUp: true
    cacheDir: ""
    configDir: "/home/hub/.cfg"
    bannersURL: artifacthub.apps.mycluster.com
    baseURL: artifacthub.apps.mycluster.com
    shutdownTimeout: 10s
    motd: ""
    motdSeverity: info
    basicAuth:
      enabled: false
      username: hub
      password: changeme
    cookie:
      hashKey: default-unsafe-key
      secure: false
    csrf:
      authKey: default-unsafe-key
      secure: false
    oauth:
      github:
        enabled: false
      google:
        enabled: false
        clientID: ""
        clientSecret: ""
        redirectURL: ""
        scopes:
          - https://www.googleapis.com/auth/userinfo.email
          - https://www.googleapis.com/auth/userinfo.profile
      oidc:
        enabled: false
        issuerURL: ""
        clientID: ""
        clientSecret: ""
        redirectURL: ""
        scopes:
          - openid
          - profile
          - email
        skipEmailVerifiedCheck: false
    xffIndex: 0
  theme:
    colors:
      primary: "#417598"
      secondary: "#2D4857"
    images:
      appleTouchIcon192: "/static/media/logo192_v2.png"
      appleTouchIcon512: "/static/media/logo512_v2.png"
      openGraphImage: "/static/media/artifactHub_v2.png"
      shortcutIcon: "/static/media/logo_v2.png"
      websiteLogo: "/static/media/logo/artifacthub-brand-white.svg"
    sampleQueries: []
    siteName: "My Artifact Hub"

scanner:
  enabled: false
  cronjob:
    image:
      repository: artifacthub/scanner
  concurrency: 3
  cacheDir: ""
  configDir: "/home/scanner/.cfg"

tracker:
  cronjob:
    image:
      repository: artifacthub/tracker
    resources:
      limits:
        cpu: 1
        memory: 2Gi
      requests:
        cpu: 100m
        memory: 1Gi
  cacheDir: ""
  configDir: "/home/tracker/.cfg"
  concurrency: 10
  repositoryTimeout: 15m
  repositoriesNames: []
  repositoriesKinds: []
  bypassDigestCheck: false

trivy:
  enabled: false
  deploy:
    image: aquasec/trivy:0.43.1
    resources:
      limits:
        cpu: 100m
        memory: 128Mi
      requests:
        cpu: 100m
        memory: 128Mi
  persistence:
    enabled: false
    size: 10Gi

postgresql:
  enabled: false

extraDeploy: []

There is certainly something wrong in my config but I really don't see what exactly.

tegioz commented 8 months ago

Hi @kmarilleau 👋

The Artifact Hub components try to read their configuration file from the following paths:

https://github.com/artifacthub/hub/blob/ec66fcdd9d17418e2c443da09a88b881474034fb/internal/util/config.go#L18-L19

Based on the error you shared, it looks like the $HOME environment variable isn't set. Otherwise, instead of Not Found in [/.cfg] (as per the first option shown above) it should show something like Not Found in [/home-env-var-content/.cfg].

Hope this helps 🙂

eralumin commented 8 months ago

Ahhh ok, so i just try this:

hub:
  configDir: "/artifacthub/.cfg"

scanner:
  configDir: "/artifacthub/.cfg"

tracker:
  configDir: "/artifacthub/.cfg"

And it works fine! Thank you!

tegioz commented 8 months ago

Awesome, no worries!