Skip to content

Commit

Permalink
Feature stability gating on a component level (#6523)
Browse files Browse the repository at this point in the history
* Feature stability gating on a component level

* Mark the beta/experimental components as such

* fix existing tests

* tests

* changelog

* fixes

* feedback
  • Loading branch information
thampiotr authored Feb 27, 2024
1 parent 1a18b61 commit ad580f5
Show file tree
Hide file tree
Showing 172 changed files with 1,108 additions and 527 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ internal API changes are not present.
Main (unreleased)
-----------------

### Features

- Added a new CLI flag `--stability.level` which defines the minimum stability
level required for the features that the agent is allowed to use. Default is `experimental`. (@thampiotr)


v0.40.0 (2024-02-27)
--------------------
Expand Down
26 changes: 19 additions & 7 deletions cmd/internal/flowmode/cmd_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/grafana/agent/converter"
convert_diag "github.com/grafana/agent/converter/diag"
"github.com/grafana/agent/internal/agentseed"
"github.com/grafana/agent/internal/featuregate"
"github.com/grafana/agent/pkg/boringcrypto"
"github.com/grafana/agent/pkg/config/instrumentation"
"github.com/grafana/agent/pkg/flow"
Expand Down Expand Up @@ -51,6 +52,7 @@ func runCommand() *cobra.Command {
inMemoryAddr: "agent.internal:12345",
httpListenAddr: "127.0.0.1:12345",
storagePath: "data-agent/",
minStability: featuregate.StabilityExperimental,
uiPrefix: "/",
disableReporting: false,
enablePprof: true,
Expand Down Expand Up @@ -97,13 +99,15 @@ depending on the nature of the reload error.
},
}

// Server flags
cmd.Flags().
StringVar(&r.httpListenAddr, "server.http.listen-addr", r.httpListenAddr, "Address to listen for HTTP traffic on")
cmd.Flags().StringVar(&r.inMemoryAddr, "server.http.memory-addr", r.inMemoryAddr, "Address to listen for in-memory HTTP traffic on. Change if it collides with a real address")
cmd.Flags().StringVar(&r.storagePath, "storage.path", r.storagePath, "Base directory where components can store data")
cmd.Flags().StringVar(&r.uiPrefix, "server.http.ui-path-prefix", r.uiPrefix, "Prefix to serve the HTTP UI at")
cmd.Flags().
BoolVar(&r.enablePprof, "server.http.enable-pprof", r.enablePprof, "Enable /debug/pprof profiling endpoints.")

// Cluster flags
cmd.Flags().
BoolVar(&r.clusterEnabled, "cluster.enabled", r.clusterEnabled, "Start in clustered mode")
cmd.Flags().
Expand All @@ -122,18 +126,25 @@ depending on the nature of the reload error.
IntVar(&r.ClusterMaxJoinPeers, "cluster.max-join-peers", r.ClusterMaxJoinPeers, "Number of peers to join from the discovered set")
cmd.Flags().
StringVar(&r.clusterName, "cluster.name", r.clusterName, "The name of the cluster to join")
cmd.Flags().
BoolVar(&r.disableReporting, "disable-reporting", r.disableReporting, "Disable reporting of enabled components to Grafana.")

// Config flags
cmd.Flags().StringVar(&r.configFormat, "config.format", r.configFormat, fmt.Sprintf("The format of the source file. Supported formats: %s.", supportedFormatsList()))
cmd.Flags().BoolVar(&r.configBypassConversionErrors, "config.bypass-conversion-errors", r.configBypassConversionErrors, "Enable bypassing errors when converting")
cmd.Flags().StringVar(&r.configExtraArgs, "config.extra-args", r.configExtraArgs, "Extra arguments from the original format used by the converter. Multiple arguments can be passed by separating them with a space.")

// Misc flags
cmd.Flags().
BoolVar(&r.disableReporting, "disable-reporting", r.disableReporting, "Disable reporting of enabled components to Grafana.")
cmd.Flags().StringVar(&r.storagePath, "storage.path", r.storagePath, "Base directory where components can store data")
cmd.Flags().Var(&r.minStability, "stability.level", fmt.Sprintf("Minimum stability level of features to enable. Supported values: %s", strings.Join(featuregate.AllowedValues(), ", ")))
return cmd
}

