util: remove deprecated grpc metrics

This commit removes the deprecated
grpc related code from cephcsi.

fixes: #4122

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
Madhu Rajanna 2023-11-02 13:00:55 +01:00 committed by mergify[bot]
parent c09700b568
commit 3ea540bf0f
8 changed files with 21 additions and 84 deletions

View File

@ -106,8 +106,8 @@ func init() {
"", "",
"Comma separated string of mount options accepted by ceph-fuse mounter") "Comma separated string of mount options accepted by ceph-fuse mounter")
// liveness/grpc metrics related flags // liveness/profile metrics related flags
flag.IntVar(&conf.MetricsPort, "metricsport", 8080, "TCP port for liveness/grpc metrics requests") flag.IntVar(&conf.MetricsPort, "metricsport", 8080, "TCP port for liveness/profile metrics requests")
flag.StringVar( flag.StringVar(
&conf.MetricsPath, &conf.MetricsPath,
"metricspath", "metricspath",
@ -116,14 +116,6 @@ func init() {
flag.DurationVar(&conf.PollTime, "polltime", time.Second*pollTime, "time interval in seconds between each poll") flag.DurationVar(&conf.PollTime, "polltime", time.Second*pollTime, "time interval in seconds between each poll")
flag.DurationVar(&conf.PoolTimeout, "timeout", time.Second*probeTimeout, "probe timeout in seconds") flag.DurationVar(&conf.PoolTimeout, "timeout", time.Second*probeTimeout, "probe timeout in seconds")
flag.BoolVar(&conf.EnableGRPCMetrics, "enablegrpcmetrics", false, "[DEPRECATED] enable grpc metrics")
flag.StringVar(
&conf.HistogramOption,
"histogramoption",
"0.5,2,6",
"[DEPRECATED] Histogram option for grpc metrics, should be comma separated value, "+
"ex:= 0.5,2,6 where start=0.5 factor=2, count=6")
flag.UintVar( flag.UintVar(
&conf.RbdHardMaxCloneDepth, &conf.RbdHardMaxCloneDepth,
"rbdhardmaxclonedepth", "rbdhardmaxclonedepth",
@ -210,7 +202,7 @@ func main() {
setPIDLimit(&conf) setPIDLimit(&conf)
if conf.EnableGRPCMetrics || conf.Vtype == livenessType { if conf.EnableProfiling || conf.Vtype == livenessType {
// validate metrics endpoint // validate metrics endpoint
conf.MetricsIP = os.Getenv("POD_IP") conf.MetricsIP = os.Getenv("POD_IP")

View File

@ -40,11 +40,9 @@ make image-cephcsi
| `--pidlimit` | _0_ | Configure the PID limit in cgroups. The container runtime can restrict the number of processes/tasks which can cause problems while provisioning (or deleting) a large number of volumes. A value of `-1` configures the limit to the maximum, `0` does not configure limits at all. | | `--pidlimit` | _0_ | Configure the PID limit in cgroups. The container runtime can restrict the number of processes/tasks which can cause problems while provisioning (or deleting) a large number of volumes. A value of `-1` configures the limit to the maximum, `0` does not configure limits at all. |
| `--metricsport` | `8080` | TCP port for liveness metrics requests | | `--metricsport` | `8080` | TCP port for liveness metrics requests |
| `--metricspath` | `/metrics` | Path of prometheus endpoint where metrics will be available | | `--metricspath` | `/metrics` | Path of prometheus endpoint where metrics will be available |
| `--enablegrpcmetrics` | `false` | [Deprecated] Enable grpc metrics collection and start prometheus server |
| `--polltime` | `60s` | Time interval in between each poll | | `--polltime` | `60s` | Time interval in between each poll |
| `--timeout` | `3s` | Probe timeout in seconds | | `--timeout` | `3s` | Probe timeout in seconds |
| `--clustername` | _empty_ | Cluster name to set on subvolume | | `--clustername` | _empty_ | Cluster name to set on subvolume |
| `--histogramoption` | `0.5,2,6` | [Deprecated] Histogram option for grpc metrics, should be comma separated value (ex:= "0.5,2,6" where start=0.5 factor=2, count=6) |
| `--forcecephkernelclient` | `false` | Force enabling Ceph Kernel clients for mounting on kernels < 4.17 | | `--forcecephkernelclient` | `false` | Force enabling Ceph Kernel clients for mounting on kernels < 4.17 |
| `--kernelmountoptions` | _empty_ | Comma separated string of mount options accepted by cephfs kernel mounter | | `--kernelmountoptions` | _empty_ | Comma separated string of mount options accepted by cephfs kernel mounter |
| `--fusemountoptions` | _empty_ | Comma separated string of mount options accepted by ceph-fuse mounter | | `--fusemountoptions` | _empty_ | Comma separated string of mount options accepted by ceph-fuse mounter |

View File

@ -37,11 +37,9 @@ make image-cephcsi
| `--pidlimit` | _0_ | Configure the PID limit in cgroups. The container runtime can restrict the number of processes/tasks which can cause problems while provisioning (or deleting) a large number of volumes. A value of `-1` configures the limit to the maximum, `0` does not configure limits at all. | | `--pidlimit` | _0_ | Configure the PID limit in cgroups. The container runtime can restrict the number of processes/tasks which can cause problems while provisioning (or deleting) a large number of volumes. A value of `-1` configures the limit to the maximum, `0` does not configure limits at all. |
| `--metricsport` | `8080` | TCP port for liveness metrics requests | | `--metricsport` | `8080` | TCP port for liveness metrics requests |
| `--metricspath` | `"/metrics"` | Path of prometheus endpoint where metrics will be available | | `--metricspath` | `"/metrics"` | Path of prometheus endpoint where metrics will be available |
| `--enablegrpcmetrics` | `false` | [Deprecated] Enable grpc metrics collection and start prometheus server |
| `--polltime` | `"60s"` | Time interval in between each poll | | `--polltime` | `"60s"` | Time interval in between each poll |
| `--timeout` | `"3s"` | Probe timeout in seconds | | `--timeout` | `"3s"` | Probe timeout in seconds |
| `--clustername` | _empty_ | Cluster name to set on RBD image | | `--clustername` | _empty_ | Cluster name to set on RBD image |
| `--histogramoption` | `0.5,2,6` | [Deprecated] Histogram option for grpc metrics, should be comma separated value (ex:= "0.5,2,6" where start=0.5 factor=2, count=6) |
| `--domainlabels` | _empty_ | Kubernetes node labels to use as CSI domain labels for topology aware provisioning, should be a comma separated value (ex:= "failure-domain/region,failure-domain/zone") | | `--domainlabels` | _empty_ | Kubernetes node labels to use as CSI domain labels for topology aware provisioning, should be a comma separated value (ex:= "failure-domain/region,failure-domain/zone") |
| `--rbdhardmaxclonedepth` | `8` | Hard limit for maximum number of nested volume clones that are taken before a flatten occurs | | `--rbdhardmaxclonedepth` | `8` | Hard limit for maximum number of nested volume clones that are taken before a flatten occurs |
| `--rbdsoftmaxclonedepth` | `4` | Soft limit for maximum number of nested volume clones that are taken before a flatten occurs | | `--rbdsoftmaxclonedepth` | `4` | Soft limit for maximum number of nested volume clones that are taken before a flatten occurs |

View File

@ -167,15 +167,10 @@ func (fs *Driver) Run(conf *util.Config) {
// passing nil for replication server as cephFS does not support mirroring. // passing nil for replication server as cephFS does not support mirroring.
RS: nil, RS: nil,
} }
server.Start(conf.Endpoint, conf.HistogramOption, srv, conf.EnableGRPCMetrics) server.Start(conf.Endpoint, srv)
if conf.EnableGRPCMetrics {
log.WarningLogMsg("EnableGRPCMetrics is deprecated")
go util.StartMetricsServer(conf)
}
if conf.EnableProfiling { if conf.EnableProfiling {
if !conf.EnableGRPCMetrics {
go util.StartMetricsServer(conf) go util.StartMetricsServer(conf)
}
log.DebugLogMsg("Registering profiling handler") log.DebugLogMsg("Registering profiling handler")
go util.EnableProfiling() go util.EnableProfiling()
} }

View File

@ -19,16 +19,12 @@ package csicommon
import ( import (
"net" "net"
"os" "os"
"strconv"
"strings"
"sync" "sync"
"github.com/ceph/ceph-csi/internal/util/log" "github.com/ceph/ceph-csi/internal/util/log"
"github.com/container-storage-interface/spec/lib/go/csi" "github.com/container-storage-interface/spec/lib/go/csi"
"github.com/csi-addons/spec/lib/go/replication" "github.com/csi-addons/spec/lib/go/replication"
grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
"github.com/prometheus/client_golang/prometheus"
"google.golang.org/grpc" "google.golang.org/grpc"
"k8s.io/klog/v2" "k8s.io/klog/v2"
) )
@ -36,7 +32,7 @@ import (
// NonBlockingGRPCServer defines Non blocking GRPC server interfaces. // NonBlockingGRPCServer defines Non blocking GRPC server interfaces.
type NonBlockingGRPCServer interface { type NonBlockingGRPCServer interface {
// Start services at the endpoint // Start services at the endpoint
Start(endpoint, hstOptions string, srv Servers, metrics bool) Start(endpoint string, srv Servers)
// Waits for the service to stop // Waits for the service to stop
Wait() Wait()
// Stops the service gracefully // Stops the service gracefully
@ -65,9 +61,9 @@ type nonBlockingGRPCServer struct {
} }
// Start start service on endpoint. // Start start service on endpoint.
func (s *nonBlockingGRPCServer) Start(endpoint, hstOptions string, srv Servers, metrics bool) { func (s *nonBlockingGRPCServer) Start(endpoint string, srv Servers) {
s.wg.Add(1) s.wg.Add(1)
go s.serve(endpoint, hstOptions, srv, metrics) go s.serve(endpoint, srv)
} }
// Wait blocks until the WaitGroup counter. // Wait blocks until the WaitGroup counter.
@ -85,7 +81,7 @@ func (s *nonBlockingGRPCServer) ForceStop() {
s.server.Stop() s.server.Stop()
} }
func (s *nonBlockingGRPCServer) serve(endpoint, hstOptions string, srv Servers, metrics bool) { func (s *nonBlockingGRPCServer) serve(endpoint string, srv Servers) {
proto, addr, err := parseEndpoint(endpoint) proto, addr, err := parseEndpoint(endpoint)
if err != nil { if err != nil {
klog.Fatal(err.Error()) klog.Fatal(err.Error())
@ -103,11 +99,7 @@ func (s *nonBlockingGRPCServer) serve(endpoint, hstOptions string, srv Servers,
klog.Fatalf("Failed to listen: %v", err) klog.Fatalf("Failed to listen: %v", err)
} }
opts := []grpc.ServerOption{ server := grpc.NewServer()
NewMiddlewareServerOption(metrics),
}
server := grpc.NewServer(opts...)
s.server = server s.server = server
if srv.IS != nil { if srv.IS != nil {
@ -124,29 +116,6 @@ func (s *nonBlockingGRPCServer) serve(endpoint, hstOptions string, srv Servers,
} }
log.DefaultLog("Listening for connections on address: %#v", listener.Addr()) log.DefaultLog("Listening for connections on address: %#v", listener.Addr())
if metrics {
ho := strings.Split(hstOptions, ",")
const expectedHo = 3
if len(ho) != expectedHo {
klog.Fatalf("invalid histogram options provided: %v", hstOptions)
}
start, e := strconv.ParseFloat(ho[0], 32)
if e != nil {
klog.Fatalf("failed to parse histogram start value: %v", e)
}
factor, e := strconv.ParseFloat(ho[1], 32)
if err != nil {
klog.Fatalf("failed to parse histogram factor value: %v", e)
}
count, e := strconv.Atoi(ho[2])
if err != nil {
klog.Fatalf("failed to parse histogram count value: %v", e)
}
buckets := prometheus.ExponentialBuckets(start, factor, count)
bktOptions := grpc_prometheus.WithHistogramBuckets(buckets)
grpc_prometheus.EnableHandlingTimeHistogram(bktOptions)
grpc_prometheus.Register(server)
}
err = server.Serve(listener) err = server.Serve(listener)
if err != nil { if err != nil {
klog.Fatalf("Failed to server: %v", err) klog.Fatalf("Failed to server: %v", err)

View File

@ -77,15 +77,9 @@ func (fs *Driver) Run(conf *util.Config) {
srv.CS = controller.NewControllerServer(cd) srv.CS = controller.NewControllerServer(cd)
} }
server.Start(conf.Endpoint, conf.HistogramOption, srv, conf.EnableGRPCMetrics) server.Start(conf.Endpoint, srv)
if conf.EnableGRPCMetrics {
log.WarningLogMsg("EnableGRPCMetrics is deprecated")
go util.StartMetricsServer(conf)
}
if conf.EnableProfiling { if conf.EnableProfiling {
if !conf.EnableGRPCMetrics {
go util.StartMetricsServer(conf) go util.StartMetricsServer(conf)
}
log.DebugLogMsg("Registering profiling handler") log.DebugLogMsg("Registering profiling handler")
go util.EnableProfiling() go util.EnableProfiling()
} }

View File

@ -177,11 +177,7 @@ func (r *Driver) Run(conf *util.Config) {
CS: r.cs, CS: r.cs,
NS: r.ns, NS: r.ns,
} }
s.Start(conf.Endpoint, conf.HistogramOption, srv, conf.EnableGRPCMetrics) s.Start(conf.Endpoint, srv)
if conf.EnableGRPCMetrics {
log.WarningLogMsg("EnableGRPCMetrics is deprecated")
go util.StartMetricsServer(conf)
}
r.startProfiling(conf) r.startProfiling(conf)
@ -241,9 +237,7 @@ func (r *Driver) setupCSIAddonsServer(conf *util.Config) error {
// starts the required profiling services. // starts the required profiling services.
func (r *Driver) startProfiling(conf *util.Config) { func (r *Driver) startProfiling(conf *util.Config) {
if conf.EnableProfiling { if conf.EnableProfiling {
if !conf.EnableGRPCMetrics {
go util.StartMetricsServer(conf) go util.StartMetricsServer(conf)
}
log.DebugLogMsg("Registering profiling handler") log.DebugLogMsg("Registering profiling handler")
go util.EnableProfiling() go util.EnableProfiling()
} }

View File

@ -96,8 +96,6 @@ type Config struct {
// metrics related flags // metrics related flags
MetricsPath string // path of prometheus endpoint where metrics will be available MetricsPath string // path of prometheus endpoint where metrics will be available
HistogramOption string // Histogram option for grpc metrics, should be comma separated value,
// ex:= "0.5,2,6" where start=0.5 factor=2, count=6
MetricsIP string // TCP port for liveness/ metrics requests MetricsIP string // TCP port for liveness/ metrics requests
// mount option related flags // mount option related flags
@ -108,7 +106,6 @@ type Config struct {
MetricsPort int // TCP port for liveness/grpc metrics requests MetricsPort int // TCP port for liveness/grpc metrics requests
PollTime time.Duration // time interval in seconds between each poll PollTime time.Duration // time interval in seconds between each poll
PoolTimeout time.Duration // probe timeout in seconds PoolTimeout time.Duration // probe timeout in seconds
EnableGRPCMetrics bool // option to enable grpc metrics
EnableProfiling bool // flag to enable profiling EnableProfiling bool // flag to enable profiling
IsControllerServer bool // if set to true start provisioner server IsControllerServer bool // if set to true start provisioner server