Skip to content

Commit

Permalink
Use consistent UpperCamelCase for ConfigMap and LabelGroup
Browse files Browse the repository at this point in the history
Signed-off-by: Scott Trent <[email protected]>
  • Loading branch information
trent-s committed Aug 29, 2024
1 parent 8386139 commit 5a23749
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 19 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ SusQL is an operator that can be deployed in a Kubernetes/OpenShift cluster. You
There are two currently CO2 emission calculation methods available, and an additional method is under development.
- The default CO2 emission calculation method is called "static", and simply uses a grams of CO2 per Joule
of electricity consumed coefficient to calculate grams of CO2 emitted. This value is user tunable by
modifying the `CARBON-INTENSITY` configmap value. The default value is based on
modifying the `CARBON-INTENSITY` ConfigMap value. The default value is based on
[US EPA](https://www.epa.gov/energy/greenhouse-gases-equivalencies-calculator-calculations-and-references)
data.
- The "simpledynamic" method periodically queries the carbon intensity value for a user specified location to provide a more accurate estimation of CO2 emission.
The configmap user configurable items are:
The ConfigMap user configurable items are:
- `CARBON-METHOD` - The "simpledynamic" method is enabled when set to `simpledynamic`.
- `CARBON-INTENSITY` - This value is set automatically. User specified values will be overwritten.
- `CARBON-INTENSITY-URL` - Specifies a web API that returns carbon intensity. The default value works as of the date of this writing.
Expand Down
8 changes: 4 additions & 4 deletions api/v1/labelgroup_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type LabelGroupStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file

// Transition phase of the label group
// Transition phase of the LabelGroup
Phase LabelGroupPhase `json:"phase,omitempty"`

// SusQL Kubernetes labels constructed from the spec
Expand All @@ -55,7 +55,7 @@ type LabelGroupStatus struct {
// TotalCarbon keeps track of the accumulated grams of carbon dioxide emission over time
TotalCarbon string `json:"totalCarbon,omitempty"`

// Prometheus query to get the total energy for this label group
// Prometheus query to get the total energy for this LabelGroup
SusQLPrometheusQuery string `json:"susqlPrometheusQuery,omitempty"`

// Active containers associated with these set of labels
Expand All @@ -66,13 +66,13 @@ type LabelGroupStatus struct {
type LabelGroupPhase string

const (
// Initializing: The label group is picked up for the first time and setup
// Initializing: The LabelGroup is picked up for the first time and setup
Initializing LabelGroupPhase = "Initializing"

// Reloading: Use most recent value in the database if requested
Reloading LabelGroupPhase = "Reloading"

// Aggregating: The label group is aggregating the energy for the registered labels
// Aggregating: The LabelGroup is aggregating the energy for the registered labels
Aggregating LabelGroupPhase = "Aggregating"
)

Expand Down
7 changes: 3 additions & 4 deletions config/crd/bases/susql.ibm.com_labelgroups.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ spec:
- name: v1
schema:
openAPIV3Schema:
description: LabelGroup is the Schema for the labelgroups API
description: LabelGroup is the Schema for the LabelGroups API
properties:
apiVersion:
description: |-
Expand Down Expand Up @@ -63,16 +63,15 @@ spec:
description: SusQL Kubernetes labels constructed from the spec
type: object
phase:
description: Transition phase of the label group
description: Transition phase of the LabelGroup
type: string
prometheusLabels:
additionalProperties:
type: string
description: SusQL Prometheus labels constructed from the spec
type: object
susqlPrometheusQuery:
description: Prometheus query to get the total energy for this label
group
description: Prometheus query to get the total energy for this LabelGroup
type: string
totalCarbon:
description: TotalCarbon keeps track of the accumulated grams of carbon
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ spec:
apiservicedefinitions: {}
customresourcedefinitions:
owned:
- description: LabelGroup is the Schema for the labelgroups API
- description: LabelGroup is the Schema for the LabelGroups API
displayName: Label Group
kind: LabelGroup
name: labelgroups.susql.ibm.com
Expand Down
6 changes: 3 additions & 3 deletions doc/operatorhub-installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ Next, use the OpenShift web console to install the SusQL Operator:

# Customization

Before deploying the SusQL Operator create a `configMap` called `susql-config` in
Before deploying the SusQL Operator create a `ConfigMap` called `susql-config` in
the same namespace that the operator will run in.
[susql-config.yaml](susql-config.yaml) is a good starting point. If you download it first, you
could create the configMap with `oc apply -n YOURNAMESPACE -f susql-config.yaml`.
If you update (or create) the configMap after the SusQL Operator has been installed, then restarting the SusQL Operator controller pod will
could create the ConfigMap with `oc apply -n YOURNAMESPACE -f susql-config.yaml`.
If you update (or create) the ConfigMap after the SusQL Operator has been installed, then restarting the SusQL Operator controller pod will
enable the changes. (e.g., Delete the pod, and allow it to be recreated automatically.)

# Post Installation Steps
Expand Down
8 changes: 4 additions & 4 deletions internal/controller/labelgroup_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ type LabelGroupReconciler struct {
KeplerMetricName string
SusQLPrometheusDatabaseUrl string
SusQLPrometheusMetricsUrl string
SamplingRate time.Duration // Sampling rate for all label groups
SamplingRate time.Duration // Sampling rate for all LabelGroups
CarbonMethod string
CarbonIntensity float64
CarbonIntensityUrl string
Expand All @@ -55,7 +55,7 @@ type LabelGroupReconciler struct {

const (
susqlMetricName = "susql_total_energy_joules" // SusQL metric to query
fixingDelay = 15 * time.Second // Time to wait in the event the label group was badly constructed
fixingDelay = 15 * time.Second // Time to wait in the event the LabelGroup was badly constructed
nopodDelay = 15 * time.Second // Time to wait in the event no pods are found
errorDelay = 1 * time.Second // Time to wait when an error happens due to network connectivity issues
)
Expand Down Expand Up @@ -87,7 +87,7 @@ func (r *LabelGroupReconciler) Reconcile(ctx context.Context, req ctrl.Request)
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
// Get LabelGroup object to process if it exists
labelGroup := &susqlv1.LabelGroup{}

// Get deep copy of LabelGroup object in reconciler cache
Expand Down Expand Up @@ -209,7 +209,7 @@ func (r *LabelGroupReconciler) Reconcile(ctx context.Context, req ctrl.Request)
case susqlv1.Aggregating:
r.Logger.V(5).Info("[Reconcile-Aggregating] Entered aggregating case.") // trace

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

if err != nil || len(podsInNamespace) == 0 {
Expand Down
2 changes: 1 addition & 1 deletion internal/controller/resource_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,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] 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 5a23749

Please sign in to comment.