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

use kubernetes informer framework #30

Merged
merged 2 commits into from Oct 18, 2016
Merged

Conversation

brancz
Copy link
Member

@brancz brancz commented Sep 27, 2016

Fixes #29 .

@fabxc @ghodss

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please let us know the company's name.

@brancz
Copy link
Member Author

brancz commented Sep 27, 2016

I signed it!

@googlebot
Copy link

CLAs look good, thanks!

@fabxc
Copy link
Contributor

fabxc commented Sep 27, 2016

Do we see an immediate use case for the informers that should finally land soon? (kubernetes/client-go#4)

If so, we might want to hold off so we don't constantly revendor.

@brancz
Copy link
Member Author

brancz commented Sep 27, 2016

That makes sense. This says the informer framework should be in the client once this is merged, which it is already, just waiting for submit queue according to the GitHub statuses. So I will hold back on this once the informer framework is included. Then we vendor it in this PR and then switch to it in an additional PR.

@brancz
Copy link
Member Author

brancz commented Sep 28, 2016

Although it's merged now and available, it seems that there is still a problem with it, however, it looks like once kubernetes/kubernetes#33632 is fixed it will work. So holding off just a bit longer until then.

@brancz
Copy link
Member Author

brancz commented Sep 29, 2016

As kubernetes/kubernetes#33632 is merged we're only waiting for submit queue again. 🎉

@brancz brancz force-pushed the clientgo15 branch 8 times, most recently from b741c02 to cced33e Compare October 6, 2016 13:27
@brancz
Copy link
Member Author

brancz commented Oct 6, 2016

Alright, 🍏 CI. Re-review @fabxc @ghodss ?

@brancz brancz force-pushed the clientgo15 branch 3 times, most recently from b6b28c9 to 05b1a39 Compare October 17, 2016 11:24
@brancz brancz changed the title upgrade to client-go 1.5 use kubernetes informer framework Oct 17, 2016
@brancz
Copy link
Member Author

brancz commented Oct 17, 2016

Alright now implemented it with the k8s informer framework. @fabxc

func (l NodeLister) List() (v1.NodeList, error) {
return l()
}

// initializeMetrics creates a new controller from the given config.
func initializeMetrics(kubeClient clientset.Interface) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Function name and comment are far outdated by now I think. Maybe just setup() or something.

@@ -70,7 +69,7 @@ var (
)

type deploymentStore interface {
List() (deployments []v1beta1.Deployment, err error)
List() []interface{}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

List() []interface{} is super generic now. Not really necessary to keep one type per resource type anymore.
Maybe just:

type lister interface {
    List() []interface{}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Or keep them as they were and add a wrapper around the cache's List method doing the typecast there. Saves us from dragging interface{} through the actual application logic layers and we can keep working with more idiomatic go.

prometheus.MustRegister(&deploymentCollector{store: dplLister})
prometheus.MustRegister(&podCollector{store: podLister})
prometheus.MustRegister(&nodeCollector{store: nodeLister})
go dinf.Run(context.TODO().Done())
Copy link
Contributor

Choose a reason for hiding this comment

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

We can just use background here as this is basically top-level. From my understanding, TODO is intended for when you want to connect a context chain later on but can't yet because the call chain doesn't fully support it yet.

@brancz
Copy link
Member Author

brancz commented Oct 17, 2016

@fabxc Undid the interface weirdness and applied the other comments.

@fabxc
Copy link
Contributor

fabxc commented Oct 18, 2016

👍

@fabxc fabxc merged commit 07e4d4f into kubernetes:master Oct 18, 2016
@brancz brancz deleted the clientgo15 branch October 18, 2016 12:06
@brancz brancz mentioned this pull request Oct 18, 2016
while1malloc0 pushed a commit to while1malloc0/kube-state-metrics that referenced this pull request Jul 2, 2018
use kubernetes informer framework
brancz pushed a commit to brancz/kube-state-metrics that referenced this pull request Jul 31, 2020
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.

None yet

3 participants