37 Star 411 Fork 76

GVPrancher/rancher

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
cluster_monitoring_enabled_handler.go 1.27 KB
一键复制 编辑 原始数据 按行查看 历史
Frank Mai 提交于 2019-03-29 12:09 . Reconcile Cluster Monitoring status
package monitoring
import (
"github.com/rancher/rancher/pkg/monitoring"
mgmtv3 "github.com/rancher/types/apis/management.cattle.io/v3"
k8scorev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
)
// clusterMonitoringEnabledHandler syncs the Cluster Monitoring Prometheus status.
type clusterMonitoringEnabledHandler struct {
clusterName string
cattleClusterController mgmtv3.ClusterController
cattleClusterLister mgmtv3.ClusterLister
}
// sync will trigger clusterHandler sync loop, if Cluster Monitoring is enabling.
func (h *clusterMonitoringEnabledHandler) sync(key string, endpoints *k8scorev1.Endpoints) (runtime.Object, error) {
endpointName, _, _ := monitoring.ClusterPrometheusEndpoint()
if endpoints == nil || endpoints.DeletionTimestamp != nil || endpoints.Name != endpointName {
return endpoints, nil
}
cluster, err := h.cattleClusterLister.Get(metav1.NamespaceAll, h.clusterName)
if err != nil || cluster.DeletionTimestamp != nil {
return endpoints, err
}
// only consider enabling monitoring
if !cluster.Spec.EnableClusterMonitoring {
return endpoints, nil
}
// trigger clusterHandler sync loop
h.cattleClusterController.Enqueue(metav1.NamespaceAll, h.clusterName)
return endpoints, nil
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/rancher/rancher.git
git@gitee.com:rancher/rancher.git
rancher
rancher
rancher
v2.2.5

搜索帮助

0d507c66 1850385 C8b1a773 1850385