Skip to content

Commit

Permalink
Fix: deprecate --features and warn user (#726)
Browse files Browse the repository at this point in the history
  • Loading branch information
The-9880 authored Jun 11, 2024
1 parent 123b0d6 commit d1ca970
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
11 changes: 11 additions & 0 deletions cmd/synthetic-monitoring-agent/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ func run(args []string, stdout io.Writer) error {
flags.BoolVar(&config.AutoMemLimit, "enable-auto-memlimit", config.AutoMemLimit, "automatically set GOMEMLIMIT")
flags.BoolVar(&config.DisableK6, "disable-k6", config.DisableK6, "disables running k6 checks on this probe")
flags.Float64Var(&config.MemLimitRatio, "memlimit-ratio", config.MemLimitRatio, "fraction of available memory to use")
flags.Var(&features, "features", "optional feature flags")

if err := flags.Parse(args[1:]); err != nil {
return err
Expand Down Expand Up @@ -187,6 +188,8 @@ func run(args []string, stdout io.Writer) error {
Interface("config", config).
Msg("starting")

notifyAboutDeprecatedFeatureFlags(features, zl)

if features.IsSet(feature.K6) {
newUri, err := validateK6URI(config.K6URI)
if err != nil {
Expand Down Expand Up @@ -412,6 +415,14 @@ func validateK6URI(uri string) (string, error) {
return uri, nil
}

func notifyAboutDeprecatedFeatureFlags(features feature.Collection, zl zerolog.Logger) {
for _, ff := range []string{feature.K6, feature.Traceroute} {
if features.IsSet(ff) {
zl.Info().Msgf("the `%s` feature is now permanently enabled in the agent, you can remove it from the --feature flag without loss of functionality", ff)
}
}
}

func setupGoMemLimit(ratio float64) error {
_, err := memlimit.SetGoMemLimitWithOpts(
memlimit.WithRatio(ratio),
Expand Down
5 changes: 4 additions & 1 deletion internal/feature/feature.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import (
)

// TODO: this doesn't seem like the right place for this
const K6 = "k6"
const (
Traceroute = "traceroute"
K6 = "k6"
)

// ErrInvalidCollection is returned when you try to set a flag in an
// invalid collection.
Expand Down

0 comments on commit d1ca970

Please sign in to comment.