Skip to content

Commit

Permalink
more information in logging. bump version.
Browse files Browse the repository at this point in the history
Signed-off-by: Scott Trent <[email protected]>
  • Loading branch information
trent-s committed Jun 24, 2024
1 parent 5525998 commit 1247829
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 24 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.19
0.0.20
10 changes: 5 additions & 5 deletions bundle/manifests/susql-operator.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ metadata:
]
capabilities: Basic Install
categories: Monitoring
containerImage: quay.io/sustainable_computing_io/susql_operator:0.0.19
createdAt: "2024-06-21T06:11:03Z"
containerImage: quay.io/sustainable_computing_io/susql_operator:0.0.20
createdAt: "2024-06-24T04:37:59Z"
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.19
name: susql-operator.v0.0.20
namespace: placeholder
spec:
apiservicedefinitions: {}
Expand Down Expand Up @@ -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.19
image: quay.io/sustainable_computing_io/susql_operator:0.0.20
imagePullPolicy: IfNotPresent
livenessProbe:
httpGet:
Expand Down Expand Up @@ -328,4 +328,4 @@ spec:
provider:
name: SusQL Operator Contributors
url: https://github.com/sustainable-computing-io/susql-operator
version: 0.0.19
version: 0.0.20
2 changes: 1 addition & 1 deletion config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ kind: Kustomization
images:
- name: controller
newName: quay.io/sustainable_computing_io/susql_operator
newTag: 0.0.19
newTag: 0.0.20
34 changes: 17 additions & 17 deletions internal/controller/labelgroup_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ func (r *LabelGroupReconciler) Reconcile(ctx context.Context, req ctrl.Request)
// Decide what action to take based on the state of the labelGroup
switch labelGroup.Status.Phase {
case susqlv1.Initializing:
r.Logger.V(5).Info("[Reconcile] Entered initializing case.")
r.Logger.V(5).Info("[Reconcile-Initializing] Entered initializing case.")
if len(labelGroup.Spec.Labels) > len(susqlPrometheusLabelNames) {
r.Logger.V(0).Error(fmt.Errorf("[Reconcile] The number of provided labels is greater than the maximum number of supported labels (e.g., up to %d labels).", len(susqlPrometheusLabelNames)), "")
r.Logger.V(0).Error(fmt.Errorf("[Reconcile-Initializing] The number of provided labels is greater than the maximum number of supported labels (e.g., up to %d labels).", len(susqlPrometheusLabelNames)), "")
return ctrl.Result{RequeueAfter: fixingDelay}, nil
}

Expand Down Expand Up @@ -141,21 +141,21 @@ func (r *LabelGroupReconciler) Reconcile(ctx context.Context, req ctrl.Request)
labelGroup.Status.Phase = susqlv1.Reloading

if err := r.Status().Update(ctx, labelGroup); err != nil {
r.Logger.V(0).Error(err, "[Reconcile] Couldn't update status of the LabelGroup.")
r.Logger.V(0).Error(err, "[Reconcile-Initializing] Couldn't update status of the LabelGroup.")
return ctrl.Result{RequeueAfter: fixingDelay}, nil
}

// Requeue
return ctrl.Result{}, nil

case susqlv1.Reloading:
r.Logger.V(5).Info("[Reconcile] Entered reloading case.")
r.Logger.V(5).Info("[Reconcile-Reloading] Entered reloading case.")
// Reload data from existing database
if !labelGroup.Spec.DisableUsingMostRecentValue {
totalEnergy, err := r.GetMostRecentValue(labelGroup.Status.SusQLPrometheusQuery)

if err != nil {
r.Logger.V(0).Error(err, "[Reconcile] Couldn't retrieve most recent value.")
r.Logger.V(0).Error(err, "[Reconcile-Reloading] Couldn't retrieve most recent value.")
return ctrl.Result{RequeueAfter: fixingDelay}, nil
}

Expand All @@ -165,28 +165,28 @@ func (r *LabelGroupReconciler) Reconcile(ctx context.Context, req ctrl.Request)
labelGroup.Status.Phase = susqlv1.Aggregating

if err := r.Status().Update(ctx, labelGroup); err != nil {
r.Logger.V(0).Error(err, "[Reconcile] Couldn't update status of the LabelGroup.")
r.Logger.V(0).Error(err, "[Reconcile-Reloading] Couldn't update status of the LabelGroup.")
return ctrl.Result{RequeueAfter: fixingDelay}, nil
}

// Requeue
return ctrl.Result{}, nil

case susqlv1.Aggregating:
r.Logger.V(5).Info("[Reconcile] Entered aggregating case.") // trace
r.Logger.V(5).Info("[Reconcile-Aggregating] Entered aggregating case.") // trace

// Get list of pods matching the label group and namespace
podsInNamespace, err := r.filterPodsInNamespace(ctx, labelGroup.Namespace, labelGroup.Status.KubernetesLabels)

if err != nil || len(podsInNamespace) == 0 {
r.Logger.V(5).Info("[Reconcile] Unable to get podlist.") // trace
r.Logger.V(5).Info(fmt.Sprintf("[Reconcile] LabelName: %s", labelGroup.Name)) // trace
r.Logger.V(5).Info(fmt.Sprintf("[Reconcile] Namespace: %s", labelGroup.Namespace)) // trace
r.Logger.V(5).Info(fmt.Sprintf("[Reconcile] KubernetesLabels: %#v", labelGroup.Status.KubernetesLabels)) // trace
r.Logger.V(5).Info(fmt.Sprintf("[Reconcile] podNamesinNamespace: %s", podsInNamespace)) // trace
r.Logger.V(5).Info(fmt.Sprintf("[Reconcile] ctx: %#v", ctx)) // trace
r.Logger.V(5).Info("[Reconcile-Aggregating] Unable to get podlist.") // trace
r.Logger.V(5).Info(fmt.Sprintf("[Reconcile-Aggregating] LabelName: %s", labelGroup.Name)) // trace
r.Logger.V(5).Info(fmt.Sprintf("[Reconcile-Aggregating] Namespace: %s", labelGroup.Namespace)) // trace
r.Logger.V(5).Info(fmt.Sprintf("[Reconcile-Aggregating] KubernetesLabels: %#v", labelGroup.Status.KubernetesLabels)) // trace
r.Logger.V(5).Info(fmt.Sprintf("[Reconcile-Aggregating] podNamesinNamespace: %s", podsInNamespace)) // trace
r.Logger.V(5).Info(fmt.Sprintf("[Reconcile] ctx: %#v", ctx)) // trace
if err != nil {
r.Logger.V(0).Error(err, "[Reconcile] ERROR: Couldn't get pods for the labels provided.")
r.Logger.V(0).Error(err, "[Reconcile-Aggregating] ERROR: Couldn't get pods for the labels provided.")
}

return ctrl.Result{}, err
Expand All @@ -196,7 +196,7 @@ func (r *LabelGroupReconciler) Reconcile(ctx context.Context, req ctrl.Request)
metricValues, err := r.GetMetricValuesForPodNames(r.KeplerMetricName, podsInNamespace, labelGroup.Namespace)

if err != nil {
r.Logger.V(0).Error(err, "[Reconcile] Querying Prometheus didn't work.")
r.Logger.V(0).Error(err, "[Reconcile-Aggregating] Querying Prometheus didn't work.")
return ctrl.Result{RequeueAfter: errorDelay}, nil
}

Expand Down Expand Up @@ -248,12 +248,12 @@ func (r *LabelGroupReconciler) Reconcile(ctx context.Context, req ctrl.Request)
return ctrl.Result{RequeueAfter: r.SamplingRate}, nil

default:
r.Logger.V(5).Info("[Reconcile] Entered default case.")
r.Logger.V(5).Info("[Reconcile-default] Entered default case.")
// First time seeing this object
labelGroup.Status.Phase = susqlv1.Initializing

if err := r.Status().Update(ctx, labelGroup); err != nil {
r.Logger.V(0).Error(err, "[Reconcile] Couldn't set object to 'Initializing'.")
r.Logger.V(0).Error(err, "[Reconcile-default] Couldn't set object to 'Initializing'.")
}

return ctrl.Result{}, nil
Expand Down
1 change: 1 addition & 0 deletions internal/controller/resource_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ func (r *LabelGroupReconciler) GetPodNamesMatchingLabels(ctx context.Context, la
if err := r.List(ctx, pods, client.UnsafeDisableDeepCopy, (client.MatchingLabels)(labelGroup.Status.KubernetesLabels)); err != nil {
r.Logger.V(5).Info(fmt.Sprintf("[GetPodNamesMatchingLabels] pods: %#v", pods))
r.Logger.V(5).Info(fmt.Sprintf("[GetPodNamesMatchingLabels] labelgroup: %#v", labelGroup))
r.Logger.V(5).Info(fmt.Sprintf("[GetPodNamesMatchingLabels] KubernetesLabels: %#v", labelGroup.Status.KubernetesLabels))
r.Logger.V(0).Error(err, "[GetPodNamesMatchingLabels] List Error:")
return nil, nil, err
}
Expand Down

0 comments on commit 1247829

Please sign in to comment.