From b70e44beb045b8ac92254a1a2b638dd924483f1f Mon Sep 17 00:00:00 2001 From: Pier-Hugues Pellerin Date: Tue, 31 Mar 2020 12:52:57 -0400 Subject: [PATCH] Display the stability status of the Elastic Agent (#17336) * Display the stability status of the Elastic Agent The Elastic Agent is currently Alpha quality software and is not ready to be used in a production environment, this commit make it obvious in the logs on startup and at enrollment. Note this doesn't use the cfgwarn helpers for two reasons: - We aren't using zap in the Elastic Agent code. - We also need to print on standout. This also add a "warn" package where the messaging can be edited once. Fixes: #17328 * Add a changelog entry --- x-pack/agent/CHANGELOG.asciidoc | 1 + .../pkg/agent/application/application.go | 2 ++ x-pack/agent/pkg/agent/cmd/enroll.go | 3 +++ x-pack/agent/pkg/agent/warn/warn.go | 24 +++++++++++++++++++ 4 files changed, 30 insertions(+) create mode 100644 x-pack/agent/pkg/agent/warn/warn.go diff --git a/x-pack/agent/CHANGELOG.asciidoc b/x-pack/agent/CHANGELOG.asciidoc index 804d43e75ad..8347f781cf2 100644 --- a/x-pack/agent/CHANGELOG.asciidoc +++ b/x-pack/agent/CHANGELOG.asciidoc @@ -20,3 +20,4 @@ - Generate index name in a format type-dataset-namespace {pull}16903[16903] - OS agnostic default configuration {pull}17016[17016] - Support for config constraints {pull}17112[17112] +- Display the stability of the agent at enroll and start. {pull}17336[17336] diff --git a/x-pack/agent/pkg/agent/application/application.go b/x-pack/agent/pkg/agent/application/application.go index 9cc2a83c088..d2e3e4f72e5 100644 --- a/x-pack/agent/pkg/agent/application/application.go +++ b/x-pack/agent/pkg/agent/application/application.go @@ -9,6 +9,7 @@ import ( "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/application/info" "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/errors" + "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/warn" "github.com/elastic/beats/v7/x-pack/agent/pkg/config" "github.com/elastic/beats/v7/x-pack/agent/pkg/core/logger" ) @@ -42,6 +43,7 @@ func createApplication( pathConfigFile string, config *config.Config, ) (Application, error) { + warn.LogNotGA(log) log.Info("Detecting execution mode") c := localDefaultConfig() diff --git a/x-pack/agent/pkg/agent/cmd/enroll.go b/x-pack/agent/pkg/agent/cmd/enroll.go index dd2cd71b0ca..d61804e9ba7 100644 --- a/x-pack/agent/pkg/agent/cmd/enroll.go +++ b/x-pack/agent/pkg/agent/cmd/enroll.go @@ -15,6 +15,7 @@ import ( c "github.com/elastic/beats/v7/libbeat/common/cli" "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/application" "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/errors" + "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/warn" "github.com/elastic/beats/v7/x-pack/agent/pkg/cli" "github.com/elastic/beats/v7/x-pack/agent/pkg/config" "github.com/elastic/beats/v7/x-pack/agent/pkg/core/logger" @@ -44,6 +45,8 @@ func newEnrollCommandWithArgs(flags *globalFlags, _ []string, streams *cli.IOStr } func enroll(streams *cli.IOStreams, cmd *cobra.Command, flags *globalFlags, args []string) error { + warn.PrintNotGA(streams.Out) + config, err := config.LoadYAML(flags.PathConfigFile) if err != nil { return errors.New(err, diff --git a/x-pack/agent/pkg/agent/warn/warn.go b/x-pack/agent/pkg/agent/warn/warn.go new file mode 100644 index 00000000000..ddbbc20132c --- /dev/null +++ b/x-pack/agent/pkg/agent/warn/warn.go @@ -0,0 +1,24 @@ +// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one +// or more contributor license agreements. Licensed under the Elastic License; +// you may not use this file except in compliance with the Elastic License. + +package warn + +import ( + "fmt" + "io" + + "github.com/elastic/beats/v7/x-pack/agent/pkg/core/logger" +) + +const message = "The Elastic Agent is currently in Alpha and should not be used in production" + +// LogNotGA warns the users in the log that the Elastic Agent is not GA. +func LogNotGA(log *logger.Logger) { + log.Info(message) +} + +// PrintNotGA writes to the received writer that the Agent is not GA. +func PrintNotGA(output io.Writer) { + fmt.Fprintln(output, message) +}