From 6b32f7b48ab23ee2444616663e1d580571a9d42c Mon Sep 17 00:00:00 2001 From: Robert Fratto Date: Thu, 11 Jan 2024 12:00:23 -0500 Subject: [PATCH] misc: remove more unused code for smoke and crow (#6121) Follow up on #6118, I missed some extra bits of smoke/crow-related code. --- .../agent-static-mixin/alerts.libsonnet | 136 +------ pkg/crow/crow.go | 362 ------------------ pkg/crow/metrics.go | 62 --- pkg/crow/samples.go | 85 ---- pkg/crow/samples_test.go | 101 ----- tools/ci/docker-containers | 26 +- 6 files changed, 6 insertions(+), 766 deletions(-) delete mode 100644 pkg/crow/crow.go delete mode 100644 pkg/crow/metrics.go delete mode 100644 pkg/crow/samples.go delete mode 100644 pkg/crow/samples_test.go diff --git a/operations/agent-static-mixin/alerts.libsonnet b/operations/agent-static-mixin/alerts.libsonnet index 51fe81e0e539..653be89ce471 100644 --- a/operations/agent-static-mixin/alerts.libsonnet +++ b/operations/agent-static-mixin/alerts.libsonnet @@ -65,132 +65,6 @@ local _config = config._config; }, ], }, - { - name: 'GrafanaAgentSmokeChecks', - rules: [ - { - alert: 'GrafanaAgentDown', - expr: ||| - up{ - namespace="agent-smoke-test", - pod=~"grafana-agent-smoke-test-(0|cluster-0|cluster-1|cluster-2)", - } == 0 - |||, - 'for': '5m', - annotations: { - summary: '{{ $labels.job }} is down', - }, - }, - { - alert: 'GrafanaAgentFlapping', - expr: ||| - avg_over_time(up{ - namespace="agent-smoke-test", - pod=~"grafana-agent-smoke-test-(0|cluster-0|cluster-1|cluster-2)", - }[5m]) < 1 - |||, - 'for': '15m', - annotations: { - summary: '{{ $labels.job }} is flapping', - }, - }, - - // Checks that the CPU usage doesn't go too high. This was generated from internal usage where - // every 1,000 active series used roughly 0.0013441% of CPU. This alert only fires if there is a - // minimum load threshold of at least 1000 active series. - { - alert: 'GrafanaAgentCPUHigh', - expr: ||| - (sum by (pod) (rate(container_cpu_usage_seconds_total{cluster=~".+", namespace=~"agent-smoke-test", container=~".+", pod="grafana-agent-smoke-test-cluster-2"}[5m])) - / - (sum by (pod) (agent_wal_storage_active_series{cluster=~".+", namespace=~"agent-smoke-test", container=~".+", pod="grafana-agent-smoke-test-cluster-2"}) / 1000) - > 0.0013441) - and - sum by (pod) (agent_wal_storage_active_series{cluster=~".+", namespace=~"agent-smoke-test", container=~".+", pod="grafana-agent-smoke-test-cluster-2"}) > 1000 - |||, - 'for': '1h', - annotations: { - summary: '{{ $labels.pod }} is using more than 0.0013441 CPU per 1000 series over the last 5 minutes', - }, - }, - - // We assume roughly ~8KB per series. Check that each deployment - // doesn't go too far above this. - // - // We aggregate the memory of the scraping service together since an individual - // node with a really small number of active series will throw this metric off. - { - alert: 'GrafanaAgentMemHigh', - expr: ||| - sum without (pod, instance) (go_memstats_heap_inuse_bytes{job=~"agent-smoke-test/grafana-agent-smoke-test.*"}) / - sum without (pod, instance, instance_group_name) (agent_wal_storage_active_series{job=~"agent-smoke-test/grafana-agent-smoke-test.*"}) / 1e3 > 10 - |||, - 'for': '1h', - annotations: { - summary: '{{ $labels.job }} has used more than 10KB per series for more than 5 minutes', - }, - }, - { - alert: 'GrafanaAgentContainerRestarts', - expr: ||| - sum by (pod) (rate(kube_pod_container_status_restarts_total{namespace="agent-smoke-test"}[10m])) > 0 - |||, - annotations: { - summary: '{{ $labels.pod }} has a high rate of container restarts', - }, - }, - ], - }, - { - name: 'GrafanaAgentCrowChecks', - rules: [ - { - alert: 'CrowDown', - expr: ||| - up{job=~"agent-smoke-test/crow-.*"} == 0 - |||, - 'for': '5m', - annotations: { - summary: 'Crow {{ $labels.job }} is down.', - }, - }, - { - alert: 'CrowFlapping', - expr: ||| - avg_over_time(up{job=~"agent-smoke-test/crow-.*"}[5m]) < 1 - |||, - 'for': '15m', - annotations: { - summary: 'Crow {{ $labels.job }} is flapping.', - }, - }, - { - alert: 'CrowNotScraped', - expr: ||| - rate(crow_test_samples_total[5m]) == 0 - |||, - 'for': '15m', - annotations: { - summary: 'Crow {{ $labels.job }} is not being scraped.', - }, - }, - { - alert: 'CrowFailures', - expr: ||| - ( - rate(crow_test_sample_results_total{result="success"}[5m]) - / - ignoring(result) sum without (result) (rate(crow_test_sample_results_total[5m])) - ) - < 1 - |||, - 'for': '15m', - annotations: { - summary: 'Crow {{ $labels.job }} has had failures for at least 5m', - }, - }, - ], - }, { name: 'VultureChecks', rules: [ @@ -358,7 +232,7 @@ local _config = config._config; }, annotations: { message: ||| - Instance {{ $labels.instance }} failed to successfully reload the config. + Instance {{ $labels.instance }} failed to successfully reload the config. |||, }, }, @@ -373,7 +247,7 @@ local _config = config._config; }, annotations: { message: ||| - Instance {{ $labels.instance }} failed to successfully reload the config. + Instance {{ $labels.instance }} failed to successfully reload the config. |||, }, }, @@ -388,7 +262,7 @@ local _config = config._config; }, annotations: { message: ||| - Instance {{ $labels.instance }} fell back to empty configuration. + Instance {{ $labels.instance }} fell back to empty configuration. |||, }, }, @@ -403,12 +277,12 @@ local _config = config._config; }, annotations: { message: ||| - Instance {{ $labels.instance }} fell back to empty configuration. + Instance {{ $labels.instance }} fell back to empty configuration. |||, }, }, ], - }, + }, ], }, } diff --git a/pkg/crow/crow.go b/pkg/crow/crow.go deleted file mode 100644 index 236a53b133cd..000000000000 --- a/pkg/crow/crow.go +++ /dev/null @@ -1,362 +0,0 @@ -// Package crow implements a correctness checker tool similar to Loki Canary. -// Inspired by Cortex test-exporter. -package crow - -import ( - "context" - "errors" - "flag" - "fmt" - "math" - "math/rand" - "net/http" - "strings" - "sync" - "time" - - "github.com/go-kit/log" - "github.com/go-kit/log/level" - "github.com/grafana/dskit/user" - "github.com/opentracing-contrib/go-stdlib/nethttp" - "github.com/prometheus/client_golang/api" - promapi "github.com/prometheus/client_golang/api/prometheus/v1" - "github.com/prometheus/client_golang/prometheus" - "github.com/prometheus/client_golang/prometheus/promhttp" - commonCfg "github.com/prometheus/common/config" - "github.com/prometheus/common/model" -) - -// Config for the Crow metrics checker. -type Config struct { - PrometheusAddr string // Base URL of Prometheus server - NumSamples int // Number of samples to generate - UserID string // User ID to use for auth when querying. - PasswordFile string // Password File for auth when querying. - ExtraSelectors string // Extra selectors for queries, i.e., cluster="prod" - OrgID string // Org ID to inject in X-Org-ScopeID header when querying. - - // Querying Params - - QueryTimeout time.Duration // Timeout for querying - QueryDuration time.Duration // Time before and after sample to search - QueryStep time.Duration // Step between samples in search - - // Validation Params - - MaxValidations int // Maximum amount of times to search for a sample - MaxTimestampDelta time.Duration // Maximum timestamp delta to use for validating. - ValueEpsilon float64 // Maximum epsilon to use for validating. - - // Logger to use. If nil, logs will be discarded. - Log log.Logger -} - -// RegisterFlags registers flags for the config to the given FlagSet. -func (c *Config) RegisterFlags(f *flag.FlagSet) { - c.RegisterFlagsWithPrefix(f, "") -} - -// RegisterFlagsWithPrefix registers flags for the config to the given FlagSet and -// prefixing each flag with the given prefix. prefix, if non-empty, should end -// in `.`. -func (c *Config) RegisterFlagsWithPrefix(f *flag.FlagSet, prefix string) { - f.StringVar(&c.PrometheusAddr, prefix+"prometheus-addr", DefaultConfig.PrometheusAddr, "Root URL of the Prometheus API to query against") - f.IntVar(&c.NumSamples, prefix+"generate-samples", DefaultConfig.NumSamples, "Number of samples to generate when being scraped") - f.StringVar(&c.UserID, prefix+"user-id", DefaultConfig.UserID, "UserID to use with basic auth.") - f.StringVar(&c.PasswordFile, prefix+"password-file", DefaultConfig.PasswordFile, "Password file to use with basic auth.") - f.StringVar(&c.ExtraSelectors, prefix+"extra-selectors", DefaultConfig.ExtraSelectors, "Extra selectors to include in queries, useful for identifying different instances of this job.") - f.StringVar(&c.OrgID, prefix+"org-id", DefaultConfig.OrgID, "Org ID to inject in X-Org-ScopeID header when querying. Useful for querying multi-tenated Cortex directly.") - - f.DurationVar(&c.QueryTimeout, prefix+"query-timeout", DefaultConfig.QueryTimeout, "timeout for querying") - f.DurationVar(&c.QueryDuration, prefix+"query-duration", DefaultConfig.QueryDuration, "time before and after sample to search") - f.DurationVar(&c.QueryStep, prefix+"query-step", DefaultConfig.QueryStep, "step between samples when searching") - - f.IntVar(&c.MaxValidations, prefix+"max-validations", DefaultConfig.MaxValidations, "Maximum number of times to try validating a sample") - f.DurationVar(&c.MaxTimestampDelta, prefix+"max-timestamp-delta", DefaultConfig.MaxTimestampDelta, "maximum difference from the stored timestamp from the validating sample to allow") - f.Float64Var(&c.ValueEpsilon, prefix+"sample-epsilon", DefaultConfig.ValueEpsilon, "maximum difference from the stored value from the validating sample to allow") -} - -// DefaultConfig holds defaults for Crow settings. -var DefaultConfig = Config{ - MaxValidations: 5, - NumSamples: 10, - - QueryTimeout: 150 * time.Millisecond, - QueryDuration: 2 * time.Second, - QueryStep: 100 * time.Millisecond, - - // MaxTimestampDelta is set to 750ms to allow some buffer for a slow network - // before the scrape goes through. - MaxTimestampDelta: 750 * time.Millisecond, - ValueEpsilon: 0.0001, -} - -// Crow is a correctness checker that validates scraped metrics reach a -// Prometheus-compatible server with the same values and roughly the same -// timestamp. -// -// Crow exposes two sets of metrics: -// -// 1. Test metrics, where each scrape generates a validation job. -// 2. State metrics, exposing state of the Crow checker itself. -// -// These two metrics should be exposed via different endpoints, and only state -// metrics are safe to be manually collected from. -// -// Collecting from the set of test metrics generates a validation job, where -// Crow will query the Prometheus API to ensure the metrics that were scraped -// were written with (approximately) the same timestamp as the scrape time -// and with (approximately) the same floating point values exposed in the -// scrape. -// -// If a set of test metrics were not found and retries have been exhausted, -// or if the metrics were found but the values did not match, the error -// counter will increase. -type Crow struct { - cfg Config - m *metrics - - promClient promapi.API - - wg sync.WaitGroup - quit chan struct{} - - pendingMtx sync.Mutex - pending []*sample - sampleCh chan []*sample -} - -// New creates a new Crow. -func New(cfg Config) (*Crow, error) { - c, err := newCrow(cfg) - if err != nil { - return nil, err - } - - c.wg.Add(1) - go c.runLoop() - return c, nil -} - -func newCrow(cfg Config) (*Crow, error) { - if cfg.Log == nil { - cfg.Log = log.NewNopLogger() - } - - if cfg.PrometheusAddr == "" { - return nil, fmt.Errorf("Crow must be configured with a URL to use for querying Prometheus") - } - - apiCfg := api.Config{ - Address: cfg.PrometheusAddr, - RoundTripper: api.DefaultRoundTripper, - } - if cfg.UserID != "" && cfg.PasswordFile != "" { - apiCfg.RoundTripper = commonCfg.NewBasicAuthRoundTripper(cfg.UserID, "", "", cfg.PasswordFile, api.DefaultRoundTripper) - } - if cfg.OrgID != "" { - apiCfg.RoundTripper = &nethttp.Transport{ - RoundTripper: promhttp.RoundTripperFunc(func(req *http.Request) (*http.Response, error) { - _ = user.InjectOrgIDIntoHTTPRequest(user.InjectOrgID(context.Background(), cfg.OrgID), req) - return apiCfg.RoundTripper.RoundTrip(req) - }), - } - } - - cli, err := api.NewClient(apiCfg) - if err != nil { - return nil, fmt.Errorf("failed to create prometheus client: %w", err) - } - - c := &Crow{ - cfg: cfg, - m: newMetrics(), - promClient: promapi.NewAPI(cli), - - quit: make(chan struct{}), - - sampleCh: make(chan []*sample), - } - return c, nil -} - -func (c *Crow) runLoop() { - defer c.wg.Done() - - ticker := time.NewTicker(250 * time.Millisecond) - defer ticker.Stop() - - for { - select { - case <-c.quit: - return - case samples := <-c.sampleCh: - c.m.totalScrapes.Inc() - c.m.totalSamples.Add(float64(len(samples))) - - c.appendSamples(samples) - case <-ticker.C: - c.checkPending() - } - } -} - -// appendSamples queues samples to be checked. -func (c *Crow) appendSamples(samples []*sample) { - c.pendingMtx.Lock() - defer c.pendingMtx.Unlock() - c.pending = append(c.pending, samples...) - c.m.pendingSets.Set(float64(len(c.pending))) -} - -// checkPending iterates over all pending samples. Samples that are ready -// are immediately validated. Samples are requeued if they're not ready or -// not found during validation. -func (c *Crow) checkPending() { - c.pendingMtx.Lock() - defer c.pendingMtx.Unlock() - - now := time.Now().UTC() - - requeued := []*sample{} - for _, s := range c.pending { - if !s.Ready(now) { - requeued = append(requeued, s) - continue - } - - err := c.validate(s) - if err == nil { - c.m.totalResults.WithLabelValues("success").Inc() - continue - } - - s.ValidationAttempt++ - if s.ValidationAttempt < c.cfg.MaxValidations { - requeued = append(requeued, s) - continue - } - - var vf errValidationFailed - if errors.As(err, &vf) { - switch { - case vf.mismatch: - c.m.totalResults.WithLabelValues("mismatch").Inc() - case vf.missing: - c.m.totalResults.WithLabelValues("missing").Inc() - default: - c.m.totalResults.WithLabelValues("unknown").Inc() - } - } - } - c.pending = requeued - c.m.pendingSets.Set(float64(len(c.pending))) -} - -type errValidationFailed struct { - missing bool - mismatch bool -} - -func (e errValidationFailed) Error() string { - switch { - case e.missing: - return "validation failed: sample missing" - case e.mismatch: - return "validation failed: sample does not match" - default: - return "validation failed" - } -} - -// validate validates a sample. If the sample should be requeued (i.e., -// couldn't be found), returns true. -func (c *Crow) validate(b *sample) error { - ctx, cancel := context.WithTimeout(context.Background(), c.cfg.QueryTimeout) - defer cancel() - - labels := make([]string, 0, len(b.Labels)) - for k, v := range b.Labels { - labels = append(labels, fmt.Sprintf(`%s="%s"`, k, v)) - } - if c.cfg.ExtraSelectors != "" { - labels = append(labels, c.cfg.ExtraSelectors) - } - - query := fmt.Sprintf("%s{%s}", validationSampleName, strings.Join(labels, ",")) - level.Debug(c.cfg.Log).Log("msg", "querying for sample", "query", query) - - val, _, err := c.promClient.QueryRange(ctx, query, promapi.Range{ - Start: b.ScrapeTime.UTC().Add(-c.cfg.QueryDuration), - End: b.ScrapeTime.UTC().Add(+c.cfg.QueryDuration), - Step: c.cfg.QueryStep, - }) - - if err != nil { - level.Error(c.cfg.Log).Log("msg", "failed to query for sample", "query", query, "err", err) - } else if m, ok := val.(model.Matrix); ok { - return c.validateInMatrix(query, b, m) - } - - return errValidationFailed{missing: true} -} - -func (c *Crow) validateInMatrix(query string, b *sample, m model.Matrix) error { - var found, matches bool - - for _, ss := range m { - for _, sp := range ss.Values { - ts := time.Unix(0, sp.Timestamp.UnixNano()) - dist := b.ScrapeTime.Sub(ts) - if dist < 0 { - dist = -dist - } - - if dist <= c.cfg.MaxTimestampDelta { - found = true - matches = math.Abs(float64(sp.Value)-b.Value) <= c.cfg.ValueEpsilon - } - - level.Debug(c.cfg.Log).Log( - "msg", "compared query to stored sample", - "query", query, - "sample", ss.Metric, - "ts", sp.Timestamp, "expect_ts", b.ScrapeTime, - "value", sp.Value, "expect_value", b.Value, - ) - - if found && matches { - break - } - } - } - - if !found || !matches { - return errValidationFailed{ - missing: !found, - mismatch: found && !matches, - } - } - return nil -} - -// TestMetrics exposes a collector of test metrics. Each collection will -// schedule a validation job. -func (c *Crow) TestMetrics() prometheus.Collector { - return &sampleGenerator{ - numSamples: c.cfg.NumSamples, - sendCh: c.sampleCh, - - r: rand.New(rand.NewSource(time.Now().Unix())), - } -} - -// StateMetrics exposes metrics of Crow itself. These metrics are not validated -// for presence in the remote system. -func (c *Crow) StateMetrics() prometheus.Collector { return c.m } - -// Stop stops crow. Panics if Stop is called more than once. -func (c *Crow) Stop() { - close(c.quit) - c.wg.Wait() -} diff --git a/pkg/crow/metrics.go b/pkg/crow/metrics.go deleted file mode 100644 index 6550cc74c596..000000000000 --- a/pkg/crow/metrics.go +++ /dev/null @@ -1,62 +0,0 @@ -package crow - -import "github.com/prometheus/client_golang/prometheus" - -type metrics struct { - totalScrapes prometheus.Counter - totalSamples prometheus.Counter - totalResults *prometheus.CounterVec - pendingSets prometheus.Gauge - - cachedCollectors []prometheus.Collector -} - -func newMetrics() *metrics { - var m metrics - - m.totalScrapes = prometheus.NewCounter(prometheus.CounterOpts{ - Name: "crow_test_scrapes_total", - Help: "Total number of generated test sample sets", - }) - - m.totalSamples = prometheus.NewCounter(prometheus.CounterOpts{ - Name: "crow_test_samples_total", - Help: "Total number of generated test samples", - }) - - m.totalResults = prometheus.NewCounterVec(prometheus.CounterOpts{ - Name: "crow_test_sample_results_total", - Help: "Total validation results of test samples", - }, []string{"result"}) // result is either "success", "missing", "mismatch", or "unknown" - - m.pendingSets = prometheus.NewGauge(prometheus.GaugeOpts{ - Name: "crow_test_pending_validations", - Help: "Total number of pending validations to perform", - }) - - return &m -} - -func (m *metrics) collectors() []prometheus.Collector { - if m.cachedCollectors == nil { - m.cachedCollectors = []prometheus.Collector{ - m.totalScrapes, - m.totalSamples, - m.totalResults, - m.pendingSets, - } - } - return m.cachedCollectors -} - -func (m *metrics) Describe(ch chan<- *prometheus.Desc) { - for _, c := range m.collectors() { - c.Describe(ch) - } -} - -func (m *metrics) Collect(ch chan<- prometheus.Metric) { - for _, c := range m.collectors() { - c.Collect(ch) - } -} diff --git a/pkg/crow/samples.go b/pkg/crow/samples.go deleted file mode 100644 index 066b21008af4..000000000000 --- a/pkg/crow/samples.go +++ /dev/null @@ -1,85 +0,0 @@ -package crow - -import ( - "fmt" - "math/rand" - "time" - - "github.com/prometheus/client_golang/prometheus" -) - -type sample struct { - ScrapeTime time.Time - Labels prometheus.Labels - Value float64 - - // How many times this sample has attempted to be validated. Starts at 0. - ValidationAttempt int -} - -// Ready checks if this sample is ready to be validated. -func (s *sample) Ready(now time.Time) bool { - backoff := sampleBackoff(s.ValidationAttempt) - return now.After(s.ScrapeTime.Add(backoff)) -} - -func sampleBackoff(attempt int) time.Duration { - // Exponential backoff from 1s up to 1s + (250ms * 2^attempt). - return time.Second + (250 * time.Millisecond * 1 << attempt) -} - -type sampleGenerator struct { - numSamples int - sendCh chan<- []*sample - r *rand.Rand -} - -const validationSampleName = "crow_validation_sample" - -func (sg *sampleGenerator) Describe(ch chan<- *prometheus.Desc) { - ch <- prometheus.NewDesc( - validationSampleName, "Sample to validate", - []string{"sample_num"}, - prometheus.Labels{}, - ) -} - -func (sg *sampleGenerator) Collect(ch chan<- prometheus.Metric) { - var ( - scrapeTime = time.Now() - - sampleLabel = "sample_num" - desc = prometheus.NewDesc( - validationSampleName, "Sample to validate", - []string{sampleLabel}, - prometheus.Labels{}, - ) - - usedLabels = map[string]struct{}{} - samples = make([]*sample, sg.numSamples) - ) - - for s := 0; s < sg.numSamples; s++ { - GenLabel: - labelSuffix := make([]byte, 1) - _, _ = sg.r.Read(labelSuffix) - label := fmt.Sprintf("sample_%x", labelSuffix) - if _, exist := usedLabels[label]; exist { - goto GenLabel - } - usedLabels[label] = struct{}{} - - samples[s] = &sample{ - ScrapeTime: scrapeTime, - Labels: prometheus.Labels{sampleLabel: label}, - Value: float64(sg.r.Int63n(1_000_000)), - } - ch <- prometheus.MustNewConstMetric( - desc, - prometheus.GaugeValue, - samples[s].Value, samples[s].Labels[sampleLabel], - ) - } - - sg.sendCh <- samples -} diff --git a/pkg/crow/samples_test.go b/pkg/crow/samples_test.go deleted file mode 100644 index 523c4c2a8cda..000000000000 --- a/pkg/crow/samples_test.go +++ /dev/null @@ -1,101 +0,0 @@ -package crow - -import ( - "fmt" - "math/rand" - "strings" - "testing" - "time" - - "github.com/prometheus/client_golang/prometheus" - "github.com/prometheus/common/expfmt" - "github.com/stretchr/testify/require" -) - -func Test_sample_Ready(t *testing.T) { - tt := []struct { - sample sample - now time.Time - expect bool - }{ - { - sample: sample{ - ScrapeTime: time.Unix(100, 0).UTC(), - ValidationAttempt: 0, - }, - now: time.Unix(100, 0).UTC(), - expect: false, - }, - { - sample: sample{ - ScrapeTime: time.Unix(100, 0).UTC(), - ValidationAttempt: 0, - }, - now: time.Unix(500, 0).UTC(), - expect: true, - }, - } - - for _, tc := range tt { - ready := tc.sample.Ready(tc.now) - require.Equal(t, tc.expect, ready) - } -} - -func Test_sampleBackoff(t *testing.T) { - tt := []struct { - attempt int - expect time.Duration - }{ - {attempt: 0, expect: 1250 * time.Millisecond}, - {attempt: 1, expect: 1500 * time.Millisecond}, - {attempt: 2, expect: 2000 * time.Millisecond}, - {attempt: 3, expect: 3000 * time.Millisecond}, - {attempt: 4, expect: 5000 * time.Millisecond}, - {attempt: 5, expect: 9000 * time.Millisecond}, - } - - for _, tc := range tt { - t.Run(fmt.Sprintf("%d", tc.attempt), func(t *testing.T) { - actual := sampleBackoff(tc.attempt) - require.Equal(t, tc.expect, actual) - }) - } -} - -func Test_sampleGenerator(t *testing.T) { - var ( - reg = prometheus.NewRegistry() - ) - - gen := sampleGenerator{ - numSamples: 10, - sendCh: make(chan<- []*sample, 10), - r: rand.New(rand.NewSource(0)), - } - reg.MustRegister(&gen) - - mfs, err := reg.Gather() - require.NoError(t, err) - - var sb strings.Builder - enc := expfmt.NewEncoder(&sb, expfmt.FmtText) - for _, mf := range mfs { - require.NoError(t, enc.Encode(mf)) - } - - expect := `# HELP crow_validation_sample Sample to validate -# TYPE crow_validation_sample gauge -crow_validation_sample{sample_num="sample_01"} 393152 -crow_validation_sample{sample_num="sample_14"} 943416 -crow_validation_sample{sample_num="sample_2f"} 980153 -crow_validation_sample{sample_num="sample_51"} 637646 -crow_validation_sample{sample_num="sample_55"} 976708 -crow_validation_sample{sample_num="sample_94"} 995827 -crow_validation_sample{sample_num="sample_c2"} 376202 -crow_validation_sample{sample_num="sample_fa"} 126063 -crow_validation_sample{sample_num="sample_fc"} 422456 -crow_validation_sample{sample_num="sample_fd"} 197794 -` - require.Equal(t, expect, sb.String()) -} diff --git a/tools/ci/docker-containers b/tools/ci/docker-containers index f42c6211415a..ee01a0905137 100755 --- a/tools/ci/docker-containers +++ b/tools/ci/docker-containers @@ -21,8 +21,6 @@ export AGENT_IMAGE=grafana/agent export AGENT_BORINGCRYPTO_IMAGE=grafana/agent-boringcrypto export AGENTCTL_IMAGE=grafana/agentctl export OPERATOR_IMAGE=grafana/agent-operator -export SMOKE_IMAGE=us.gcr.io/kubernetes-dev/grafana/agent-smoke -export CROW_IMAGE=us.gcr.io/kubernetes-dev/grafana/agent-crow # We need to determine what version to assign to built binaries. If containers # are being built from a Drone tag trigger, we force the version to come from the @@ -106,30 +104,8 @@ case "$TARGET_CONTAINER" in . ;; - smoke) - docker buildx build --push \ - --platform $BUILD_PLATFORMS \ - --build-arg RELEASE_BUILD=1 \ - --build-arg VERSION="$VERSION" \ - -t "$SMOKE_IMAGE:$VERSION" \ - -t "$SMOKE_IMAGE:$BRANCH_TAG" \ - -f tools/smoke/Dockerfile \ - . - ;; - - crow) - docker buildx build --push \ - --platform $BUILD_PLATFORMS \ - --build-arg RELEASE_BUILD=1 \ - --build-arg VERSION="$VERSION" \ - -t "$CROW_IMAGE:$VERSION" \ - -t "$CROW_IMAGE:$BRANCH_TAG" \ - -f tools/crow/Dockerfile \ - . - ;; - *) - echo "Usage: $0 agent|agent-boringcrypto|agentctl|agent-operator|smoke|crow" + echo "Usage: $0 agent|agent-boringcrypto|agentctl|agent-operator" exit 1 ;; esac