代码拉取完成,页面将自动刷新
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
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。