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

Watch ConfigMap to prevent datasources from not being imported. #664

Merged
merged 8 commits into from
Feb 22, 2022

Conversation

zoetrope
Copy link
Contributor

@zoetrope zoetrope commented Jan 13, 2022

Description

If a datasource resource is created before grafana-controller creates a configmap resource, the datasource resource will not be imported.
I fixed it so that datasource-controller triggers configmap changes to reconcile datasources.

Relevant issues/tickets

#652

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

  • This change requires a documentation update
  • I have added tests that prove my fix is effective or that my feature works
  • I have added a test case that will be used to verify my changes
  • Verified independently on a cluster by reviewer

Verification steps

return ctrl.NewControllerManagedBy(mgr).
For(&integreatlyorgv1alpha1.GrafanaDataSource{}).
Watches(&source.Kind{Type: &v1.ConfigMap{}}, handler.EnqueueRequestsFromMapFunc(cmHandler)).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use Owns(&v1.ConfigMap{}) instead? That would trigger the normal reconcile function where we could check if it's the right configmap.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pb82
Unfortunately, the owner of the configmap is not a DataSource resource, but a Grafana resource.
So we cannot use Owns(&v1.ConfigMap{}) in this controller.

Copy link
Collaborator

@hubeadmin hubeadmin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, if @pb82 is also happy with it, we can merge

Copy link
Collaborator

@NissesSenap NissesSenap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@pb82 pb82 merged commit 3921869 into grafana:master Feb 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants