From 69ad3c7e4eecaf45bd42f96e4c73b92e5086665d Mon Sep 17 00:00:00 2001 From: Satyanarayana Kolluri Date: Tue, 24 Jun 2025 12:50:26 +0530 Subject: [PATCH] Added logic to run the profiling server as required --- cmd/syncer/main.go | 12 ++++++++++++ cmd/vsphere-csi/main.go | 13 +++++++++++++ manifests/guestcluster/1.31/pvcsi.yaml | 2 ++ manifests/guestcluster/1.32/pvcsi.yaml | 2 ++ manifests/guestcluster/1.33/pvcsi.yaml | 2 ++ manifests/supervisorcluster/1.29/cns-csi.yaml | 3 +++ manifests/supervisorcluster/1.30/cns-csi.yaml | 3 +++ manifests/supervisorcluster/1.31/cns-csi.yaml | 3 +++ manifests/vanilla/vsphere-csi-driver.yaml | 2 ++ 9 files changed, 42 insertions(+) diff --git a/cmd/syncer/main.go b/cmd/syncer/main.go index b88b9bb84d..1209dc3969 100644 --- a/cmd/syncer/main.go +++ b/cmd/syncer/main.go @@ -21,6 +21,7 @@ import ( "flag" "fmt" "net/http" + _ "net/http/pprof" "os" "os/signal" "regexp" @@ -84,6 +85,7 @@ var ( internalFSSNamespace = flag.String("fss-namespace", "", "Namespace of the feature state switch configmap") periodicSyncIntervalInMin = flag.Duration("storagequota-sync-interval", 30*time.Minute, "Periodic sync interval in Minutes") + enableProfileServer = flag.Bool("enable-profile-server", false, "Enable profiling endpoint for the syncer.") ) // main for vsphere syncer. @@ -98,6 +100,16 @@ func main() { ctx, log := logger.GetNewContextWithLogger() log.Infof("Version : %s", syncer.Version) + if *enableProfileServer { + go func() { + log.Info("Starting the http server to expose profiling metrics..") + err := http.ListenAndServe(":9501", nil) + if err != nil { + log.Fatalf("Unable to start profiling server: %s", err) + } + }() + } + // Set CO agnostic init params. clusterFlavor, err := config.GetClusterFlavor(ctx) if err != nil { diff --git a/cmd/vsphere-csi/main.go b/cmd/vsphere-csi/main.go index 29b3a4958c..f0b1a2507b 100644 --- a/cmd/vsphere-csi/main.go +++ b/cmd/vsphere-csi/main.go @@ -20,6 +20,8 @@ import ( "context" "flag" "fmt" + "net/http" + _ "net/http/pprof" "os" "os/signal" "syscall" @@ -41,6 +43,7 @@ var ( "Namespace of the feature state switch configmap in supervisor cluster") internalFSSName = flag.String("fss-name", "", "Name of the feature state switch configmap") internalFSSNamespace = flag.String("fss-namespace", "", "Namespace of the feature state switch configmap") + enableProfileServer = flag.Bool("enable-profile-server", false, "Enable profiling endpoint for the controller.") ) // main is ignored when this package is built as a go plug-in. @@ -55,6 +58,16 @@ func main() { ctx, log := logger.GetNewContextWithLogger() log.Infof("Version : %s", service.Version) + if *enableProfileServer { + go func() { + log.Info("Starting the http server to expose profiling metrics..") + err := http.ListenAndServe(":9500", nil) + if err != nil { + log.Fatalf("Unable to start profiling server: %s", err) + } + }() + } + // Set CO Init params. clusterFlavor, err := csiconfig.GetClusterFlavor(ctx) if err != nil { diff --git a/manifests/guestcluster/1.31/pvcsi.yaml b/manifests/guestcluster/1.31/pvcsi.yaml index 287b18d92e..1b811f014c 100644 --- a/manifests/guestcluster/1.31/pvcsi.yaml +++ b/manifests/guestcluster/1.31/pvcsi.yaml @@ -200,6 +200,7 @@ spec: - "--supervisor-fss-namespace=$(CSI_NAMESPACE)" - "--fss-name=internal-feature-states.csi.vsphere.vmware.com" - "--fss-namespace=$(CSI_NAMESPACE)" + - "--enable-profile-server=false" imagePullPolicy: "IfNotPresent" ports: - containerPort: 2112 @@ -270,6 +271,7 @@ spec: - "--supervisor-fss-namespace=$(CSI_NAMESPACE)" - "--fss-name=internal-feature-states.csi.vsphere.vmware.com" - "--fss-namespace=$(CSI_NAMESPACE)" + - "--enable-profile-server=false" imagePullPolicy: "IfNotPresent" ports: - containerPort: 2113 diff --git a/manifests/guestcluster/1.32/pvcsi.yaml b/manifests/guestcluster/1.32/pvcsi.yaml index 4f0b4e857f..19f97eede7 100644 --- a/manifests/guestcluster/1.32/pvcsi.yaml +++ b/manifests/guestcluster/1.32/pvcsi.yaml @@ -200,6 +200,7 @@ spec: - "--supervisor-fss-namespace=$(CSI_NAMESPACE)" - "--fss-name=internal-feature-states.csi.vsphere.vmware.com" - "--fss-namespace=$(CSI_NAMESPACE)" + - "--enable-profile-server=false" imagePullPolicy: "IfNotPresent" ports: - containerPort: 2112 @@ -270,6 +271,7 @@ spec: - "--supervisor-fss-namespace=$(CSI_NAMESPACE)" - "--fss-name=internal-feature-states.csi.vsphere.vmware.com" - "--fss-namespace=$(CSI_NAMESPACE)" + - "--enable-profile-server=false" imagePullPolicy: "IfNotPresent" ports: - containerPort: 2113 diff --git a/manifests/guestcluster/1.33/pvcsi.yaml b/manifests/guestcluster/1.33/pvcsi.yaml index 768cb007b7..7b3760a5b2 100644 --- a/manifests/guestcluster/1.33/pvcsi.yaml +++ b/manifests/guestcluster/1.33/pvcsi.yaml @@ -200,6 +200,7 @@ spec: - "--supervisor-fss-namespace=$(CSI_NAMESPACE)" - "--fss-name=internal-feature-states.csi.vsphere.vmware.com" - "--fss-namespace=$(CSI_NAMESPACE)" + - "--enable-profile-server=false" imagePullPolicy: "IfNotPresent" ports: - containerPort: 2112 @@ -270,6 +271,7 @@ spec: - "--supervisor-fss-namespace=$(CSI_NAMESPACE)" - "--fss-name=internal-feature-states.csi.vsphere.vmware.com" - "--fss-namespace=$(CSI_NAMESPACE)" + - "--enable-profile-server=false" imagePullPolicy: "IfNotPresent" ports: - containerPort: 2113 diff --git a/manifests/supervisorcluster/1.29/cns-csi.yaml b/manifests/supervisorcluster/1.29/cns-csi.yaml index 39efb430ae..c6ddf0d8f0 100644 --- a/manifests/supervisorcluster/1.29/cns-csi.yaml +++ b/manifests/supervisorcluster/1.29/cns-csi.yaml @@ -375,6 +375,8 @@ spec: name: socket-dir - name: vsphere-csi-controller image: localhost:5000/vmware/vsphere-csi: + args: + - "--enable-profile-server=false" ports: - containerPort: 2112 name: prometheus @@ -446,6 +448,7 @@ spec: - "--leader-election-retry-period=30s" - "--storagequota-sync-interval=10m" - "--webhook-client-cert-verification" + - "--enable-profile-server=false" env: - name: CLUSTER_FLAVOR value: "WORKLOAD" diff --git a/manifests/supervisorcluster/1.30/cns-csi.yaml b/manifests/supervisorcluster/1.30/cns-csi.yaml index 28010122c7..09b841cb5b 100644 --- a/manifests/supervisorcluster/1.30/cns-csi.yaml +++ b/manifests/supervisorcluster/1.30/cns-csi.yaml @@ -382,6 +382,8 @@ spec: name: socket-dir - name: vsphere-csi-controller image: localhost:5000/vmware/vsphere-csi: + args: + - "--enable-profile-server=false" ports: - containerPort: 2112 name: prometheus @@ -453,6 +455,7 @@ spec: - "--leader-election-retry-period=30s" - "--storagequota-sync-interval=10m" - "--webhook-client-cert-verification" + - "--enable-profile-server=false" env: - name: CLUSTER_FLAVOR value: "WORKLOAD" diff --git a/manifests/supervisorcluster/1.31/cns-csi.yaml b/manifests/supervisorcluster/1.31/cns-csi.yaml index 28010122c7..09b841cb5b 100644 --- a/manifests/supervisorcluster/1.31/cns-csi.yaml +++ b/manifests/supervisorcluster/1.31/cns-csi.yaml @@ -382,6 +382,8 @@ spec: name: socket-dir - name: vsphere-csi-controller image: localhost:5000/vmware/vsphere-csi: + args: + - "--enable-profile-server=false" ports: - containerPort: 2112 name: prometheus @@ -453,6 +455,7 @@ spec: - "--leader-election-retry-period=30s" - "--storagequota-sync-interval=10m" - "--webhook-client-cert-verification" + - "--enable-profile-server=false" env: - name: CLUSTER_FLAVOR value: "WORKLOAD" diff --git a/manifests/vanilla/vsphere-csi-driver.yaml b/manifests/vanilla/vsphere-csi-driver.yaml index 371833a559..8a5d7912bf 100644 --- a/manifests/vanilla/vsphere-csi-driver.yaml +++ b/manifests/vanilla/vsphere-csi-driver.yaml @@ -282,6 +282,7 @@ spec: args: - "--fss-name=internal-feature-states.csi.vsphere.vmware.com" - "--fss-namespace=$(CSI_NAMESPACE)" + - "--enable-profile-server=false" imagePullPolicy: "Always" env: - name: CSI_ENDPOINT @@ -346,6 +347,7 @@ spec: - "--leader-election-retry-period=10s" - "--fss-name=internal-feature-states.csi.vsphere.vmware.com" - "--fss-namespace=$(CSI_NAMESPACE)" + - "--enable-profile-server=false" imagePullPolicy: "Always" ports: - containerPort: 2113