Skip to content

Commit

Permalink
Make request diagnostics optional
Browse files Browse the repository at this point in the history
  • Loading branch information
michel-laterman committed Jun 17, 2024
1 parent 891be9a commit 6670bf0
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion internal/pkg/api/openapi.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions internal/pkg/config/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,9 @@ func (c *Elasticsearch) DiagRequests(ctx context.Context) []byte {
if u.Scheme == "" {
u.Scheme = c.Protocol
}
ctx, cancel := context.WithTimeout(ctx, time.Second*30) // TODO(michel-laterman): Configurable timeout; should this be part of config, or part of a diagnostics action?
req, err := http.NewRequestWithContext(ctx, http.MethodGet, u.String(), nil)
cancel()
if err != nil {
zerolog.Ctx(ctx).Warn().Err(err).Str("host", host).Msg("Unable to create request to host")
res.WriteString(fmt.Sprintf("Unable to create request to host %q: %v\n", host, err))
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/server/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func (a *Agent) Run(ctx context.Context) error {
}
return cfg.Output.Elasticsearch.TLS.DiagCerts()()
})
a.agent.RegisterDiagnosticHook("fleet-server output request diag", "fleet-server output request trace diagnostics", "fleet-server-output-request.txt", "text/plain", func() []byte {
a.agent.RegisterOptionalDiagnosticHook("CONN", "fleet-server output request diag", "fleet-server output request trace diagnostics", "fleet-server-output-request.txt", "text/plain", func() []byte {
if a.srv == nil {
log.Warn().Msg("Diagnostics hook failure fleet-server is nil.")
return []byte(`Diagnostics hook failure fleet-server is nil`)
Expand Down
1 change: 1 addition & 0 deletions model/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,7 @@ components:
type: string
enum:
- CPU
- CONN
actionPolicyReassign:
description: The POLICY_REASSIGN action data.
type: object
Expand Down
3 changes: 2 additions & 1 deletion pkg/api/types.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6670bf0

Please sign in to comment.