Use client generator to generate all k8s clients and add respective client-go metrics (#2668)
* Define client generator to generate all k8s clients * Increase QPS and burst values * Capture client-go metrics * Support for controller runtime metrics Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>
This commit is contained in:
@@ -251,9 +251,18 @@ func (executor *Executor) getFunctionServiceFromCache(ctx context.Context, fn *f
|
||||
// StartExecutor Starts executor and the executor components such as Poolmgr,
|
||||
// deploymgr and potential future executor types
|
||||
func StartExecutor(ctx context.Context, logger *zap.Logger, port int) error {
|
||||
fissionClient, kubernetesClient, _, metricsClient, err := crd.MakeFissionClient()
|
||||
clientGen := crd.NewClientGenerator()
|
||||
fissionClient, err := clientGen.GetFissionClient()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to get kubernetes client")
|
||||
return errors.Wrap(err, "error making the fission client")
|
||||
}
|
||||
kubernetesClient, err := clientGen.GetKubernetesClient()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error making the kube client")
|
||||
}
|
||||
metricsClient, err := clientGen.GetMetricsClient()
|
||||
if err != nil {
|
||||
logger.Error("error making the metrics client", zap.Error(err))
|
||||
}
|
||||
|
||||
err = crd.WaitForCRDs(ctx, logger, fissionClient)
|
||||
|
||||
@@ -115,9 +115,18 @@ func TestExecutor(t *testing.T) {
|
||||
|
||||
// connect to k8s
|
||||
// and get CRD client
|
||||
fissionClient, kubeClient, apiExtClient, _, err := crd.MakeFissionClient()
|
||||
clientGen := crd.NewClientGenerator()
|
||||
fissionClient, err := clientGen.GetFissionClient()
|
||||
if err != nil {
|
||||
log.Panicf("failed to connect: %v", err)
|
||||
log.Panicf("failed to connect: %s", err)
|
||||
}
|
||||
kubeClient, err := clientGen.GetKubernetesClient()
|
||||
if err != nil {
|
||||
log.Panicf("failed to connect: %s", err)
|
||||
}
|
||||
apiExtClient, err := clientGen.GetApiExtensionsClient()
|
||||
if err != nil {
|
||||
log.Panicf("failed to connect: %s", err)
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
@@ -17,8 +17,8 @@ limitations under the License.
|
||||
package metrics
|
||||
|
||||
import (
|
||||
"github.com/fission/fission/pkg/utils/metrics"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promauto"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -26,14 +26,14 @@ var (
|
||||
// function_uid: the function's version id
|
||||
// function_address: the address of the pod from which the function was called
|
||||
functionLabels = []string{"function_name", "function_namespace"}
|
||||
ColdStarts = promauto.NewCounterVec(
|
||||
ColdStarts = prometheus.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Name: "fission_function_cold_starts_total",
|
||||
Help: "How many cold starts are made by function_name, function_namespace.",
|
||||
},
|
||||
functionLabels,
|
||||
)
|
||||
FuncRunningSummary = promauto.NewSummaryVec(
|
||||
FuncRunningSummary = prometheus.NewSummaryVec(
|
||||
prometheus.SummaryOpts{
|
||||
Name: "fission_function_running_seconds",
|
||||
Help: "The running time (last access - create) in seconds of the function.",
|
||||
@@ -41,7 +41,7 @@ var (
|
||||
},
|
||||
functionLabels,
|
||||
)
|
||||
FuncError = promauto.NewCounterVec(
|
||||
FuncError = prometheus.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Name: "fission_function_cold_start_errors_total",
|
||||
Help: "Count of fission cold start errors",
|
||||
@@ -49,3 +49,10 @@ var (
|
||||
functionLabels,
|
||||
)
|
||||
)
|
||||
|
||||
func init() {
|
||||
registry := metrics.Registry
|
||||
registry.MustRegister(ColdStarts)
|
||||
registry.MustRegister(FuncRunningSummary)
|
||||
registry.MustRegister(FuncError)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user