Skip to content

Commit

Permalink
Use embedded metrics-profiles in index subcmd (#137)
Browse files Browse the repository at this point in the history
* Use embedded metrics-profiles in index subcmd

Signed-off-by: Raul Sevilla <[email protected]>

* Remove embedded flag

Signed-off-by: Raul Sevilla <[email protected]>

---------

Signed-off-by: Raul Sevilla <[email protected]>
  • Loading branch information
rsevilla87 authored Nov 19, 2024
1 parent f9b61da commit b7b2288
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cmd/ocp.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func openShiftCmd() *cobra.Command {
ocp.NewNodeDensityHeavy(&wh),
ocp.NewNodeDensityCNI(&wh),
ocp.NewUDNDensityPods(&wh),
ocp.NewIndex(&wh.MetricsEndpoint, &wh.MetadataAgent),
ocp.NewIndex(&wh, ocpConfig),
ocp.NewWorkersScale(&wh.MetricsEndpoint, &wh.MetadataAgent),
ocp.NewPVCDensity(&wh),
ocp.NewRDSCore(&wh),
Expand Down
15 changes: 9 additions & 6 deletions index.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
package ocp

import (
"embed"
"encoding/json"
"fmt"
"os"
"time"

"github.com/cloud-bulldozer/go-commons/indexers"
ocpmetadata "github.com/cloud-bulldozer/go-commons/ocp-metadata"
"github.com/cloud-bulldozer/go-commons/version"
"github.com/kube-burner/kube-burner/pkg/burner"
"github.com/kube-burner/kube-burner/pkg/config"
Expand All @@ -33,7 +33,7 @@ import (
)

// NewIndex orchestrates indexing for ocp wrapper
func NewIndex(metricsEndpoint *string, ocpMetaAgent *ocpmetadata.Metadata) *cobra.Command {
func NewIndex(wh *workloads.WorkloadHelper, ocpConfig embed.FS) *cobra.Command {
var jobName string
var metricsProfiles []string
var start, end int64
Expand All @@ -57,16 +57,16 @@ func NewIndex(metricsEndpoint *string, ocpMetaAgent *ocpmetadata.Metadata) *cobr
Run: func(cmd *cobra.Command, args []string) {
jobEnd := end
uuid, _ = cmd.Flags().GetString("uuid")
clusterMetadata, err := ocpMetaAgent.GetClusterMetadata()
clusterMetadata, err := wh.MetadataAgent.GetClusterMetadata()
if err != nil {
log.Fatal("Error obtaining clusterMetadata: ", err.Error())
}
esServer, _ := cmd.Flags().GetString("es-server")
esIndex, _ := cmd.Flags().GetString("es-index")
workloads.ConfigSpec.GlobalConfig.UUID = uuid
// When metricsEndpoint is specified, don't fetch any prometheus token
if *metricsEndpoint == "" {
prometheusURL, prometheusToken, err = ocpMetaAgent.GetPrometheus()
if wh.MetricsEndpoint == "" {
prometheusURL, prometheusToken, err = wh.MetadataAgent.GetPrometheus()
if err != nil {
log.Fatal("Error obtaining prometheus information from cluster: ", err.Error())
}
Expand Down Expand Up @@ -102,11 +102,14 @@ func NewIndex(metricsEndpoint *string, ocpMetaAgent *ocpmetadata.Metadata) *cobr
metadata[k] = v
}
workloads.ConfigSpec.MetricsEndpoints = append(workloads.ConfigSpec.MetricsEndpoints, indexer)
workloads.ConfigSpec.EmbedFSDir = wh.ConfigDir + "/metrics"
workloads.ConfigSpec.EmbedFS = ocpConfig
metricsScraper := metrics.ProcessMetricsScraperConfig(metrics.ScraperConfig{
ConfigSpec: &workloads.ConfigSpec,
MetricsEndpoint: *metricsEndpoint,
MetricsEndpoint: wh.MetricsEndpoint,
UserMetaData: userMetadata,
MetricsMetadata: metadata,
EmbedConfig: true,
})
for _, prometheusClient := range metricsScraper.PrometheusClients {
prometheusJob := prometheus.Job{
Expand Down

0 comments on commit b7b2288

Please sign in to comment.