From 20727bd41af44e4b9bca686ffb2b13a5cf103673 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Mon, 29 Nov 2021 10:49:18 +0100 Subject: [PATCH] cleanup: reduce complexity of rbd.Driver.Run() After adding the new CSI-Addons Server, golang-ci complains that driver.Run() is too complex. By moving the profiling checks and starting of the go-routines in their own function, golang-ci is happy again. Signed-off-by: Niels de Vos --- internal/rbd/driver.go | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/internal/rbd/driver.go b/internal/rbd/driver.go index 09db97164..95898e140 100644 --- a/internal/rbd/driver.go +++ b/internal/rbd/driver.go @@ -214,13 +214,9 @@ func (r *Driver) Run(conf *util.Config) { log.WarningLogMsg("EnableGRPCMetrics is deprecated") go util.StartMetricsServer(conf) } - if conf.EnableProfiling { - if !conf.EnableGRPCMetrics { - go util.StartMetricsServer(conf) - } - log.DebugLogMsg("Registering profiling handler") - go util.EnableProfiling() - } + + r.startProfiling(conf) + if conf.IsNodeServer { go func() { // TODO: move the healer to csi-addons @@ -255,3 +251,15 @@ func (r *Driver) setupCSIAddonsServer(endpoint string) error { return nil } + +// startProfiling checks which profiling options are enabled in the config and +// starts the required profiling services. +func (r *Driver) startProfiling(conf *util.Config) { + if conf.EnableProfiling { + if !conf.EnableGRPCMetrics { + go util.StartMetricsServer(conf) + } + log.DebugLogMsg("Registering profiling handler") + go util.EnableProfiling() + } +}