Skip to content

Commit 1f70834

Browse files
Fix troubleshooting message URL for versions after 9.x (#10218) (#10479)
* Fix troubleshooting message URL for versions after 9.x * Add changelog fragment * Change troubleshoot message to a const variable * Fix build issue created by the merge * Fix linter issue * Revert linter fix and add nolint comment (cherry picked from commit b74942a) Co-authored-by: Stefan Traistaru <[email protected]>
1 parent 74efdcd commit 1f70834

18 files changed

+65
-29
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# REQUIRED
2+
# Kind can be one of:
3+
# - breaking-change: a change to previously-documented behavior
4+
# - deprecation: functionality that is being removed in a later release
5+
# - bug-fix: fixes a problem in a previous version
6+
# - enhancement: extends functionality but does not break or fix existing behavior
7+
# - feature: new functionality
8+
# - known-issue: problems that we are aware of in a given version
9+
# - security: impacts on the security of a product or a user’s deployment.
10+
# - upgrade: important information for someone upgrading from a prior version
11+
# - other: does not fit into any of the other categories
12+
kind: bug-fix
13+
14+
# REQUIRED for all kinds
15+
# Change summary; a 80ish characters long description of the change.
16+
summary: Fix troubleshooting docs URL for 9.x+ to prevent invalid version links
17+
# this field accommodate a description without length limits.
18+
# description:
19+
20+
# REQUIRED for breaking-change, deprecation, known-issue
21+
# impact:
22+
23+
# REQUIRED for breaking-change, deprecation, known-issue
24+
# action:
25+
26+
# REQUIRED for all kinds
27+
# Affected component; usually one of "elastic-agent", "fleet-server", "filebeat", "metricbeat", "auditbeat", "all", etc.
28+
component: elastic-agent
29+
30+
# AUTOMATED
31+
# OPTIONAL to manually add other PR URLs
32+
# PR URL: A link the PR that added the changeset.
33+
# If not present is automatically filled by the tooling finding the PR where this changelog fragment has been added.
34+
# NOTE: the tooling supports backports, so it's able to fill the original PR number instead of the backport PR number.
35+
# Please provide it if you are adding a fragment for a different PR.
36+
# pr: https://github.com/owner/repo/1234
37+
38+
# AUTOMATED
39+
# OPTIONAL to manually add other issue URLs
40+
# Issue URL; optional; the GitHub issue related to this changeset (either closes or is part of).
41+
# If not present is automatically filled by the tooling with the issue linked to the PR number.
42+
# issue: https://github.com/owner/repo/1234

internal/pkg/agent/cmd/apply_flavor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func newApplyFlavorCommandWithArgs(_ []string, streams *cli.IOStreams) *cobra.Co
2424
Short: "Apply Flavor cleans up unnecessary components from agent installation directory",
2525
Run: func(c *cobra.Command, _ []string) {
2626
if err := applyCmd(); err != nil {
27-
fmt.Fprintf(streams.Err, "Error: %v\n%s\n", err, troubleshootMessage())
27+
fmt.Fprintf(streams.Err, "Error: %v\n%s\n", err, troubleshootMessage)
2828
logExternal(fmt.Sprintf("%s apply flavor failed: %s", paths.BinaryName, err))
2929
os.Exit(1)
3030
}

internal/pkg/agent/cmd/common.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ package cmd
66

77
import (
88
"flag"
9-
"fmt"
109
"os"
11-
"strings"
1210

1311
"github.com/spf13/cobra"
1412

@@ -17,15 +15,12 @@ import (
1715

1816
"github.com/elastic/elastic-agent/internal/pkg/basecmd"
1917
"github.com/elastic/elastic-agent/internal/pkg/cli"
20-
"github.com/elastic/elastic-agent/internal/pkg/release"
2118
"github.com/elastic/elastic-agent/version"
2219
)
2320

24-
func troubleshootMessage() string {
25-
v := strings.Split(release.Version(), ".")
26-
version := strings.Join(v[:2], ".")
27-
return fmt.Sprintf("For help, please see our troubleshooting guide at https://www.elastic.co/guide/en/fleet/%s/fleet-troubleshooting.html", version)
28-
}
21+
const (
22+
troubleshootMessage = "For help, please see our troubleshooting guide at https://www.elastic.co/docs/troubleshoot/ingest/fleet/common-problems"
23+
)
2924

3025
// NewCommand returns the default command for the agent.
3126
func NewCommand() *cobra.Command {

internal/pkg/agent/cmd/container.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ occurs on every start of the container set FLEET_FORCE to 1.
170170
}
171171

172172
func logError(streams *cli.IOStreams, err error) {
173-
fmt.Fprintf(streams.Err, "Error: %v\n%s\n", err, troubleshootMessage())
173+
fmt.Fprintf(streams.Err, "Error: %v\n%s\n", err, troubleshootMessage)
174174
}
175175

176176
func logInfo(streams *cli.IOStreams, a ...interface{}) {

internal/pkg/agent/cmd/diagnostics.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func newDiagnosticsCommand(_ []string, streams *cli.IOStreams) *cobra.Command {
2828
Long: "This command gathers diagnostics information from the Elastic Agent and writes it to a zip archive.",
2929
Run: func(c *cobra.Command, args []string) {
3030
if err := diagnosticCmd(streams, c); err != nil {
31-
fmt.Fprintf(streams.Err, "Error: %v\n%s\n", err, troubleshootMessage())
31+
fmt.Fprintf(streams.Err, "Error: %v\n%s\n", err, troubleshootMessage)
3232
os.Exit(1)
3333
}
3434
},

internal/pkg/agent/cmd/diagnostics_otel.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func newOtelDiagnosticsCommand(streams *cli.IOStreams) *cobra.Command {
2525
Long: "This command gathers diagnostics information from the EDOT and writes it to a zip archive",
2626
RunE: func(cmd *cobra.Command, _ []string) error {
2727
if err := otelDiagnosticCmd(streams, cmd); err != nil {
28-
fmt.Fprintf(streams.Err, "Error: %v\n%s\n", err, troubleshootMessage())
28+
fmt.Fprintf(streams.Err, "Error: %v\n%s\n", err, troubleshootMessage)
2929
os.Exit(1)
3030
}
3131
return nil

internal/pkg/agent/cmd/enroll.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func newEnrollCommandWithArgs(_ []string, streams *cli.IOStreams) *cobra.Command
4545
Long: "This command will enroll the Elastic Agent into Fleet.",
4646
Run: func(c *cobra.Command, args []string) {
4747
if err := doEnroll(streams, c); err != nil {
48-
fmt.Fprintf(streams.Err, "Error: %v\n%s\n", err, troubleshootMessage())
48+
fmt.Fprintf(streams.Err, "Error: %v\n%s\n", err, troubleshootMessage)
4949
logExternal(fmt.Sprintf("%s enroll failed: %s", paths.BinaryName, err))
5050
os.Exit(1)
5151
}

internal/pkg/agent/cmd/inspect.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ wait that amount of time before using the variables for the configuration.
6262
ctx, cancel := context.WithCancel(context.Background())
6363
service.HandleSignals(func() {}, cancel)
6464
if err := inspectConfig(ctx, paths.ConfigFile(), opts, streams); err != nil {
65-
fmt.Fprintf(streams.Err, "Error: %v\n%s\n", err, troubleshootMessage())
65+
fmt.Fprintf(streams.Err, "Error: %v\n%s\n", err, troubleshootMessage)
6666
os.Exit(1)
6767
}
6868
},
@@ -115,7 +115,7 @@ variables for the configuration.
115115
service.HandleSignals(func() {}, cancel)
116116

117117
if err := inspectComponents(ctx, paths.ConfigFile(), opts, streams); err != nil {
118-
fmt.Fprintf(streams.Err, "Error: %v\n%s\n", err, troubleshootMessage())
118+
fmt.Fprintf(streams.Err, "Error: %v\n%s\n", err, troubleshootMessage)
119119
os.Exit(1)
120120
}
121121
},

internal/pkg/agent/cmd/install.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ would like the Agent to operate.
4949
`,
5050
Run: func(c *cobra.Command, _ []string) {
5151
if err := installCmd(streams, c); err != nil {
52-
fmt.Fprintf(streams.Err, "Error: %v\n%s\n", err, troubleshootMessage())
52+
fmt.Fprintf(streams.Err, "Error: %v\n%s\n", err, troubleshootMessage)
5353
logExternal(fmt.Sprintf("%s install failed: %s", paths.BinaryName, err))
5454
os.Exit(1)
5555
}

internal/pkg/agent/cmd/logs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ func newLogsCommandWithArgs(_ []string, streams *cli.IOStreams) *cobra.Command {
170170
Long: "This command allows to output, watch and filter Elastic Agent logs.",
171171
Run: func(c *cobra.Command, _ []string) {
172172
if err := logsCmd(streams, c, logsDir, eventLogsDir); err != nil {
173-
fmt.Fprintf(streams.Err, "Error: %v\n%s\n", err, troubleshootMessage())
173+
fmt.Fprintf(streams.Err, "Error: %v\n%s\n", err, troubleshootMessage)
174174
os.Exit(1)
175175
}
176176
},

0 commit comments

Comments
 (0)