diff --git a/VERSION b/VERSION index 236c7ad..818944f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.0.21 +0.0.22 diff --git a/bundle/manifests/susql-operator.clusterserviceversion.yaml b/bundle/manifests/susql-operator.clusterserviceversion.yaml index 38ac88f..2315148 100644 --- a/bundle/manifests/susql-operator.clusterserviceversion.yaml +++ b/bundle/manifests/susql-operator.clusterserviceversion.yaml @@ -22,14 +22,14 @@ metadata: ] capabilities: Basic Install categories: Monitoring - containerImage: quay.io/sustainable_computing_io/susql_operator:0.0.21 - createdAt: "2024-06-27T17:23:07Z" + containerImage: quay.io/sustainable_computing_io/susql_operator:0.0.22 + createdAt: "2024-07-01T08:04:51Z" description: 'Aggregates energy data from pods tagged with SusQL labels ' operators.operatorframework.io/builder: operator-sdk-v1.34.1 operators.operatorframework.io/project_layout: go.kubebuilder.io/v4 repository: https://github.com/sustainable-computing-io/susql-operator support: https://github.com/sustainable-computing-io/susql-operator/issues - name: susql-operator.v0.0.21 + name: susql-operator.v0.0.22 namespace: placeholder spec: apiservicedefinitions: {} @@ -224,7 +224,7 @@ spec: value: :8081 - name: METRICS-BIND-ADDRESS value: 127.0.0.1:9999 - image: quay.io/sustainable_computing_io/susql_operator:0.0.21 + image: quay.io/sustainable_computing_io/susql_operator:0.0.22 imagePullPolicy: IfNotPresent livenessProbe: httpGet: @@ -328,4 +328,4 @@ spec: provider: name: SusQL Operator Contributors url: https://github.com/sustainable-computing-io/susql-operator - version: 0.0.21 + version: 0.0.22 diff --git a/cmd/main.go b/cmd/main.go index 15b5cce..7b864ed 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -111,6 +111,7 @@ func main() { HealthProbeBindAddress: probeAddr, LeaderElection: enableLeaderElection, LeaderElectionID: "cac735ee.ibm.com", + PprofBindAddress: "127.0.0.1:6060", // LeaderElectionReleaseOnCancel defines if the leader should step down voluntarily // when the Manager ends. This requires the binary to immediately end when the // Manager is stopped, otherwise, this setting is unsafe. Setting this significantly diff --git a/config/manager/kustomization.yaml b/config/manager/kustomization.yaml index 3a9192b..06c051c 100644 --- a/config/manager/kustomization.yaml +++ b/config/manager/kustomization.yaml @@ -5,4 +5,4 @@ kind: Kustomization images: - name: controller newName: quay.io/sustainable_computing_io/susql_operator - newTag: 0.0.21 + newTag: 0.0.22 diff --git a/internal/controller/labelgroup_controller.go b/internal/controller/labelgroup_controller.go index 07ce93a..326c9bb 100644 --- a/internal/controller/labelgroup_controller.go +++ b/internal/controller/labelgroup_controller.go @@ -19,6 +19,7 @@ package controller import ( "context" "fmt" + coreruntime "runtime" "strconv" "time" @@ -73,6 +74,10 @@ func (r *LabelGroupReconciler) Reconcile(ctx context.Context, req ctrl.Request) r.Logger.V(5).Info("[Reconcile] Entered Reconcile().") + var m coreruntime.MemStats + coreruntime.ReadMemStats(&m) + r.Logger.V(5).Info(fmt.Sprintf("Memory: Alloc=%.2f MB TotalAlloc=%.2f MB Sys= %.2f MB NumGC=%v", float32(m.Alloc)/1024.0/1024.0, float32(m.TotalAlloc)/1024.0/1024.0, float32(m.Sys)/1024.0/1024.0, m.NumGC)) + // Get label group object to process if it exists labelGroup := &susqlv1.LabelGroup{} diff --git a/internal/controller/prometheus_manager.go b/internal/controller/prometheus_manager.go index f1d0d5b..c0d9284 100644 --- a/internal/controller/prometheus_manager.go +++ b/internal/controller/prometheus_manager.go @@ -36,20 +36,23 @@ import ( ) var ( - maxQueryTime = "1y" // Look back 'maxQueryTime' for the most recent value + maxQueryTime = "1y" // Look back 'maxQueryTime' for the most recent value + keplerRoundTripper http.RoundTripper = nil + susqlRoundTripper http.RoundTripper = nil ) // Functions to get data from the cluster func (r *LabelGroupReconciler) GetMostRecentValue(susqlPrometheusQuery string) (float64, error) { // Return the most recent value found in the table - var roundtripper http.RoundTripper = nil - if strings.HasPrefix(r.KeplerPrometheusUrl, "https://") { - rttls := &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: true}} - roundtripper = config.NewAuthorizationCredentialsFileRoundTripper("Bearer", "/var/run/secrets/kubernetes.io/serviceaccount/token", rttls) + if susqlRoundTripper == nil { + if strings.HasPrefix(r.SusQLPrometheusDatabaseUrl, "https://") { + rttls := &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: true}} + susqlRoundTripper = config.NewAuthorizationCredentialsFileRoundTripper("Bearer", "/var/run/secrets/kubernetes.io/serviceaccount/token", rttls) + } } client, err := api.NewClient(api.Config{ Address: r.SusQLPrometheusDatabaseUrl, - RoundTripper: roundtripper, + RoundTripper: susqlRoundTripper, }) if err != nil { @@ -90,14 +93,15 @@ func (r *LabelGroupReconciler) GetMostRecentValue(susqlPrometheusQuery string) ( } func (r *LabelGroupReconciler) GetMetricValuesForPodNames(metricName string, podNames []string, namespaceName string) (map[string]float64, error) { - var roundtripper http.RoundTripper = nil - if strings.HasPrefix(r.KeplerPrometheusUrl, "https://") { - rttls := &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: true}} - roundtripper = config.NewAuthorizationCredentialsFileRoundTripper("Bearer", "/var/run/secrets/kubernetes.io/serviceaccount/token", rttls) + if keplerRoundTripper == nil { + if strings.HasPrefix(r.KeplerPrometheusUrl, "https://") { + rttls := &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: true}} + keplerRoundTripper = config.NewAuthorizationCredentialsFileRoundTripper("Bearer", "/var/run/secrets/kubernetes.io/serviceaccount/token", rttls) + } } client, err := api.NewClient(api.Config{ Address: r.KeplerPrometheusUrl, - RoundTripper: roundtripper, + RoundTripper: keplerRoundTripper, }) if err != nil {