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

Fix agent not starting with api key missing on Windows #19887

Merged
merged 4 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
3 changes: 3 additions & 0 deletions cmd/agent/subcommands/run/command_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,5 +158,8 @@ func getPlatformModules() fx.Option {
return fx.Options(
agentcrashdetect.Module,
comptraceconfig.Module,
fx.Replace(comptraceconfig.Params{
FailIfAPIKeyMissing: false,
}),
)
}
3 changes: 3 additions & 0 deletions comp/trace/config/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ type Mock interface {
// Module defines the fx options for this component.
var Module = fxutil.Component(
fx.Provide(newConfig),
fx.Supply(Params{
FailIfAPIKeyMissing: true,
}),
)

// MockModule defines the fx options for the mock component.
Expand Down
8 changes: 6 additions & 2 deletions comp/trace/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

type dependencies struct {
fx.In

Params Params
Config coreconfig.Component
}

Expand All @@ -43,8 +43,12 @@ type cfg struct {

func newConfig(deps dependencies) (Component, error) {
tracecfg, err := setupConfig(deps, "")

if err != nil {
return nil, err
// Allow main Agent to start with missing API key
if !(err == traceconfig.ErrMissingAPIKey && !deps.Params.FailIfAPIKeyMissing) {
return nil, err
}
}

c := cfg{
Expand Down
12 changes: 12 additions & 0 deletions comp/trace/config/params.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.

package config

// Params defines the parameters for the config component.
type Params struct {
// FailIfAPIKeyMissing controls if the Agent should fail if the API key is missing from the config.
FailIfAPIKeyMissing bool
}
Loading