Skip to content

Commit

Permalink
fix(controller): Fix k8s clientset controller metrics. Fixes argoproj…
Browse files Browse the repository at this point in the history
…#2139 (argoproj#2261)

* Add roundtripper to kubeconfig before creating kubeclient

Signed-off-by: Nikhil <[email protected]>

* Check if k8sRequestsCount is nil before attempting increase

Signed-off-by: Nikhil <[email protected]>

* Added Flipkart to Users.md

Signed-off-by: Nikhil <[email protected]>

* gofmt controller/metrics/client.go

Signed-off-by: Nikhil <[email protected]>

Signed-off-by: Nikhil <[email protected]>
  • Loading branch information
nikhil1raghav authored and jandersen-plaid committed Nov 8, 2022
1 parent ea73d40 commit 5102772
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions USERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Organizations below are **officially** using Argo Rollouts. Please send a PR wit
1. [Databricks](https://github.com/databricks)
1. [Devtron Labs](https://github.com/devtron-labs/devtron)
1. [Farfetch](https://www.farfetch.com/)
1. [Flipkart](https://flipkart.com)
1. [Gllue](https://gllue.com)
1. [Ibotta](https://home.ibotta.com/)
1. [Intuit](https://www.intuit.com/)
Expand Down
5 changes: 3 additions & 2 deletions cmd/rollouts-controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ func newCommand() *cobra.Command {
log.Infof("Using namespace %s", namespace)
}

k8sRequestProvider := &metrics.K8sRequestsCountProvider{}
kubeclientmetrics.AddMetricsTransportWrapper(config, k8sRequestProvider.IncKubernetesRequest)

kubeClient, err := kubernetes.NewForConfig(config)
checkError(err)
argoprojClient, err := clientset.NewForConfig(config)
Expand Down Expand Up @@ -155,8 +158,6 @@ func newCommand() *cobra.Command {
configMapInformer := controllerNamespaceInformerFactory.Core().V1().ConfigMaps()
secretInformer := controllerNamespaceInformerFactory.Core().V1().Secrets()

k8sRequestProvider := &metrics.K8sRequestsCountProvider{}
kubeclientmetrics.AddMetricsTransportWrapper(config, k8sRequestProvider.IncKubernetesRequest)
mode, err := ingressutil.DetermineIngressMode(ingressVersion, kubeClient.DiscoveryClient)
checkError(err)
ingressWrapper, err := ingressutil.NewIngressWrapper(mode, kubeClient, kubeInformerFactory)
Expand Down
5 changes: 3 additions & 2 deletions controller/metrics/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ func (m *K8sRequestsCountProvider) IncKubernetesRequest(resourceInfo kubeclientm
name = "Unknown"
kind = "Unknown"
}

m.k8sRequestsCount.WithLabelValues(kind, namespace, name, string(resourceInfo.Verb), statusCode).Inc()
if m.k8sRequestsCount != nil {
m.k8sRequestsCount.WithLabelValues(kind, namespace, name, string(resourceInfo.Verb), statusCode).Inc()
}
return nil
}

0 comments on commit 5102772

Please sign in to comment.