diff --git a/pkg/cmd/start/receiver.go b/pkg/cmd/start/receiver.go index 36538fd13..88478a480 100644 --- a/pkg/cmd/start/receiver.go +++ b/pkg/cmd/start/receiver.go @@ -20,7 +20,7 @@ func NewReceiver() *cobra.Command { Use: "start-receiver", Short: "Start a listener that accepts and logs uploaded content", RunE: func(cmd *cobra.Command, args []string) error { - return http.ListenAndServe(listen, http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { + return http.ListenAndServe(listen, http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { // nolint: gosec klog.Infof("Handling %s", req.URL.Path) contentType := req.Header.Get("Content-Type") if len(contentType) == 0 { diff --git a/pkg/gatherers/clusterconfig/dvo_metrics.go b/pkg/gatherers/clusterconfig/dvo_metrics.go index e056f29f5..d13b8b1b8 100644 --- a/pkg/gatherers/clusterconfig/dvo_metrics.go +++ b/pkg/gatherers/clusterconfig/dvo_metrics.go @@ -7,7 +7,6 @@ import ( "io" "net/http" "net/url" - "regexp" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes" @@ -21,15 +20,11 @@ import ( "github.com/openshift/insights-operator/pkg/utils/marshal" ) -const ( - dvoNamespace = "deployment-validation-operator" -) - var ( - // Only services with the word "metrics" in their name should be considered. - dvoMetricsServiceNameRegex = regexp.MustCompile(`\bmetrics\b`) // Only metrics with the DVO prefix should be gathered. dvoMetricsPrefix = []byte("deployment_validation_operator_") + // label selector used for searching the required service + serviceLabelSelector = "name=deployment-validation-operator" ) // GatherDVOMetrics collects metrics from the Deployment Validation Operator's @@ -55,7 +50,9 @@ func gatherDVOMetrics( coreClient corev1client.CoreV1Interface, rateLimiter flowcontrol.RateLimiter, ) ([]record.Record, []error) { - serviceList, err := coreClient.Services(dvoNamespace).List(ctx, metav1.ListOptions{}) + serviceList, err := coreClient.Services("").List(ctx, metav1.ListOptions{ + LabelSelector: serviceLabelSelector, + }) if err != nil { return nil, []error{err} } @@ -65,13 +62,10 @@ func gatherDVOMetrics( for svcIdx := range serviceList.Items { // Use pointer to make gocritic happy and avoid copying the whole Service struct. service := &serviceList.Items[svcIdx] - if !dvoMetricsServiceNameRegex.MatchString(service.Name) { - continue - } for _, port := range service.Spec.Ports { apiURL := url.URL{ Scheme: "http", - Host: fmt.Sprintf("%s.%s.svc:%d", service.Name, dvoNamespace, port.Port), + Host: fmt.Sprintf("%s.%s.svc:%d", service.Name, service.Namespace, port.Port), } prefixedLines, err := gatherDVOMetricsFromEndpoint(ctx, &apiURL, rateLimiter) diff --git a/pkg/recorder/diskrecorder/diskrecorder.go b/pkg/recorder/diskrecorder/diskrecorder.go index c64bfb2ac..6109aa0aa 100644 --- a/pkg/recorder/diskrecorder/diskrecorder.go +++ b/pkg/recorder/diskrecorder/diskrecorder.go @@ -158,7 +158,7 @@ func (d *DiskRecorder) Summary(_ context.Context, since time.Time) (*insightscli if isNotArchiveFile(fileInfo) { continue } - if !fileInfo.ModTime().After(since) { + if fileInfo.ModTime().Before(since) { continue } recentFiles = append(recentFiles, file.Name())