Skip to content

Commit 8911acd

Browse files
Merge branch 'main' into otel/added-k8s-comps
2 parents 140c47a + 33598b6 commit 8911acd

File tree

7 files changed

+94
-52
lines changed

7 files changed

+94
-52
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Kind can be one of:
2+
# - breaking-change: a change to previously-documented behavior
3+
# - deprecation: functionality that is being removed in a later release
4+
# - bug-fix: fixes a problem in a previous version
5+
# - enhancement: extends functionality but does not break or fix existing behavior
6+
# - feature: new functionality
7+
# - known-issue: problems that we are aware of in a given version
8+
# - security: impacts on the security of a product or a user’s deployment.
9+
# - upgrade: important information for someone upgrading from a prior version
10+
# - other: does not fit into any of the other categories
11+
kind: enhancement
12+
13+
# Change summary; a 80ish characters long description of the change.
14+
summary: Add diagnostics skip-conn flag
15+
16+
# Long description; in case the summary is not enough to describe the change
17+
# this field accommodate a description without length limits.
18+
# NOTE: This field will be rendered only for breaking-change and known-issue kinds at the moment.
19+
description: Add --skip-conn flag to elastic-agent diagnostics subcommand to skip collecting connection request diagnostics.
20+
21+
# Affected component; a word indicating the component this changeset affects.
22+
component:
23+
24+
# PR URL; optional; the PR number that added the changeset.
25+
# If not present is automatically filled by the tooling finding the PR where this changelog fragment has been added.
26+
# NOTE: the tooling supports backports, so it's able to fill the original PR number instead of the backport PR number.
27+
# Please provide it if you are adding a fragment for a different PR.
28+
pr: https://github.com/elastic/elastic-agent/pull/4946
29+
30+
# Issue URL; optional; the GitHub issue related to this changeset (either closes or is part of).
31+
# If not present is automatically filled by the tooling with the issue linked to the PR number.
32+
#issue: https://github.com/owner/repo/1234

control_v2.proto

+1
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ message DiagnosticAgentRequest {
260260
// DiagnosticAgentRequestAdditional is an enum of additional diagnostic metrics that can be requested from Elastic Agent.
261261
enum AdditionalDiagnosticRequest {
262262
CPU = 0;
263+
CONN = 1;
263264
}
264265

265266
// DiagnosticComponentsRequest is the message to request diagnostics from individual components.

internal/pkg/agent/cmd/diagnostics.go

+8-3
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ func newDiagnosticsCommand(_ []string, streams *cli.IOStreams) *cobra.Command {
3636

3737
cmd.Flags().StringP("file", "f", "", "name of the output diagnostics zip archive")
3838
cmd.Flags().BoolP("cpu-profile", "p", false, "wait to collect a CPU profile")
39+
cmd.Flags().BoolP("skip-conn", "", false, "Skip connection request diagnostics")
3940
cmd.Flags().Bool("exclude-events", false, "do not collect events log file")
4041

4142
return cmd
@@ -64,7 +65,8 @@ func diagnosticCmd(streams *cli.IOStreams, cmd *cobra.Command) error {
6465
defer f.Close()
6566

6667
cpuProfile, _ := cmd.Flags().GetBool("cpu-profile")
67-
agentDiag, unitDiags, compDiags, err := collectDiagnostics(ctx, streams, cpuProfile)
68+
connSkip, _ := cmd.Flags().GetBool("skip-conn")
69+
agentDiag, unitDiags, compDiags, err := collectDiagnostics(ctx, streams, cpuProfile, connSkip)
6870
if err != nil {
6971
return fmt.Errorf("failed collecting diagnostics: %w", err)
7072
}
@@ -77,7 +79,7 @@ func diagnosticCmd(streams *cli.IOStreams, cmd *cobra.Command) error {
7779
return nil
7880
}
7981

80-
func collectDiagnostics(ctx context.Context, streams *cli.IOStreams, cpuProfile bool) ([]client.DiagnosticFileResult, []client.DiagnosticUnitResult, []client.DiagnosticComponentResult, error) {
82+
func collectDiagnostics(ctx context.Context, streams *cli.IOStreams, cpuProfile, connSkip bool) ([]client.DiagnosticFileResult, []client.DiagnosticUnitResult, []client.DiagnosticComponentResult, error) {
8183
daemon := client.New()
8284
err := daemon.Connect(ctx)
8385
if err != nil {
@@ -86,10 +88,13 @@ func collectDiagnostics(ctx context.Context, streams *cli.IOStreams, cpuProfile
8688
defer daemon.Disconnect()
8789

8890
var additionalDiags []cproto.AdditionalDiagnosticRequest
91+
if !connSkip {
92+
additionalDiags = append(additionalDiags, cproto.AdditionalDiagnosticRequest_CONN)
93+
}
8994
if cpuProfile {
9095
// console will just hang while we wait for the CPU profile; print something so user doesn't get confused
9196
fmt.Fprintf(streams.Out, "Creating diagnostics archive, waiting for CPU profile...\n")
92-
additionalDiags = []cproto.AdditionalDiagnosticRequest{cproto.AdditionalDiagnosticRequest_CPU}
97+
additionalDiags = append(additionalDiags, cproto.AdditionalDiagnosticRequest_CPU)
9398
}
9499

95100
agentDiag, err := daemon.DiagnosticAgent(ctx, additionalDiags)

pkg/control/v1/proto/control_v1.pb.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/control/v1/proto/control_v1_grpc.pb.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/control/v2/cproto/control_v2.pb.go

+50-46
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/control/v2/cproto/control_v2_grpc.pb.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)