Skip to content

Reusing names of CRs that register plugins cause collisions in the plugin ConfigMap #2163

@Baarsgaard

Description

@Baarsgaard

Describe the bug
Namespace information is not tracked in the plugin ConfigMap keys.
Resources in other namespaces with the same name will collide and overwrite each other if they match the same instances.
If the two or more resources have different plugins listed, alternating reconciles will trigger a restart of the matching Grafana instances.

Came up while reviewing the improved handling plugins in #2162.

Version
v5.19.x

To Reproduce
Steps to reproduce the behavior:

  1. Create two datasources with the same name, must be done in different namespaces.
kubectl get grafanadatasources.grafana.integreatly.org -A
NAMESPACE      NAME                        NO MATCHING INSTANCES   LAST RESYNC   AGE
default        example-grafanadatasource                           80s           31m
grafana-crds   example-grafanadatasource                           2m8s          31m
  1. Make sure the pluginlist between the datasources are different, either different versions or one having an empty list etc.
  2. Create a Grafana instance which satisfies the instanceSelector of both datasources.
  3. Make sure one or both datasources have .spec.allowCrossNamespaceImport=true to match across namespaces.
  4. Observe the deployment being modified back and forth by the operator depending on which datasource was last reconciled.

Expected behavior
The plugin list to be stable across namespaces regardless of the name of resources.

Suspect component/Location where the bug might be occurring
Dashboard:

err = ReconcilePlugins(ctx, r.Client, r.Scheme, &grafana, cr.Spec.Plugins, fmt.Sprintf("%v-dashboard", cr.Name))

err = ReconcilePlugins(ctx, r.Client, r.Scheme, &grafana, nil, fmt.Sprintf("%v-dashboard", cr.Name))

Datasource:

err = ReconcilePlugins(ctx, r.Client, r.Scheme, &grafana, cr.Spec.Plugins, fmt.Sprintf("%v-datasource", cr.Name))

err = ReconcilePlugins(ctx, r.Client, r.Scheme, &grafana, nil, fmt.Sprintf("%v-datasource", cr.Name))

Library Panel:

err := ReconcilePlugins(ctx, r.Client, r.Scheme, instance, cr.Spec.Plugins, fmt.Sprintf("%v-librarypanel", cr.Name))

Example of the resulting ConfigMap:

kubectl get cm grafana-plugins -o yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: grafana-plugins
  namespace: default
binaryData:
  # The below value is changed on every alternate reconciliation triggering a restart.
  example-grafanadatasource-datasource: W3sibmFtZSI6ImdyYWZhbmEtY2xvY2stcGFuZWwiLCJ2ZXJzaW9uIjoiMS4zLjAifV0=

Metadata

Metadata

Assignees

Labels

triage/acceptedIndicates an issue or PR is ready to be actively worked on.

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions