Skip to content

Commit

Permalink
Store provider instead of isKubemark in PrometheusController
Browse files Browse the repository at this point in the history
  • Loading branch information
mm4tt committed Apr 23, 2019
1 parent 1ca76bb commit ac21ba8
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions clusterloader2/pkg/prometheus/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ const (
// the cluster.
type PrometheusController struct {
clusterLoaderConfig *config.ClusterLoaderConfig
// isKubemark determines whether prometheus stack is being set up in kubemark cluster or not.
isKubemark bool
// provider is the cloud provider derived from the --provider flag.
provider string
// framework associated with the cluster where the prometheus stack should be set up.
// For kubemark it's the root cluster, otherwise it's the main (and only) cluster.
framework *framework.Framework
Expand All @@ -59,7 +59,7 @@ type PrometheusController struct {
func NewPrometheusController(clusterLoaderConfig *config.ClusterLoaderConfig) (pc *PrometheusController, err error) {
pc = &PrometheusController{
clusterLoaderConfig: clusterLoaderConfig,
isKubemark: clusterLoaderConfig.ClusterConfig.Provider == "kubemark",
provider: clusterLoaderConfig.ClusterConfig.Provider,
}

if pc.framework, err = framework.NewRootFramework(&clusterLoaderConfig.ClusterConfig, numK8sClients); err != nil {
Expand Down Expand Up @@ -92,7 +92,7 @@ func (pc *PrometheusController) SetUpPrometheusStack() error {
if err := pc.applyManifests(coreManifests); err != nil {
return err
}
if pc.isKubemark {
if pc.isKubemark() {
if err := pc.exposeKubemarkApiServerMetrics(); err != nil {
return err
}
Expand Down Expand Up @@ -187,7 +187,7 @@ func (pc *PrometheusController) isPrometheusReady() (bool, error) {
// server is started before targets are registered.
expectedTargets := pc.clusterLoaderConfig.ClusterConfig.Nodes
// TODO(mm4tt): Start monitoring kube-proxy in kubemark and get rid of this if.
if pc.isKubemark {
if pc.isKubemark() {
expectedTargets = 3 // kube-apiserver, prometheus, grafana
}
return CheckTargetsReady(
Expand All @@ -196,6 +196,10 @@ func (pc *PrometheusController) isPrometheusReady() (bool, error) {
expectedTargets)
}

func (pc *PrometheusController) isKubemark() bool {
return pc.provider == "kubemark"
}

func retryCreateFunction(f func() error) error {
return client.RetryWithExponentialBackOff(
client.RetryFunction(f, client.Allow(apierrs.IsAlreadyExists)))
Expand Down

0 comments on commit ac21ba8

Please sign in to comment.