Feature flag to enable/disable canary + optional prometheus install (#937)

This commit is contained in:
smruthi2187
2018-10-22 15:24:43 -07:00
committed by GitHub
parent e7f1d4564a
commit 0a8c6e97a6
20 changed files with 304 additions and 28 deletions
+16 -2
View File
@@ -19,9 +19,11 @@ package canaryconfigmgr
import (
"context"
"fmt"
log "github.com/sirupsen/logrus"
"os"
"strings"
"time"
log "github.com/sirupsen/logrus"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields"
@@ -45,7 +47,19 @@ type canaryConfigMgr struct {
func MakeCanaryConfigMgr(fissionClient *crd.FissionClient, kubeClient *kubernetes.Clientset, crdClient *rest.RESTClient, prometheusSvc string) (*canaryConfigMgr, error) {
if prometheusSvc == "" {
return nil, fmt.Errorf("prometheus service not found, cant create canary config manager")
// handle a case where there is a prometheus server is already installed, try to find the service from env variable
envVars := os.Environ()
for _, envVar := range envVars {
if strings.Contains(envVar, "PROMETHEUS_SERVER_SERVICE_HOST") {
envVarSplit := strings.Split(envVar, "=")
prometheusSvc = envVarSplit[1]
break
}
}
if prometheusSvc == "" {
return nil, fmt.Errorf("prometheus service not found, cant create canary config manager")
}
}
configMgr := &canaryConfigMgr{