Skip to content

Commit

Permalink
updated IncUnregisteredInformers signature
Browse files Browse the repository at this point in the history
  • Loading branch information
Ash-exp committed Jan 23, 2025
1 parent f63b7f2 commit ccbc89e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
9 changes: 6 additions & 3 deletions kubewatch/pkg/controller/inCluster/informer.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ func (impl *InformerImpl) Start(stopChan <-chan int) {
workflowInformer, err := ciWfInformer.GetSharedInformer(bean.DEFAULT_CLSUTER_ID, namespace, impl.defaultK8sConfig)
if err != nil {
impl.logger.Errorw("error in starting workflow informer", "err", err)
middleware.IncUnregisteredInformers(middleware.DEFAULT_CLUSTER_MATRICS_NAME, bean.DEFAULT_CLSUTER_ID, middleware.CI_STAGE_ARGO_WORKFLOW)
clusterLabels := middleware.NewClusterLabels(middleware.DEFAULT_CLUSTER_MATRICS_NAME, bean.DEFAULT_CLSUTER_ID)
middleware.IncUnregisteredInformers(clusterLabels, middleware.CI_STAGE_ARGO_WORKFLOW)
}
stopCh := make(chan struct{})
defer close(stopCh)
Expand All @@ -79,7 +80,8 @@ func (impl *InformerImpl) Start(stopChan <-chan int) {
workflowInformer, err := cdWfInformer.GetSharedInformer(bean.DEFAULT_CLSUTER_ID, namespace, impl.defaultK8sConfig)
if err != nil {
impl.logger.Errorw("error in starting workflow informer", "err", err)
middleware.IncUnregisteredInformers(middleware.DEFAULT_CLUSTER_MATRICS_NAME, bean.DEFAULT_CLSUTER_ID, middleware.CD_STAGE_ARGO_WORLFLOW)
clusterLabels := middleware.NewClusterLabels(middleware.DEFAULT_CLUSTER_MATRICS_NAME, bean.DEFAULT_CLSUTER_ID)
middleware.IncUnregisteredInformers(clusterLabels, middleware.CD_STAGE_ARGO_WORLFLOW)
}
stopCh := make(chan struct{})
defer close(stopCh)
Expand All @@ -92,7 +94,8 @@ func (impl *InformerImpl) Start(stopChan <-chan int) {
acdInformer, err := applicationInformer.GetSharedInformer(bean.DEFAULT_CLSUTER_ID, impl.appConfig.GetAcdConfig().ACDNamespace, impl.defaultK8sConfig)
if err != nil {
impl.logger.Errorw("error in registering acd informer", "err", err)
middleware.IncUnregisteredInformers(middleware.DEFAULT_CLUSTER_MATRICS_NAME, bean.DEFAULT_CLSUTER_ID, middleware.ARGO_CD)
clusterLabels := middleware.NewClusterLabels(middleware.DEFAULT_CLUSTER_MATRICS_NAME, bean.DEFAULT_CLSUTER_ID)
middleware.IncUnregisteredInformers(clusterLabels, middleware.ARGO_CD)
}
appStopCh := make(chan struct{})
defer close(appStopCh)
Expand Down
9 changes: 6 additions & 3 deletions kubewatch/pkg/controller/multiCluster/informer.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ func (impl *InformerImpl) Start() error {
err := impl.startDefaultClusterInformer()
if err != nil {
impl.logger.Errorw("error in starting default cluster informer", "err", err)
middleware.IncUnregisteredInformers(middleware.DEFAULT_CLUSTER_MATRICS_NAME, bean.DEFAULT_CLSUTER_ID, middleware.DEFAULT_CLUSTER_SECRET)
clusterLabels := middleware.NewClusterLabels(middleware.DEFAULT_CLUSTER_MATRICS_NAME, bean.DEFAULT_CLSUTER_ID)
middleware.IncUnregisteredInformers(clusterLabels, middleware.DEFAULT_CLUSTER_SECRET)
return err
}
models, err := impl.clusterRepository.FindAllActive()
Expand Down Expand Up @@ -299,7 +300,8 @@ func (impl *InformerImpl) startInformer(clusterId int) error {
err = impl.startSystemExecInformer(clusterInfo)
if err != nil && !errors.Is(err, AlreadyExists) {
impl.logger.Errorw("error in starting system executor informer for cluster", "clusterId", clusterId, "err", err)
middleware.IncUnregisteredInformers(clusterInfo.ClusterName, clusterInfo.Id, middleware.SYSTEM_EXECUTOR)
clusterLabels := middleware.NewClusterLabels(clusterInfo.ClusterName, clusterInfo.Id)
middleware.IncUnregisteredInformers(clusterLabels, middleware.SYSTEM_EXECUTOR)
return err
} else if errors.Is(err, AlreadyExists) {
impl.logger.Warnw("system executor informer already exist for cluster", "clusterId", clusterId)
Expand All @@ -309,7 +311,8 @@ func (impl *InformerImpl) startInformer(clusterId int) error {
err = impl.startArgoCdInformer(clusterInfo)
if err != nil && !errors.Is(err, AlreadyExists) {
impl.logger.Errorw("error in starting argo cd informer for cluster", "clusterId", clusterId, "err", err)
middleware.IncUnregisteredInformers(clusterInfo.ClusterName, clusterInfo.Id, middleware.ARGO_CD)
clusterLabels := middleware.NewClusterLabels(clusterInfo.ClusterName, clusterInfo.Id)
middleware.IncUnregisteredInformers(clusterLabels, middleware.ARGO_CD)
return err
} else if errors.Is(err, AlreadyExists) {
impl.logger.Warnw("argo cd informer already exist for cluster", "clusterId", clusterId)
Expand Down
4 changes: 2 additions & 2 deletions kubewatch/pkg/middleware/instrument.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,6 @@ func IncUnreachableCluster(clusterLabels *ClusterLabels) {
UnreachableCluster.WithLabelValues(clusterLabels.ClusterName, strconv.Itoa(clusterLabels.ClusterId)).Inc()
}

func IncUnregisteredInformers(clusterName string, clusterId int, informerName string) {
UnregisteredInformers.WithLabelValues(clusterName, strconv.Itoa(clusterId), informerName).Inc()
func IncUnregisteredInformers(clusterLabels *ClusterLabels, informerName string) {
UnregisteredInformers.WithLabelValues(clusterLabels.ClusterName, strconv.Itoa(clusterLabels.ClusterId), informerName).Inc()
}

0 comments on commit ccbc89e

Please sign in to comment.