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

[windows] fix startup with empty api key #19884

Closed
wants to merge 2 commits into from
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
9 changes: 8 additions & 1 deletion comp/trace/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"fmt"
"html"
"net/http"
"runtime"
"strings"
"testing"

Expand Down Expand Up @@ -44,7 +45,13 @@ type cfg struct {
func newConfig(deps dependencies) (Component, error) {
tracecfg, err := setupConfig(deps, "")
if err != nil {
return nil, err
// The windows agent has a requirement that it can successfully start
// with an invalid config. The `tracecfg` object is initialized with
// various defaults, that allow it to be "good enough". On Windows,
// allow us to return the minimal config rather than failing startup
if runtime.GOOS != "windows" || tracecfg == nil {
return nil, err
}
}

c := cfg{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,6 @@ def stop(flavor)
end
end
wait_until_service_stopped(service)
if result == nil || result == false
log_trace "datadog-agent", "stop"
end
result
end

Expand All @@ -174,9 +171,6 @@ def start(flavor)
end
end
wait_until_service_started(service)
if result == nil || result == false
log_trace "datadog-agent", "start"
end
result
end

Expand Down Expand Up @@ -210,32 +204,9 @@ def restart(flavor)
wait_until_service_started(service, 5)
end
end
if result == nil || result == false
log_trace "datadog-agent", "restart"
end
result
end

def log_trace(flavor, action)
service = get_service_name(flavor)
if os == :windows
if action == "stop" || action == "restart"
system "wevtutil qe System /q:\"*[System[(EventID=7040) and (EventData[Data[@Name='param1']='#{service}'])]\""
end
if action == "start" || action == "restart"
system "wevtutil qe System /q:\"*[System[(EventID=7036) and (EventData[Data[@Name='param1']='#{service}'])]\""
end
else
if has_systemctl
system "sudo journalctl -u #{service} -xe --no-pager"
elsif has_upstart
system "sudo grep #{service} /var/log/upstart"
else
system "sudo grep #{service} /var/log/message"
end
end
end

def has_systemctl
system('command -v systemctl 2>&1 > /dev/null')
end
Expand Down