Last active
October 5, 2023 00:45
-
-
Save pintohutch/a062265e23660ac1ee9ff55ac3ec96da to your computer and use it in GitHub Desktop.
Generated via `git diff v0.8.0-rc.1..v0.7.4 -- . ':!*_test.go' '!:vendor/*' ':!*.md' ':!Makefile' ':!examples/*' ':!hack/*'` to target only production changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/cmd/operator/deploy/crds/monitoring.googleapis.com_operatorconfigs.yaml b/cmd/operator/deploy/crds/monitoring.googleapis.com_operatorconfigs.yaml | |
index 585713d9e..d61478b72 100644 | |
--- a/cmd/operator/deploy/crds/monitoring.googleapis.com_operatorconfigs.yaml | |
+++ b/cmd/operator/deploy/crds/monitoring.googleapis.com_operatorconfigs.yaml | |
@@ -93,6 +93,16 @@ spec: | |
type: object | |
description: Features holds configuration for optional managed-collection features. | |
properties: | |
+ config: | |
+ type: object | |
+ description: Settings for the collector configuration propagation. | |
+ properties: | |
+ compression: | |
+ type: string | |
+ description: Compression enables compression of the config data propagated by the operator to collectors. It is recommended to use the gzip option when using a large number of ClusterPodMonitoring and/or PodMonitoring. | |
+ enum: | |
+ - none | |
+ - gzip | |
targetStatus: | |
type: object | |
description: Configuration of target status reporting. | |
diff --git a/cmd/rule-evaluator/main.go b/cmd/rule-evaluator/main.go | |
index 7ba9dda7f..56c120d13 100644 | |
--- a/cmd/rule-evaluator/main.go | |
+++ b/cmd/rule-evaluator/main.go | |
@@ -36,7 +36,6 @@ import ( | |
"github.com/oklog/run" | |
"google.golang.org/api/option" | |
apihttp "google.golang.org/api/transport/http" | |
- "google.golang.org/grpc" | |
"gopkg.in/alecthomas/kingpin.v2" | |
"github.com/prometheus/client_golang/api" | |
@@ -82,6 +81,7 @@ func main() { | |
reg.MustRegister( | |
prometheus.NewGoCollector(), | |
prometheus.NewProcessCollector(prometheus.ProcessCollectorOpts{}), | |
+ grpc_prometheus.DefaultClientMetrics, | |
) | |
// The rule-evaluator version is identical to the export library version for now, so | |
@@ -163,12 +163,9 @@ func main() { | |
ctxRuleManger := context.Background() | |
ctxDiscover, cancelDiscover := context.WithCancel(context.Background()) | |
- grpc_prometheus.EnableClientHandlingTimeHistogram() | |
- | |
opts := []option.ClientOption{ | |
option.WithScopes("https://www.googleapis.com/auth/monitoring.read"), | |
option.WithUserAgent(fmt.Sprintf("rule-evaluator/%s", version)), | |
- option.WithGRPCDialOption(grpc.WithUnaryInterceptor(grpc_prometheus.UnaryClientInterceptor)), | |
} | |
if *queryCredentialsFile != "" { | |
opts = append(opts, option.WithCredentialsFile(*queryCredentialsFile)) | |
@@ -178,9 +175,10 @@ func main() { | |
level.Error(logger).Log("msg", "Creating proxy HTTP transport failed", "err", err) | |
os.Exit(1) | |
} | |
+ roundTripper := makeInstrumentedRoundTripper(transport, reg) | |
client, err := api.NewClient(api.Config{ | |
Address: *targetURL, | |
- RoundTripper: transport, | |
+ RoundTripper: roundTripper, | |
}) | |
if err != nil { | |
level.Error(logger).Log("msg", "Error creating client", "err", err) | |
@@ -648,3 +646,28 @@ func (db *queryAccess) Select(sort bool, hints *storage.SelectHints, matchers .. | |
func (db *queryAccess) Close() error { | |
return nil | |
} | |
+ | |
+// makeInstrumentedRoundTripper instruments the original RoundTripper with middleware to observe the request result. | |
+// The new RoundTripper counts the number of query requests sent to GCM and measures the latency of each request. | |
+func makeInstrumentedRoundTripper(transport http.RoundTripper, reg prometheus.Registerer) http.RoundTripper { | |
+ queryCounter := prometheus.NewCounterVec( | |
+ prometheus.CounterOpts{ | |
+ Name: "rule_evaluator_query_requests_total", | |
+ Help: "A counter for query requests sent to GCM.", | |
+ }, | |
+ []string{"code", "method"}, | |
+ ) | |
+ queryHistogram := prometheus.NewHistogramVec( | |
+ prometheus.HistogramOpts{ | |
+ Name: "rule_evaluator_query_requests_latency_seconds", | |
+ Help: "Histogram of response latency of query requests sent to GCM.", | |
+ Buckets: prometheus.DefBuckets, | |
+ }, | |
+ []string{"code", "method"}, | |
+ ) | |
+ reg.MustRegister(queryCounter, queryHistogram) | |
+ | |
+ return promhttp.InstrumentRoundTripperCounter(queryCounter, | |
+ promhttp.InstrumentRoundTripperDuration(queryHistogram, transport)) | |
+ | |
+} | |
diff --git a/go.mod b/go.mod | |
index 065fd4994..5e4c1f348 100644 | |
--- a/go.mod | |
+++ b/go.mod | |
@@ -1,6 +1,6 @@ | |
module github.com/GoogleCloudPlatform/prometheus-engine | |
-go 1.18 | |
+go 1.20 | |
require ( | |
cloud.google.com/go/compute/metadata v0.2.2 | |
@@ -34,7 +34,6 @@ require ( | |
k8s.io/code-generator v0.26.8 | |
k8s.io/utils v0.0.0-20221128185143-99ec85e7a448 | |
sigs.k8s.io/controller-runtime v0.14.6 | |
- sigs.k8s.io/yaml v1.3.0 | |
) | |
require ( | |
@@ -118,6 +117,7 @@ require ( | |
k8s.io/kube-openapi v0.0.0-20221207184640-f3cff1453715 // indirect | |
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect | |
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect | |
+ sigs.k8s.io/yaml v1.3.0 // indirect | |
) | |
// Exclude pre-go-mod kubernetes tags, as they are older | |
diff --git a/manifests/setup.yaml b/manifests/setup.yaml | |
index 096ad09fd..9de263914 100644 | |
--- a/manifests/setup.yaml | |
+++ b/manifests/setup.yaml | |
@@ -929,6 +929,16 @@ spec: | |
type: object | |
description: Features holds configuration for optional managed-collection features. | |
properties: | |
+ config: | |
+ type: object | |
+ description: Settings for the collector configuration propagation. | |
+ properties: | |
+ compression: | |
+ type: string | |
+ description: Compression enables compression of the config data propagated by the operator to collectors. It is recommended to use the gzip option when using a large number of ClusterPodMonitoring and/or PodMonitoring. | |
+ enum: | |
+ - none | |
+ - gzip | |
targetStatus: | |
type: object | |
description: Configuration of target status reporting. | |
diff --git a/pkg/export/export.go b/pkg/export/export.go | |
index b9475bb41..fe8542084 100644 | |
--- a/pkg/export/export.go | |
+++ b/pkg/export/export.go | |
@@ -522,7 +522,7 @@ const ( | |
ClientName = "prometheus-engine-export" | |
// mainModuleVersion is the version of the main module. Align with git tag. | |
// TODO(TheSpiritXIII): Remove with https://github.com/golang/go/issues/50603 | |
- mainModuleVersion = "v0.7.4-rc.0" | |
+ mainModuleVersion = "v0.8.0-rc.0" | |
// mainModuleName is the name of the main module. Align with go.mod. | |
mainModuleName = "github.com/GoogleCloudPlatform/prometheus-engine" | |
) | |
diff --git a/pkg/operator/apis/monitoring/v1/types.go b/pkg/operator/apis/monitoring/v1/types.go | |
index 4ff32fc6f..169d1cb44 100644 | |
--- a/pkg/operator/apis/monitoring/v1/types.go | |
+++ b/pkg/operator/apis/monitoring/v1/types.go | |
@@ -117,6 +117,16 @@ type CollectionSpec struct { | |
type OperatorFeatures struct { | |
// Configuration of target status reporting. | |
TargetStatus TargetStatusSpec `json:"targetStatus,omitempty"` | |
+ // Settings for the collector configuration propagation. | |
+ Config ConfigSpec `json:"config,omitempty"` | |
+} | |
+ | |
+// ConfigSpec holds configurations for the Prometheus configuration. | |
+type ConfigSpec struct { | |
+ // Compression enables compression of the config data propagated by the operator to collectors. | |
+ // It is recommended to use the gzip option when using a large number of ClusterPodMonitoring | |
+ // and/or PodMonitoring. | |
+ Compression CompressionType `json:"compression,omitempty"` | |
} | |
// TargetStatusSpec holds configuration for target status reporting. | |
@@ -128,6 +138,9 @@ type TargetStatusSpec struct { | |
// +kubebuilder:validation:Enum=none;gzip | |
type CompressionType string | |
+const CompressionNone CompressionType = "none" | |
+const CompressionGzip CompressionType = "gzip" | |
+ | |
// KubeletScraping allows enabling scraping of the Kubelets' metric endpoints. | |
type KubeletScraping struct { | |
// The interval at which the metric endpoints are scraped. | |
diff --git a/pkg/operator/apis/monitoring/v1/zz_generated.deepcopy.go b/pkg/operator/apis/monitoring/v1/zz_generated.deepcopy.go | |
index ee5189a0c..6ca4c5740 100644 | |
--- a/pkg/operator/apis/monitoring/v1/zz_generated.deepcopy.go | |
+++ b/pkg/operator/apis/monitoring/v1/zz_generated.deepcopy.go | |
@@ -282,6 +282,22 @@ func (in *CollectionSpec) DeepCopy() *CollectionSpec { | |
return out | |
} | |
+// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. | |
+func (in *ConfigSpec) DeepCopyInto(out *ConfigSpec) { | |
+ *out = *in | |
+ return | |
+} | |
+ | |
+// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConfigSpec. | |
+func (in *ConfigSpec) DeepCopy() *ConfigSpec { | |
+ if in == nil { | |
+ return nil | |
+ } | |
+ out := new(ConfigSpec) | |
+ in.DeepCopyInto(out) | |
+ return out | |
+} | |
+ | |
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. | |
func (in *ExportFilters) DeepCopyInto(out *ExportFilters) { | |
*out = *in | |
@@ -506,6 +522,7 @@ func (in *OperatorConfigList) DeepCopyObject() runtime.Object { | |
func (in *OperatorFeatures) DeepCopyInto(out *OperatorFeatures) { | |
*out = *in | |
out.TargetStatus = in.TargetStatus | |
+ out.Config = in.Config | |
return | |
} | |
diff --git a/pkg/operator/collection.go b/pkg/operator/collection.go | |
index c1920065c..a4b191f36 100644 | |
--- a/pkg/operator/collection.go | |
+++ b/pkg/operator/collection.go | |
@@ -15,6 +15,8 @@ | |
package operator | |
import ( | |
+ "bytes" | |
+ "compress/gzip" | |
"context" | |
"encoding/json" | |
"fmt" | |
@@ -174,7 +176,7 @@ func (r *collectionReconciler) Reconcile(ctx context.Context, req reconcile.Requ | |
return reconcile.Result{}, fmt.Errorf("ensure collector daemon set: %w", err) | |
} | |
- if err := r.ensureCollectorConfig(ctx, &config.Collection); err != nil { | |
+ if err := r.ensureCollectorConfig(ctx, &config.Collection, config.Features.Config.Compression); err != nil { | |
return reconcile.Result{}, fmt.Errorf("ensure collector config: %w", err) | |
} | |
@@ -255,7 +257,7 @@ func (r *collectionReconciler) ensureCollectorDaemonSet(ctx context.Context, spe | |
flags = append(flags, fmt.Sprintf("--export.credentials-file=%q", p)) | |
} | |
- if len(spec.Compression) > 0 && spec.Compression != "none" { | |
+ if len(spec.Compression) > 0 && spec.Compression != monitoringv1.CompressionNone { | |
flags = append(flags, fmt.Sprintf("--export.compression=%s", spec.Compression)) | |
} | |
@@ -300,8 +302,20 @@ func resolveLabels(opts Options, externalLabels map[string]string) (projectID st | |
return | |
} | |
+func gzipData(data []byte) ([]byte, error) { | |
+ var b bytes.Buffer | |
+ gz := gzip.NewWriter(&b) | |
+ if _, err := gz.Write(data); err != nil { | |
+ return nil, err | |
+ } | |
+ if err := gz.Close(); err != nil { | |
+ return nil, err | |
+ } | |
+ return b.Bytes(), nil | |
+} | |
+ | |
// ensureCollectorConfig generates the collector config and creates or updates it. | |
-func (r *collectionReconciler) ensureCollectorConfig(ctx context.Context, spec *monitoringv1.CollectionSpec) error { | |
+func (r *collectionReconciler) ensureCollectorConfig(ctx context.Context, spec *monitoringv1.CollectionSpec, compression monitoringv1.CompressionType) error { | |
cfg, err := r.makeCollectorConfig(ctx, spec) | |
if err != nil { | |
return fmt.Errorf("generate Prometheus config: %w", err) | |
@@ -316,9 +330,26 @@ func (r *collectionReconciler) ensureCollectorConfig(ctx context.Context, spec * | |
Namespace: r.opts.OperatorNamespace, | |
Name: NameCollector, | |
}, | |
- Data: map[string]string{ | |
+ } | |
+ | |
+ // Thanos config-reloader detects gzip compression automatically, so no sync with | |
+ // config-reloaders is needed when switching between these. | |
+ switch compression { | |
+ case monitoringv1.CompressionGzip: | |
+ compressedCfg, err := gzipData(cfgEncoded) | |
+ if err != nil { | |
+ return fmt.Errorf("gzip Prometheus config: %w", err) | |
+ } | |
+ | |
+ cm.BinaryData = map[string][]byte{ | |
+ configFilename: compressedCfg, | |
+ } | |
+ case "", monitoringv1.CompressionNone: | |
+ cm.Data = map[string]string{ | |
configFilename: string(cfgEncoded), | |
- }, | |
+ } | |
+ default: | |
+ return fmt.Errorf("unknown compression type: %q", compression) | |
} | |
if err := r.client.Update(ctx, cm); apierrors.IsNotFound(err) { | |
diff --git a/pkg/operator/endpoint_status_builder.go b/pkg/operator/endpoint_status_builder.go | |
index 758d15a8e..428d40a1a 100644 | |
--- a/pkg/operator/endpoint_status_builder.go | |
+++ b/pkg/operator/endpoint_status_builder.go | |
@@ -55,7 +55,7 @@ type scrapeEndpointBuilder struct { | |
} | |
func (b *scrapeEndpointBuilder) add(target *prometheusv1.TargetsResult) error { | |
- b.total += 1 | |
+ b.total++ | |
if target != nil { | |
for _, activeTarget := range target.Active { | |
if err := b.addActiveTarget(activeTarget, b.time); err != nil { | |
@@ -63,7 +63,7 @@ func (b *scrapeEndpointBuilder) add(target *prometheusv1.TargetsResult) error { | |
} | |
} | |
} else { | |
- b.failed += 1 | |
+ b.failed++ | |
} | |
return nil | |
} | |
@@ -135,7 +135,7 @@ func newScrapeEndpointStatusBuilder(target *prometheusv1.ActiveTarget, time meta | |
// Adds a sample target, potentially merging with a pre-existing one. | |
func (b *scrapeEndpointStatusBuilder) addSampleTarget(target *prometheusv1.ActiveTarget) { | |
- b.status.ActiveTargets += 1 | |
+ b.status.ActiveTargets++ | |
errorType := target.LastError | |
lastError := &errorType | |
if target.Health == "up" { | |
@@ -143,7 +143,7 @@ func (b *scrapeEndpointStatusBuilder) addSampleTarget(target *prometheusv1.Activ | |
lastError = nil | |
} | |
} else { | |
- b.status.UnhealthyTargets += 1 | |
+ b.status.UnhealthyTargets++ | |
} | |
sampleGroup, ok := b.groupByError[errorType] | |
@@ -160,7 +160,7 @@ func (b *scrapeEndpointStatusBuilder) addSampleTarget(target *prometheusv1.Activ | |
} | |
b.groupByError[errorType] = sampleGroup | |
} | |
- *sampleGroup.Count += 1 | |
+ *sampleGroup.Count++ | |
sampleGroup.SampleTargets = append(sampleGroup.SampleTargets, sampleTarget) | |
} | |
diff --git a/pkg/operator/operator.go b/pkg/operator/operator.go | |
index cbd215169..f8c04ae8b 100644 | |
--- a/pkg/operator/operator.go | |
+++ b/pkg/operator/operator.go | |
@@ -12,6 +12,7 @@ | |
// See the License for the specific language governing permissions and | |
// limitations under the License. | |
+// Package operator contains the Prometheus operator. | |
package operator | |
import ( | |
@@ -19,8 +20,8 @@ import ( | |
"encoding/base64" | |
"errors" | |
"fmt" | |
- "io/ioutil" | |
"net" | |
+ "os" | |
"path/filepath" | |
"strconv" | |
"time" | |
@@ -57,26 +58,29 @@ const ( | |
// configuration data. | |
DefaultPublicNamespace = "gmp-public" | |
- // Fixed names used in various resources managed by the operator. | |
- NameOperator = "gmp-operator" | |
+ // NameOperator is a fixed name used in various resources managed by the operator. | |
+ NameOperator = "gmp-operator" | |
+ // componentName is a fixed name used in various resources managed by the operator. | |
componentName = "managed_prometheus" | |
// Filename for configuration files. | |
configFilename = "config.yaml" | |
- // The well-known app name label. | |
+ // LabelAppName is the well-known app name label. | |
LabelAppName = "app.kubernetes.io/name" | |
- // The component name, will be exposed as metric name. | |
+ // AnnotationMetricName is the component name, will be exposed as metric name. | |
AnnotationMetricName = "components.gke.io/component-name" | |
// ClusterAutoscalerSafeEvictionLabel is the annotation label that determines | |
// whether the cluster autoscaler can safely evict a Pod when the Pod doesn't | |
// satisfy certain eviction criteria. | |
ClusterAutoscalerSafeEvictionLabel = "cluster-autoscaler.kubernetes.io/safe-to-evict" | |
- // The k8s Application, will be exposed as component name. | |
- KubernetesAppName = "app" | |
+ // KubernetesAppName is the k8s Application, will be exposed as component name. | |
+ KubernetesAppName = "app" | |
+ // RuleEvaluatorAppName is the name of the rule-evaluator application. | |
RuleEvaluatorAppName = "managed-prometheus-rule-evaluator" | |
- AlertmanagerAppName = "managed-prometheus-alertmanager" | |
+ // AlertmanagerAppName is the name of the alert manager application. | |
+ AlertmanagerAppName = "managed-prometheus-alertmanager" | |
// The level of concurrency to use to fetch all targets. | |
defaultTargetPollConcurrency = 4 | |
@@ -167,7 +171,7 @@ func New(logger logr.Logger, clientConfig *rest.Config, opts Options) (*Operator | |
return nil, fmt.Errorf("invalid options: %w", err) | |
} | |
// Create temporary directory to store webhook serving cert files. | |
- certDir, err := ioutil.TempDir("", "operator-cert") | |
+ certDir, err := os.MkdirTemp("", "operator-cert") | |
if err != nil { | |
return nil, fmt.Errorf("create temporary certificate dir: %w", err) | |
} | |
@@ -479,13 +483,13 @@ func (o *Operator) ensureCerts(ctx context.Context, dir string) ([]byte, error) | |
// Use crt as the ca in the the self-sign case. | |
caData = crt | |
} else { | |
- return nil, errors.New("Flags key-base64 and cert-base64 must both be set.") | |
+ return nil, errors.New("flags key-base64 and cert-base64 must both be set") | |
} | |
// Create cert/key files. | |
- if err := ioutil.WriteFile(filepath.Join(dir, "tls.crt"), crt, 0666); err != nil { | |
+ if err := os.WriteFile(filepath.Join(dir, "tls.crt"), crt, 0666); err != nil { | |
return nil, fmt.Errorf("create cert file: %w", err) | |
} | |
- if err := ioutil.WriteFile(filepath.Join(dir, "tls.key"), key, 0666); err != nil { | |
+ if err := os.WriteFile(filepath.Join(dir, "tls.key"), key, 0666); err != nil { | |
return nil, fmt.Errorf("create key file: %w", err) | |
} | |
return caData, nil | |
diff --git a/pkg/operator/operator_config.go b/pkg/operator/operator_config.go | |
index 81bcb52d1..71f0568f7 100644 | |
--- a/pkg/operator/operator_config.go | |
+++ b/pkg/operator/operator_config.go | |
@@ -57,6 +57,7 @@ const ( | |
NameAlertmanager = "alertmanager" | |
) | |
+// Secret paths | |
const ( | |
RulesSecretName = "rules" | |
CollectionSecretName = "collection" | |
@@ -615,18 +616,18 @@ func (r *operatorConfigReconciler) makeAlertmanagerConfigs(ctx context.Context, | |
// getSecretOrConfigMapBytes is a helper function to conditionally fetch | |
// the secret or configmap selector payloads. | |
-func getSecretOrConfigMapBytes(ctx context.Context, kClient client.Reader, namespace string, scm *monitoringv1.SecretOrConfigMap) ([]byte, error) { | |
+func getSecretOrConfigMapBytes(ctx context.Context, c client.Reader, namespace string, scm *monitoringv1.SecretOrConfigMap) ([]byte, error) { | |
var ( | |
b []byte | |
err error | |
) | |
if secret := scm.Secret; secret != nil { | |
- b, err = getSecretKeyBytes(ctx, kClient, namespace, secret) | |
+ b, err = getSecretKeyBytes(ctx, c, namespace, secret) | |
if err != nil { | |
return b, err | |
} | |
} else if cm := scm.ConfigMap; cm != nil { | |
- b, err = getConfigMapKeyBytes(ctx, kClient, namespace, cm) | |
+ b, err = getConfigMapKeyBytes(ctx, c, namespace, cm) | |
if err != nil { | |
return b, err | |
} | |
@@ -635,7 +636,7 @@ func getSecretOrConfigMapBytes(ctx context.Context, kClient client.Reader, names | |
} | |
// getSecretKeyBytes processes the given NamespacedSecretKeySelector and returns the referenced data. | |
-func getSecretKeyBytes(ctx context.Context, kClient client.Reader, namespace string, sel *corev1.SecretKeySelector) ([]byte, error) { | |
+func getSecretKeyBytes(ctx context.Context, c client.Reader, namespace string, sel *corev1.SecretKeySelector) ([]byte, error) { | |
var ( | |
secret = &corev1.Secret{} | |
nn = types.NamespacedName{ | |
@@ -644,7 +645,7 @@ func getSecretKeyBytes(ctx context.Context, kClient client.Reader, namespace str | |
} | |
bytes []byte | |
) | |
- err := kClient.Get(ctx, nn, secret) | |
+ err := c.Get(ctx, nn, secret) | |
if err != nil { | |
return bytes, fmt.Errorf("unable to get secret %q: %w", sel.Name, err) | |
} | |
@@ -657,7 +658,7 @@ func getSecretKeyBytes(ctx context.Context, kClient client.Reader, namespace str | |
} | |
// getConfigMapKeyBytes processes the given NamespacedConfigMapKeySelector and returns the referenced data. | |
-func getConfigMapKeyBytes(ctx context.Context, kClient client.Reader, namespace string, sel *corev1.ConfigMapKeySelector) ([]byte, error) { | |
+func getConfigMapKeyBytes(ctx context.Context, c client.Reader, namespace string, sel *corev1.ConfigMapKeySelector) ([]byte, error) { | |
var ( | |
cm = &corev1.ConfigMap{} | |
nn = types.NamespacedName{ | |
@@ -666,7 +667,7 @@ func getConfigMapKeyBytes(ctx context.Context, kClient client.Reader, namespace | |
} | |
b []byte | |
) | |
- err := kClient.Get(ctx, nn, cm) | |
+ err := c.Get(ctx, nn, cm) | |
if err != nil { | |
return b, fmt.Errorf("unable to get secret %q: %w", sel.Name, err) | |
} | |
diff --git a/pkg/operator/target_status.go b/pkg/operator/target_status.go | |
index e391c7f3e..3d49aba66 100644 | |
--- a/pkg/operator/target_status.go | |
+++ b/pkg/operator/target_status.go | |
@@ -53,7 +53,7 @@ var ( | |
}, []string{}) | |
// Minimum duration between polls. | |
- pollDurationMin = 10 * time.Second | |
+ minPollDuration = 10 * time.Second | |
) | |
// Responsible for fetching the targets given a pod. | |
@@ -154,7 +154,7 @@ func shouldPoll(ctx context.Context, cfgNamespacedName types.NamespacedName, kub | |
// Reconcile polls the collector pods, fetches and aggregates target status and | |
// upserts into each PodMonitoring's Status field. | |
func (r *targetStatusReconciler) Reconcile(ctx context.Context, request reconcile.Request) (reconcile.Result, error) { | |
- timer := r.clock.NewTimer(pollDurationMin) | |
+ timer := r.clock.NewTimer(minPollDuration) | |
now := time.Now() | |
@@ -403,9 +403,9 @@ func getTarget(ctx context.Context, logger logr.Logger, port int32, pod *corev1. | |
if pod.Status.PodIP == "" { | |
return nil, errors.New("pod does not have IP allocated") | |
} | |
- podUrl := fmt.Sprintf("http://%s:%d", pod.Status.PodIP, port) | |
+ podURL := fmt.Sprintf("http://%s:%d", pod.Status.PodIP, port) | |
client, err := api.NewClient(api.Config{ | |
- Address: podUrl, | |
+ Address: podURL, | |
}) | |
if err != nil { | |
return nil, fmt.Errorf("unable to create Prometheus client: %w", err) | |
diff --git a/pkg/ui/ui.go b/pkg/ui/ui.go | |
index 530f32584..c3d7fd8ec 100644 | |
--- a/pkg/ui/ui.go | |
+++ b/pkg/ui/ui.go | |
@@ -17,7 +17,7 @@ package ui | |
import ( | |
"bytes" | |
"fmt" | |
- "io/ioutil" | |
+ "io" | |
"net/http" | |
"net/url" | |
"path" | |
@@ -48,7 +48,7 @@ func Handler(externalURL *url.URL) http.Handler { | |
fmt.Fprintf(w, "Error opening React index.html: %v", err) | |
return | |
} | |
- idx, err := ioutil.ReadAll(f) | |
+ idx, err := io.ReadAll(f) | |
if err != nil { | |
w.WriteHeader(http.StatusInternalServerError) | |
fmt.Fprintf(w, "Error reading React index.html: %v", err) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment