Skip to content

Commit

Permalink
[chore] few more enhancements (#138)
Browse files Browse the repository at this point in the history
Signed-off-by: Vishnu Challa <[email protected]>
Co-authored-by: Vishnu Challa <[email protected]>
  • Loading branch information
vishnuchalla and Vishnu Challa authored Nov 1, 2024
1 parent d2588e0 commit 762ae83
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pkg/workerscale/autoscaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (awsAutoScalerScenario *AutoScalerScenario) OrchestrateWorkload(scaleConfig
}
scaledMachineDetails, amiID := getMachines(machineClient, 0)
discardPreviousMachines(prevMachineDetails, scaledMachineDetails)
finalizeMetrics(machineSetsToEdit, scaledMachineDetails, scaleConfig.Indexer, amiID, 0)
finalizeMetrics(machineSetsToEdit, scaledMachineDetails, scaleConfig.Metadata, scaleConfig.Indexer, amiID, 0)
deleteAutoScaler(dynamicClient)
deleteMachineAutoscalers(dynamicClient, machineSetsToEdit)
deleteBatchJob(clientSet, triggerJob)
Expand Down
4 changes: 2 additions & 2 deletions pkg/workerscale/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (awsScenario *BaseScenario) OrchestrateWorkload(scaleConfig ScaleConfig) st
log.Error(err.Error())
}
scaledMachineDetails, amiID := getMachines(machineClient, scaleConfig.ScaleEventEpoch)
finalizeMetrics(&sync.Map{}, scaledMachineDetails, scaleConfig.Indexer, amiID, scaleConfig.ScaleEventEpoch)
finalizeMetrics(&sync.Map{}, scaledMachineDetails, scaleConfig.Metadata, scaleConfig.Indexer, amiID, scaleConfig.ScaleEventEpoch)
return amiID
} else {
machineSetDetails := getMachineSets(machineClient)
Expand All @@ -57,7 +57,7 @@ func (awsScenario *BaseScenario) OrchestrateWorkload(scaleConfig ScaleConfig) st
}
scaledMachineDetails, amiID := getMachines(machineClient, 0)
discardPreviousMachines(prevMachineDetails, scaledMachineDetails)
finalizeMetrics(machineSetsToEdit, scaledMachineDetails, scaleConfig.Indexer, amiID, scaleConfig.ScaleEventEpoch)
finalizeMetrics(machineSetsToEdit, scaledMachineDetails, scaleConfig.Metadata, scaleConfig.Indexer, amiID, scaleConfig.ScaleEventEpoch)
if scaleConfig.GC {
log.Info("Restoring machine sets to previous state")
editMachineSets(machineClient, clientSet, machineSetsToEdit, false)
Expand Down
8 changes: 5 additions & 3 deletions pkg/workerscale/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ func setupMetrics(uuid string, metadata map[string]interface{}, kubeClientProvid
}

// finalizeMetrics performs and indexes required metrics
func finalizeMetrics(machineSetsToEdit *sync.Map, scaledMachineDetails map[string]MachineInfo, indexerValue indexers.Indexer, amiID string, scaleEventEpoch int64) {
func finalizeMetrics(machineSetsToEdit *sync.Map, scaledMachineDetails map[string]MachineInfo, metadata map[string]interface{}, indexerValue indexers.Indexer, amiID string, scaleEventEpoch int64) {
nodeMetrics := measurements.GetMetrics()
normLatencies, latencyQuantiles := calculateMetrics(machineSetsToEdit, scaledMachineDetails, nodeMetrics[0], amiID, scaleEventEpoch)
normLatencies, latencyQuantiles := calculateMetrics(machineSetsToEdit, scaledMachineDetails, metadata, nodeMetrics[0], amiID, scaleEventEpoch)
for _, q := range latencyQuantiles {
nq := q.(mmetrics.LatencyQuantiles)
log.Infof("%s: %s 50th: %v 99th: %v max: %v avg: %v", JobName, nq.QuantileName, nq.P50, nq.P99, nq.Max, nq.Avg)
Expand All @@ -66,7 +66,7 @@ func finalizeMetrics(machineSetsToEdit *sync.Map, scaledMachineDetails map[strin
}

// calculateMetrics calculates the metrics for node bootup times
func calculateMetrics(machineSetsToEdit *sync.Map, scaledMachineDetails map[string]MachineInfo, nodeMetrics *sync.Map, amiID string, scaleEventEpoch int64) ([]interface{}, []interface{}) {
func calculateMetrics(machineSetsToEdit *sync.Map, scaledMachineDetails map[string]MachineInfo, metadata map[string]interface{}, nodeMetrics *sync.Map, amiID string, scaleEventEpoch int64) ([]interface{}, []interface{}) {
var scaleEventTimestamp time.Time
var uuid, machineSetName string
var normLatencies, latencyQuantiles []interface{}
Expand Down Expand Up @@ -113,6 +113,7 @@ func calculateMetrics(machineSetsToEdit *sync.Map, scaledMachineDetails map[stri
JobName: JobName,
Name: nodeMetricValue.Name,
Labels: nodeMetricValue.Labels,
Metadata: metadata,
})
}
quantileMap := map[string][]float64{}
Expand All @@ -128,6 +129,7 @@ func calculateMetrics(machineSetsToEdit *sync.Map, scaledMachineDetails map[stri
latencySummary.UUID = uuid
latencySummary.MetricName = nodeReadyLatencyQuantilesMeasurement
latencySummary.JobName = JobName
latencySummary.Metadata = metadata
return latencySummary
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/workerscale/rosa.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (rosaScenario *RosaScenario) OrchestrateWorkload(scaleConfig ScaleConfig) s
if err := measurements.Stop(); err != nil {
log.Error(err.Error())
}
finalizeMetrics(&sync.Map{}, scaledMachineDetails, scaleConfig.Indexer, amiID, scaleConfig.ScaleEventEpoch)
finalizeMetrics(&sync.Map{}, scaledMachineDetails, scaleConfig.Metadata, scaleConfig.Indexer, amiID, scaleConfig.ScaleEventEpoch)
return amiID
} else {
prevMachineDetails, _ := getMachineDetails(machineClient, 0, clusterID, hcNamespace, scaleConfig.IsHCP)
Expand All @@ -93,7 +93,7 @@ func (rosaScenario *RosaScenario) OrchestrateWorkload(scaleConfig ScaleConfig) s
if err := measurements.Stop(); err != nil {
log.Error(err.Error())
}
finalizeMetrics(&sync.Map{}, scaledMachineDetails, scaleConfig.Indexer, amiID, triggerTime.Unix())
finalizeMetrics(&sync.Map{}, scaledMachineDetails, scaleConfig.Metadata, scaleConfig.Indexer, amiID, triggerTime.Unix())
if scaleConfig.GC {
log.Info("Restoring machine pool to previous state")
editMachinepool(clusterID, len(prevMachineDetails), len(prevMachineDetails), scaleConfig.AutoScalerEnabled, scaleConfig.IsHCP)
Expand Down
1 change: 1 addition & 0 deletions pkg/workerscale/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,5 @@ type NodeReadyMetric struct {
JobName string `json:"jobName,omitempty"`
Name string `json:"nodeName"`
Labels map[string]string `json:"labels"`
Metadata interface{} `json:"metadata,omitempty"`
}

0 comments on commit 762ae83

Please sign in to comment.