type flowRun struct {
inMemoryAddr string
httpListenAddr string
storagePath string
minStability featuregate.Stability
uiPrefix string
enablePprof bool
disableReporting bool
Expand Down Expand Up @@ -265,10 +276,11 @@ func (fr *flowRun) Run(configPath string) error {
agentseed.Init(fr.storagePath, l)

f := flow.New(flow.Options{
Logger: l,
Tracer: t,
DataPath: fr.storagePath,
Reg: reg,
Logger: l,
Tracer: t,
DataPath: fr.storagePath,
Reg: reg,
MinStability: fr.minStability,
Services: []service.Service{
httpService,
uiService,
Expand Down
1 change: 1 addition & 0 deletions component/common/loki/positions/write_positions_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package positions

import (
"bytes"

"github.com/natefinch/atomic"
yaml "gopkg.in/yaml.v2"
)
Expand Down
8 changes: 5 additions & 3 deletions component/discovery/aws/ec2.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/grafana/agent/component"
"github.com/grafana/agent/component/common/config"
"github.com/grafana/agent/component/discovery"
"github.com/grafana/agent/internal/featuregate"
"github.com/grafana/river/rivertypes"
promcfg "github.com/prometheus/common/config"
"github.com/prometheus/common/model"
Expand All @@ -17,9 +18,10 @@ import (

func init() {
component.Register(component.Registration{
Name: "discovery.ec2",
Args: EC2Arguments{},
Exports: discovery.Exports{},
Name: "discovery.ec2",
Stability: featuregate.StabilityStable,
Args: EC2Arguments{},
Exports: discovery.Exports{},
Build: func(opts component.Options, args component.Arguments) (component.Component, error) {
return NewEC2(opts, args.(EC2Arguments))
},
Expand Down
8 changes: 5 additions & 3 deletions component/discovery/aws/lightsail.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/grafana/agent/component"
"github.com/grafana/agent/component/common/config"
"github.com/grafana/agent/component/discovery"
"github.com/grafana/agent/internal/featuregate"
"github.com/grafana/river/rivertypes"
promcfg "github.com/prometheus/common/config"
"github.com/prometheus/common/model"
Expand All @@ -17,9 +18,10 @@ import (

func init() {
component.Register(component.Registration{
Name: "discovery.lightsail",
Args: LightsailArguments{},
Exports: discovery.Exports{},
Name: "discovery.lightsail",
Stability: featuregate.StabilityStable,
Args: LightsailArguments{},
Exports: discovery.Exports{},
Build: func(opts component.Options, args component.Arguments) (component.Component, error) {
return NewLightsail(opts, args.(LightsailArguments))
},
Expand Down
8 changes: 5 additions & 3 deletions component/discovery/azure/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/grafana/agent/component"
"github.com/grafana/agent/component/common/config"
"github.com/grafana/agent/component/discovery"
"github.com/grafana/agent/internal/featuregate"
"github.com/grafana/river/rivertypes"
common "github.com/prometheus/common/config"
"github.com/prometheus/common/model"
Expand All @@ -16,9 +17,10 @@ import (

func init() {
component.Register(component.Registration{
Name: "discovery.azure",
Args: Arguments{},
Exports: discovery.Exports{},
Name: "discovery.azure",
Stability: featuregate.StabilityStable,
Args: Arguments{},
Exports: discovery.Exports{},

Build: func(opts component.Options, args component.Arguments) (component.Component, error) {
return New(opts, args.(Arguments))
Expand Down
8 changes: 5 additions & 3 deletions component/discovery/consul/consul.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/grafana/agent/component"
"github.com/grafana/agent/component/common/config"
"github.com/grafana/agent/component/discovery"
"github.com/grafana/agent/internal/featuregate"
"github.com/grafana/river/rivertypes"
config_util "github.com/prometheus/common/config"
"github.com/prometheus/common/model"
Expand All @@ -15,9 +16,10 @@ import (

func init() {
component.Register(component.Registration{
Name: "discovery.consul",
Args: Arguments{},
Exports: discovery.Exports{},
Name: "discovery.consul",
Stability: featuregate.StabilityStable,
Args: Arguments{},
Exports: discovery.Exports{},

Build: func(opts component.Options, args component.Arguments) (component.Component, error) {
return New(opts, args.(Arguments))
Expand Down
8 changes: 5 additions & 3 deletions component/discovery/consulagent/consulagent.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@ import (
"github.com/grafana/agent/component"
"github.com/grafana/agent/component/common/config"
"github.com/grafana/agent/component/discovery"
"github.com/grafana/agent/internal/featuregate"
"github.com/grafana/river/rivertypes"
promcfg "github.com/prometheus/common/config"
"github.com/prometheus/common/model"
)

func init() {
component.Register(component.Registration{
Name: "discovery.consulagent",
Args: Arguments{},
Exports: discovery.Exports{},
Name: "discovery.consulagent",
Stability: featuregate.StabilityStable,
Args: Arguments{},
Exports: discovery.Exports{},

Build: func(opts component.Options, args component.Arguments) (component.Component, error) {
return New(opts, args.(Arguments))
Expand Down
8 changes: 5 additions & 3 deletions component/discovery/digitalocean/digitalocean.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@ import (
"github.com/grafana/agent/component"
"github.com/grafana/agent/component/common/config"
"github.com/grafana/agent/component/discovery"
"github.com/grafana/agent/internal/featuregate"
"github.com/grafana/river/rivertypes"
"github.com/prometheus/common/model"
prom_discovery "github.com/prometheus/prometheus/discovery/digitalocean"
)

func init() {
component.Register(component.Registration{
Name: "discovery.digitalocean",
Args: Arguments{},
Exports: discovery.Exports{},
Name: "discovery.digitalocean",
Stability: featuregate.StabilityStable,
Args: Arguments{},
Exports: discovery.Exports{},

Build: func(opts component.Options, args component.Arguments) (component.Component, error) {
return New(opts, args.(Arguments))
Expand Down
8 changes: 5 additions & 3 deletions component/discovery/dns/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@ import (

"github.com/grafana/agent/component"
"github.com/grafana/agent/component/discovery"
"github.com/grafana/agent/internal/featuregate"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/discovery/dns"
)

func init() {
component.Register(component.Registration{
Name: "discovery.dns",
Args: Arguments{},
Exports: discovery.Exports{},
Name: "discovery.dns",
Stability: featuregate.StabilityStable,
Args: Arguments{},
Exports: discovery.Exports{},

Build: func(opts component.Options, args component.Arguments) (component.Component, error) {
return New(opts, args.(Arguments))
Expand Down
8 changes: 5 additions & 3 deletions component/discovery/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@ import (
"github.com/grafana/agent/component"
"github.com/grafana/agent/component/common/config"
"github.com/grafana/agent/component/discovery"
"github.com/grafana/agent/internal/featuregate"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/discovery/moby"
)

func init() {
component.Register(component.Registration{
Name: "discovery.docker",
Args: Arguments{},
Exports: discovery.Exports{},
Name: "discovery.docker",
Stability: featuregate.StabilityStable,
Args: Arguments{},
Exports: discovery.Exports{},

Build: func(opts component.Options, args component.Arguments) (component.Component, error) {
return New(opts, args.(Arguments))
Expand Down
8 changes: 5 additions & 3 deletions component/discovery/dockerswarm/dockerswarm.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@ import (
"github.com/grafana/agent/component"
"github.com/grafana/agent/component/common/config"
"github.com/grafana/agent/component/discovery"
"github.com/grafana/agent/internal/featuregate"
"github.com/prometheus/common/model"
prom_discovery "github.com/prometheus/prometheus/discovery/moby"
)

func init() {
component.Register(component.Registration{
Name: "discovery.dockerswarm",
Args: Arguments{},
Exports: discovery.Exports{},
Name: "discovery.dockerswarm",
Stability: featuregate.StabilityStable,
Args: Arguments{},
Exports: discovery.Exports{},

Build: func(opts component.Options, args component.Arguments) (component.Component, error) {
return New(opts, args.(Arguments))
Expand Down
8 changes: 5 additions & 3 deletions component/discovery/eureka/eureka.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@ import (
"github.com/grafana/agent/component"
"github.com/grafana/agent/component/common/config"
"github.com/grafana/agent/component/discovery"
"github.com/grafana/agent/internal/featuregate"
"github.com/prometheus/common/model"
prom_discovery "github.com/prometheus/prometheus/discovery/eureka"
)

func init() {
component.Register(component.Registration{
Name: "discovery.eureka",
Args: Arguments{},
Exports: discovery.Exports{},
Name: "discovery.eureka",
Stability: featuregate.StabilityStable,
Args: Arguments{},
Exports: discovery.Exports{},

Build: func(opts component.Options, args component.Arguments) (component.Component, error) {
return New(opts, args.(Arguments))
Expand Down
8 changes: 5 additions & 3 deletions component/discovery/file/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@ import (

"github.com/grafana/agent/component"
"github.com/grafana/agent/component/discovery"
"github.com/grafana/agent/internal/featuregate"
"github.com/prometheus/common/model"
prom_discovery "github.com/prometheus/prometheus/discovery/file"
)

func init() {
component.Register(component.Registration{
Name: "discovery.file",
Args: Arguments{},
Exports: discovery.Exports{},
Name: "discovery.file",
Stability: featuregate.StabilityStable,
Args: Arguments{},
Exports: discovery.Exports{},

Build: func(opts component.Options, args component.Arguments) (component.Component, error) {
return New(opts, args.(Arguments))
Expand Down
8 changes: 5 additions & 3 deletions component/discovery/gce/gce.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ import (

"github.com/grafana/agent/component"
"github.com/grafana/agent/component/discovery"
"github.com/grafana/agent/internal/featuregate"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/discovery/gce"
)

func init() {
component.Register(component.Registration{
Name: "discovery.gce",
Args: Arguments{},
Exports: discovery.Exports{},
Name: "discovery.gce",
Stability: featuregate.StabilityStable,
Args: Arguments{},
Exports: discovery.Exports{},

Build: func(opts component.Options, args component.Arguments) (component.Component, error) {
return New(opts, args.(Arguments))
Expand Down
8 changes: 5 additions & 3 deletions component/discovery/hetzner/hetzner.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@ import (
"github.com/grafana/agent/component"
"github.com/grafana/agent/component/common/config"
"github.com/grafana/agent/component/discovery"
"github.com/grafana/agent/internal/featuregate"
"github.com/prometheus/common/model"
prom_discovery "github.com/prometheus/prometheus/discovery/hetzner"
)

func init() {
component.Register(component.Registration{
Name: "discovery.hetzner",
Args: Arguments{},
Exports: discovery.Exports{},
Name: "discovery.hetzner",
Stability: featuregate.StabilityStable,
Args: Arguments{},
Exports: discovery.Exports{},

Build: func(opts component.Options, args component.Arguments) (component.Component, error) {
return New(opts, args.(Arguments))
Expand Down
8 changes: 5 additions & 3 deletions component/discovery/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@ import (
"github.com/grafana/agent/component"
"github.com/grafana/agent/component/common/config"
"github.com/grafana/agent/component/discovery"
"github.com/grafana/agent/internal/featuregate"
promcfg "github.com/prometheus/common/config"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/discovery/http"
)

func init() {
component.Register(component.Registration{
Name: "discovery.http",
Args: Arguments{},
Exports: discovery.Exports{},
Name: "discovery.http",
Stability: featuregate.StabilityStable,
Args: Arguments{},
Exports: discovery.Exports{},
Build: func(opts component.Options, args component.Arguments) (component.Component, error) {
return New(opts, args.(Arguments))
},
Expand Down
Loading

0 comments on commit ad580f5

Please sign in to comment.