jfrog / charts

JFrog official Helm Charts
https://jfrog.com/integration/helm-repository/
Apache License 2.0
260 stars 447 forks source link

[Xray] can't enable loggers: can't evaluate field Values in type interface {} #1827

Closed nu12 closed 8 months ago

nu12 commented 1 year ago

Is this a BUG REPORT or FEATURE REQUEST? (choose one): BUG REPORT

Version of Helm and Kubernetes: Helm v3.12.0 Kubernetes 1.27.3

Which chart: xray version 103.82.11

What happened: When the field loggers is not empty, helm gives the error below when compiling the manifests:

Error: template: xray/templates/xray-statefulset.yaml:1123:22: executing "xray/templates/xray-statefulset.yaml" at <.Values.containerSecurityContext.enabled>: can't evaluate field Values in type interface {}
helm.go:84: [debug] template: xray/templates/xray-statefulset.yaml:1123:22: executing "xray/templates/xray-statefulset.yaml" at <.Values.containerSecurityContext.enabled>: can't evaluate field Values in type interface {}

What you expected to happen: Successful compilation of the manifests when running helm install/upgrade/template.

How to reproduce it (as minimally and precisely as possible):

Create a minimal values.yaml with loggers commented:

xray:
  jfrogUrl: "any"
  loggers: []
  # - router-request.log

Run helm template to compile the manifests:

$ helm template jfrog/xray --version 103.82.11 --values values.yaml 
coalesce.go:175: warning: skipped value for rabbitmq.initContainers: Not a table.
---
# Source: xray/templates/xray-resourcequota.yaml
apiVersion: v1
kind: ResourceQuota
metadata:
  labels:
    app: xray
    chart: xray-103.82.11
    release: "release-name"
    heritage: "Helm"
  name: release-name-xray
spec:
  hard:
    count/jobs.batch: 100
---
# Source: xray/charts/rabbitmq/templates/serviceaccount.yaml
apiVersion: v1
kind: ServiceAccount
(...)

We see above that the manifests were compiled.

Now, remove the brackets and uncomment the logger (it doesn't matter how many, one suffies for this test). New values.yaml is:

xray:
  jfrogUrl: "any"
  loggers:
  - router-request.log

Run the same command as before:

$ helm template jfrog/xray --version 103.82.11 --values values.yaml --debug
install.go:200: [debug] Original chart version: "103.82.11"
install.go:217: [debug] CHART PATH: /home/my-user/.cache/helm/repository/xray-103.82.11.tgz

coalesce.go:175: warning: skipped value for rabbitmq.initContainers: Not a table.

Error: template: xray/templates/xray-statefulset.yaml:1123:22: executing "xray/templates/xray-statefulset.yaml" at <.Values.containerSecurityContext.enabled>: can't evaluate field Values in type interface {}
helm.go:84: [debug] template: xray/templates/xray-statefulset.yaml:1123:22: executing "xray/templates/xray-statefulset.yaml" at <.Values.containerSecurityContext.enabled>: can't evaluate field Values in type interface {}

The error appears.

I'm using helm template command for this demonstration but the same error happens with helm install and helm upgrade.

Cheers.

eldada commented 1 year ago

Looks like a bug that should be fixed. @chukka - can you take it?

While this is looked at, I recommend moving to a smarter, more efficient logging with a single sidecar for all logs. Look at https://github.com/jfrog/charts/tree/master/examples/artifactory/logging for an example of a more advanced way that is actually used by us (JFrog). For Xray, it should be a similar solution in common.customSidecarContainers. A single fluent-bit based sidecar that tails the logs you want and spits them out as json, which can easily be consumed or just tailed.

rahulsadanandan commented 1 year ago

@nu12 Thanks for reporting this. We've created an internal ticket to track and address this issue, and it will be fixed in one of the upcoming releases.

rahulsadanandan commented 1 year ago

@nu12 The fix will be available from 3.86.x versions of xray. For a more streamlined logging approach, refer to this example at https://github.com/jfrog/charts/tree/master/examples/xray/logging, utilizing the fluent-bit sidecar.