Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

something went wrong while collecting envs [Bug] #1526

Closed
alikhil opened this issue May 10, 2024 · 1 comment · Fixed by #1537
Closed

something went wrong while collecting envs [Bug] #1526

alikhil opened this issue May 10, 2024 · 1 comment · Fixed by #1537
Assignees
Labels
bug Something isn't working triage/accepted Indicates an issue or PR is ready to be actively worked on.

Comments

@alikhil
Copy link

alikhil commented May 10, 2024

Describe the bug

GrafanaDashboard resources without envs spec field set is failed to reconcile with something went wrong while collecting envs, error: dashboard.Spec.Envs or dashboard.Spec.EnvFrom nil, can't get envs for dashboard error.

However, according to docs both fields are optional:
image

Version
Full semver version of the operator being used - 5.9.0

To Reproduce
Steps to reproduce the behavior:

  1. Deploy operator using latest helm chart https://artifacthub.io/packages/helm/bitnami/grafana-operator
  2. Create grafana crd
  3. Create Dashboard resource
Example of dashboard resource
apiVersion: grafana.integreatly.org/v1beta1
kind: GrafanaDashboard
metadata:
  name: grafanadashboard-jsonnet
  namespace: promstack
spec:
  folder: "Kubernetes"
  instanceSelector:
    matchLabels:
      grafana: iponweb
  resyncPeriod: 1m

  jsonnet: |
   local grafana = import 'grafonnet/grafana.libsonnet';
   local dashboard = grafana.dashboard;
   local row = grafana.row;
   local singlestat = grafana.singlestat;
   local prometheus = grafana.prometheus;
   local template = grafana.template;

   dashboard.new(
     'JVM',
     tags=['java'],
   )
   .addTemplate(
     grafana.template.datasource(
       'PROMETHEUS_DS',
       'prometheus',
       'Prometheus',
       hide='label',
     )
   )
   .addTemplate(
     template.new(
       'env',
       '$PROMETHEUS_DS',
       'label_values(jvm_threads_current, env)',
       label='Environment',
       refresh='time',
     )
   )
   .addTemplate(
     template.new(
       'job',
       '$PROMETHEUS_DS',
       'label_values(jvm_threads_current{env="$env"}, job)',
       label='Job',
       refresh='time',
     )
   )
   .addTemplate(
     template.new(
       'instance',
       '$PROMETHEUS_DS',
       'label_values(jvm_threads_current{env="$env",job="$job"}, instance)',
       label='Instance',
       refresh='time',
     )
   )
   .addRow(
     row.new()
     .addPanel(
       singlestat.new(
         'uptime',
         format='s',
         datasource='Prometheus',
         span=2,
         valueName='current',
       )
       .addTarget(
         prometheus.target(
           'time() - process_start_time_seconds{env="$env", job="$job", instance="$instance"}',
         )
       )
     )
   )
  1. See error in logs of operator
2024-05-10T10:08:39Z    ERROR   GrafanaDashboardReconciler      error fetching dashboard        {"controller": "grafanadashboard", "controllerGroup": "grafana.integreatly.org", "controllerKind": "GrafanaDashboard", "GrafanaDashboard": {"name":"grafanadashboard-jsonnet","namespace":"promstack"}, "namespace": "promstack", "name": "grafanadashboard-jsonnet", "reconcileID": "11a726b1-cf40-4164-a1ce-af226a83cbd5", "dashboard": "grafanadashboard-jsonnet", "error": "something went wrong while collecting envs, error: dashboard.Spec.Envs or dashboard.Spec.EnvFrom nil, can't get envs for dashboard: grafanadashboard-jsonnet"}
github.com/grafana/grafana-operator/v5/controllers.(*GrafanaDashboardReconciler).Reconcile
        /bitnami/blacksmith-sandox/grafana-operator-5.8.1/src/github.com/grafana-operator/grafana-operator/controllers/dashboard_controller.go:203
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Reconcile
        /bitnami/blacksmith-sandox/grafana-operator-5.8.1/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:119
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler
        /bitnami/blacksmith-sandox/grafana-operator-5.8.1/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:316
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem
        /bitnami/blacksmith-sandox/grafana-operator-5.8.1/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:266
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2
        /bitnami/blacksmith-sandox/grafana-operator-5.8.1/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:227

Expected behavior
Expected to reconcile dashboard successfully.

Suspect component/Location where the bug might be occurring
I think there is a bug here which triggers throwing error on empty 'envFrom' and 'envs' fields.

Runtime:

  • OS: [e.g. Linux,Fedora,Mac]
  • Grafana Operator Version 5.9.0
  • Environment: Kubernetes v1.27.11-gke.1062001
  • Deployment type: deployed in cluster with 4.2.1 chart version
@alikhil alikhil added bug Something isn't working needs triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels May 10, 2024
@alikhil
Copy link
Author

alikhil commented May 10, 2024

Also, if I add some dummy envs like

envs:
- name: DUMMY
   value: "VALUE"

It works with any problem

@alikhil alikhil changed the title [Bug] something went wrong while collecting envs [Bug] May 10, 2024
@theSuess theSuess added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels May 13, 2024
@theSuess theSuess self-assigned this May 15, 2024
theSuess added a commit that referenced this issue May 15, 2024
theSuess added a commit that referenced this issue May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants