Skip to content

Commit

Permalink
support muilt job name
Browse files Browse the repository at this point in the history
  • Loading branch information
jiuker authored and pjuarezd committed Dec 9, 2024
1 parent 4821492 commit 982f5d4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions pkg/controller/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"context"
"errors"
"reflect"
"strings"

promv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
promv1alpha1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1alpha1"
Expand Down Expand Up @@ -169,7 +170,7 @@ func (c *Controller) checkAndCreatePrometheusAddlConfig(ctx context.Context, ten
}
// get other scrape configs
for _, sc := range scrapeConfigs {
if sc.JobName != tenant.PrometheusOperatorAddlConfigJobName() {
if !strings.HasPrefix(sc.JobName, tenant.PrometheusOperatorAddlConfigJobName()) {
exceptedScrapeConfigs = append(exceptedScrapeConfigs, sc)
}
}
Expand Down Expand Up @@ -231,7 +232,7 @@ func (c *Controller) deletePrometheusAddlConfig(ctx context.Context, tenant *min
return err
}
for _, sc := range scrapeConfigs {
if sc.JobName != tenant.PrometheusOperatorAddlConfigJobName() {
if !strings.HasPrefix(sc.JobName, tenant.PrometheusOperatorAddlConfigJobName()) {
exceptedScrapeConfigs = append(exceptedScrapeConfigs, sc)
}
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/resources/configmaps/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ func GetPrometheusConfig(t *miniov2.Tenant, accessKey, secretKey string) *Promet
t.Spec.PrometheusOperatorScrapeMetricsPath = []string{"/minio/v2/metrics/cluster"}
}

for _, scrape := range t.Spec.PrometheusOperatorScrapeMetricsPath {
for index, scrape := range t.Spec.PrometheusOperatorScrapeMetricsPath {
promConfig.ScrapeConfigs = append(promConfig.ScrapeConfigs, ScrapeConfig{
JobName: t.PrometheusConfigJobName(),
JobName: fmt.Sprintf("%s-%d", t.PrometheusOperatorAddlConfigJobName(), index),
BearerToken: bearerToken,
MetricsPath: scrape,
Scheme: minioScheme,
Expand Down

0 comments on commit 982f5d4

Please sign in to comment.