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

[Bug] Grafana Operator 5.15.1 ignores 'spec.version' in Grafana CR #1758

Closed
tnishiga opened this issue Nov 14, 2024 · 4 comments · Fixed by #1764
Closed

[Bug] Grafana Operator 5.15.1 ignores 'spec.version' in Grafana CR #1758

tnishiga opened this issue Nov 14, 2024 · 4 comments · Fixed by #1764
Labels
bug Something isn't working triage/accepted Indicates an issue or PR is ready to be actively worked on.

Comments

@tnishiga
Copy link

Describe the bug
The latest Grafana Operator 5.15.1 ignored 'spec.version' in Grafana CR. Grafana Pod is started by Operator, but its version is the different with the specified one in Grafana CR.

Version
v5.15.1

To Reproduce
Steps to reproduce the behavior:

  1. Install Grafana Operator 5.15.1 from OperatorHub of OpenShift.
  2. Create Grafana custom resources with 'spec.version' like 10.4.11 and wait for starting Grafana pod.
  3. Check Grafana version from the executed pod.

Subscription/grafana-operator:

apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
  creationTimestamp: "2024-11-14T07:07:27Z"
  generation: 1
  labels:
    operators.coreos.com/grafana-operator.grafana: ""
  name: grafana-operator
  namespace: grafana
  resourceVersion: "52098312"
  uid: b548c0b7-4a20-4cde-85f5-4e2fb694bcc1
spec:
  channel: v5
  installPlanApproval: Manual
  name: grafana-operator
  source: community-operators
  sourceNamespace: openshift-marketplace
  startingCSV: grafana-operator.v5.15.1

Grafana custom resource:

apiVersion: grafana.integreatly.org/v1beta1
kind: Grafana
metadata:
  labels:
    dashboards: grafana
    folders: grafana
spec:
  config:
    auth:
      disable_login_form: 'false'
    log:
      mode: console
  deployment:
    spec:
      template:
        spec:
          volumes:
            - name: grafana-data
              persistentVolumeClaim:
                claimName: grafana-pvc
  persistentVolumeClaim:
    metadata: {}
    spec:
      accessModes:
        - ReadWriteOnce
      resources:
        requests:
          storage: 1Gi
  route:
    spec:
      host: grafana.apps.xxxxx.com
  version: 10.4.11

The specified version is 10.4.11. But the running version is 10.4.3

$ oc logs grafana-deployment-6d7c46886d-8299s |grep version
logger=settings t=2024-11-14T07:08:14.913265476Z level=info msg="Starting Grafana" version=10.4.3 commit=0bfd547800e6eb79dc98e55844ba28194b3df002 branch=v10.4.x compiled=2024-11-14T07:08:14Z

Expected behavior
The operator recognizes 'spec.version' of Grafana CR and use it as the executing Grafana version.

Suspect component/Location where the bug might be occurring
unknown

Screenshots
N/A

Runtime (please complete the following information):

  • Grafana Operator Version: v5.15.1
  • Environment: Openshift 4.15.18
  • Deployment type: Openshift OLM
@tnishiga tnishiga added bug Something isn't working needs triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Nov 14, 2024
@Baarsgaard
Copy link
Contributor

The spec.version field is ignored if RELATED_IMAGE_GRAFANA is set and references a hash instead of a tag. source
Have you defined the environment variable RELATED_GRAFANA_IMAGE on the operator/manager deployment?

This is unfortunately not mentioned in the description of the version field

@tnishiga
Copy link
Author

Thanks, @Baarsgaard .

RELATED_IMAGE_GRAFANA was set as a hash image value on deployment/grafana-operator-controller-manager-v5.

$ oc get deploy grafana-operator-controller-manager-v5 -o json | jq .spec.template.spec.containers[].env
[
  {
    "name": "RELATED_IMAGE_GRAFANA",
    "value": "docker.io/grafana/grafana@sha256:b7fcb534f7b3512801bb3f4e658238846435804deb479d105b5cdc680847c272"
  },
  {
    "name": "WATCH_NAMESPACE",
    "valueFrom": {
      "fieldRef": {
        "apiVersion": "v1",
        "fieldPath": "metadata.annotations['olm.targetNamespaces']"
      }
    }
  },
  {
    "name": "OPERATOR_CONDITION_NAME",
    "value": "grafana-operator.v5.15.1"
  }
]

I tried to change RELATED_IMAGE_GRAFANA as follows. But the change of the environment value is reverted.

$ oc set env deploy/grafana-operator-controller-manager-v5 RELATED_IMAGE_GRAFANA=docker.io/grafana/grafana:10.4.3

$ oc get deploy grafana-operator-controller-manager-v5 -o json | jq .spec.template.spec.containers[].env
[
  {
    "name": "RELATED_IMAGE_GRAFANA",
    "value": "docker.io/grafana/grafana@sha256:b7fcb534f7b3512801bb3f4e658238846435804deb479d105b5cdc680847c272"
  },
  {
    "name": "WATCH_NAMESPACE",
    "valueFrom": {
      "fieldRef": {
        "apiVersion": "v1",
        "fieldPath": "metadata.annotations['olm.targetNamespaces']"
      }
    }
  },
  {
    "name": "OPERATOR_CONDITION_NAME",
    "value": "grafana-operator.v5.15.1"
  }
]

Can you tell me the correct way to fix for this issue?

@tnishiga
Copy link
Author

Hi @Baarsgaard ,
After patching env entry of the csv/grafana-operator.v5.15.1 as follows, Grafana Operator starts to recognize the spec.version of Grafana CR.

$ oc get csv/grafana-operator.v5.15.1 -o json | jq .spec.install.spec.deployments[0].spec.template.spec.containers[0].env
[
  {
    "name": "RELATED_IMAGE_GRAFANA",
    "value": "docker.io/grafana/grafana:10.4.3"
  },
  {
    "name": "WATCH_NAMESPACE",
    "valueFrom": {
      "fieldRef": {
        "fieldPath": "metadata.annotations['olm.targetNamespaces']"
      }
    }
  }
]

Thanks.

@theSuess
Copy link
Member

Sorry for this issue - this seems to be a regression introduced by #1733. I'll work on a fix for this before the next release

@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 Nov 18, 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.

3 participants