diff --git a/pkg/workerscale/autoscaler.go b/pkg/workerscale/autoscaler.go index b25ff5a8..cc97e738 100644 --- a/pkg/workerscale/autoscaler.go +++ b/pkg/workerscale/autoscaler.go @@ -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) diff --git a/pkg/workerscale/base.go b/pkg/workerscale/base.go index de92d29e..9cd39054 100644 --- a/pkg/workerscale/base.go +++ b/pkg/workerscale/base.go @@ -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) @@ -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) diff --git a/pkg/workerscale/metrics.go b/pkg/workerscale/metrics.go index d6675309..d7afb6eb 100644 --- a/pkg/workerscale/metrics.go +++ b/pkg/workerscale/metrics.go @@ -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) @@ -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{} @@ -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{} @@ -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 } diff --git a/pkg/workerscale/rosa.go b/pkg/workerscale/rosa.go index 98411ebe..9a9f6347 100644 --- a/pkg/workerscale/rosa.go +++ b/pkg/workerscale/rosa.go @@ -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) @@ -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) diff --git a/pkg/workerscale/types.go b/pkg/workerscale/types.go index 889fed7e..ab0e7726 100644 --- a/pkg/workerscale/types.go +++ b/pkg/workerscale/types.go @@ -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"` }