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

Add Service to ServiceMonitor Reverse index #46

Merged
merged 4 commits into from Jul 20, 2017

Conversation

Projects
None yet
2 participants
@sadlil
Copy link
Contributor

commented Jul 19, 2017

Request URl: http://localhost:8081/apis/monitoring.coreos.com/v1alpha1/namespaces/kube-system/service/kube-dns/servicemonitors

@sadlil sadlil added the enhancement label Jul 19, 2017

@sadlil sadlil self-assigned this Jul 19, 2017

@sadlil sadlil requested a review from tamalsaha Jul 19, 2017

return nil
}

serviceMonitors, err := promClient.ServiceMonitors(apiv1.NamespaceAll).List(metav1.ListOptions{})

This comment has been minimized.

Copy link
@tamalsaha

tamalsaha Jul 19, 2017

Member

Should check that service monitor exists

This comment has been minimized.

Copy link
@sadlil

sadlil Jul 19, 2017

Author Contributor

Line 109 ensures that ServiceMonitor TPR is exists. If not this would have been nil.
For extra safety i can call util.IsPreferredResource here.

This comment has been minimized.

Copy link
@tamalsaha

tamalsaha Jul 19, 2017

Member

I see. Move this method inside the SMIndexer (same for SvcIndexer).

Also, add a Add(svcMon, svc) type method to avoid n^2 loops.

if oldRes, ok := oldObj.(*apiv1.Endpoints); ok {
if newRes, ok := newObj.(*apiv1.Endpoints); ok {
if !reflect.DeepEqual(oldRes.Subsets, newRes.Subsets) && op.ReverseIndex.Service != nil {
svc, err := op.KubeClient.CoreV1().Services(newRes.Namespace).Get(newRes.Name, metav1.GetOptions{})

This comment has been minimized.

Copy link
@tamalsaha

tamalsaha Jul 19, 2017

Member

err == nil check is enough, I think

key := ri.Key(v1.ObjectMeta{Name: name, Namespace: namespace})
if val, err := ri.index.GetInternal(key); err == nil && len(val) > 0 {
if err := json.NewEncoder(w).Encode(json.RawMessage(val)); err == nil {
w.Header().Set("Content-Type", "application/json")

This comment has been minimized.

Copy link
@tamalsaha

tamalsaha Jul 19, 2017

Member

Also, "x-content-type-options": "nosniff", // http://stackoverflow.com/a/3146618/244009

In the other HTTP handlers, too

This comment has been minimized.

Copy link
@sadlil

sadlil Jul 19, 2017

Author Contributor

ok.

@tamalsaha tamalsaha merged commit fe6964b into master Jul 20, 2017

@tamalsaha tamalsaha deleted the service-monitor-indexers branch Jul 20, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.