Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable TLS by default in shipper output #34425

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion libbeat/outputs/shipper/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type backoffConfig struct {
Max time.Duration `config:"max" validate:"nonzero"`
}

// Config manages configuration for the shipper output
type Config struct {
// Server address in the format of host:port, e.g. `localhost:50051`
Server string `config:"server"`
Expand All @@ -50,8 +51,12 @@ type Config struct {
}

func defaultConfig() Config {
enabled := true
return Config{
TLS: nil,
// agent will expect that TLS is enabled by default, will disable explicitly
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will disable explicitly

Looks confusing because of the enabled := true above. What does it mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, sorry, it should say "the agent will disabled it explicitly"

TLS: &tlscommon.Config{
Enabled: &enabled,
},
Timeout: 30 * time.Second,
MaxRetries: 3,
BulkMaxSize: 50,
Expand Down
35 changes: 34 additions & 1 deletion libbeat/outputs/shipper/shipper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,29 @@ import (
"github.com/elastic/elastic-agent-shipper-client/pkg/proto/messages"
)

func TestShipperConfig(t *testing.T) {
input := mapstr.M{
"ssl": mapstr.M{
"enabled": false,
},
"timeout": time.Second * 10,
"backoff": mapstr.M{
"init": time.Second,
},
}
cfg, err := config.NewConfigFrom(input)
require.NoError(t, err)

shipperSettings := defaultConfig()
err = cfg.Unpack(&shipperSettings)
require.NoError(t, err)

require.Equal(t, false, *shipperSettings.TLS.Enabled)
require.Equal(t, 3, shipperSettings.MaxRetries)
require.Equal(t, time.Second*10, shipperSettings.Timeout)
require.Equal(t, time.Second, shipperSettings.Backoff.Init)
}

func TestToShipperEvent(t *testing.T) {
wrong := struct{}{}
ts := time.Now().Truncate(time.Second)
Expand Down Expand Up @@ -224,6 +247,7 @@ func TestConvertMapStr(t *testing.T) {
require.Nil(t, converted)
return
}
require.NoError(t, err)
requireEqualProto(t, tc.exp, converted)
})
}
Expand Down Expand Up @@ -305,6 +329,9 @@ func TestPublish(t *testing.T) {

cfg, err := config.NewConfigFrom(map[string]interface{}{
"server": addr,
"ssl": map[string]interface{}{
"enabled": false,
},
})
require.NoError(t, err)

Expand Down Expand Up @@ -338,7 +365,10 @@ func TestPublish(t *testing.T) {
defer stop()

cfg, err := config.NewConfigFrom(map[string]interface{}{
"server": addr,
"server": addr,
"ssl": map[string]interface{}{
"enabled": false,
},
"timeout": 5, // 5 sec
"backoff": map[string]interface{}{
"init": "10ms",
Expand Down Expand Up @@ -383,6 +413,9 @@ func TestPublish(t *testing.T) {
defer stop()

cfg, err := config.NewConfigFrom(map[string]interface{}{
"ssl": map[string]interface{}{
"enabled": false,
},
"server": addr,
"timeout": 5, // 5 sec
"backoff": map[string]interface{}{
Expand Down