Skip to content

Commit

Permalink
Display the stability status of the Elastic Agent (#17336) (#17578)
Browse files Browse the repository at this point in the history
* 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

(cherry picked from commit b70e44b)
  • Loading branch information
ph authored Apr 7, 2020
1 parent 4999c80 commit 9c844df
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions x-pack/agent/CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@

- Generate index name in a format type-dataset-namespace {pull}16903[16903]
- OS agnostic default configuration {pull}17016[17016]
- Display the stability of the agent at enroll and start. {pull}17336[17336]
2 changes: 2 additions & 0 deletions x-pack/agent/pkg/agent/application/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -42,6 +43,7 @@ func createApplication(
pathConfigFile string,
config *config.Config,
) (Application, error) {
warn.LogNotGA(log)

log.Info("Detecting execution mode")
c := localDefaultConfig()
Expand Down
3 changes: 3 additions & 0 deletions x-pack/agent/pkg/agent/cmd/enroll.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand Down
24 changes: 24 additions & 0 deletions x-pack/agent/pkg/agent/warn/warn.go
Original file line number Diff line number Diff line change
@@ -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)
}

0 comments on commit 9c844df

Please sign in to comment.