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

Cherry-pick #24128 to 7.x: Fix: Successfully installed and enrolled agent running standalone #24131

Merged
merged 1 commit into from
Feb 19, 2021
Merged
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
1 change: 1 addition & 0 deletions x-pack/elastic-agent/CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
- Fixed Monitoring filebeat and metricbeat not connecting to Agent over GRPC {pull}23843[23843]
- Windows agent doesn't uninstall with a lowercase `c:` drive in the path {pull}23998[23998]
- Fix reloading of log level for services {pull}[24055]24055
- Fix: Successfully installed and enrolled agent running standalone{pull}[24128]24128

==== New features

Expand Down
6 changes: 0 additions & 6 deletions x-pack/elastic-agent/pkg/agent/application/enroll_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ type EnrollCmdOption struct {
Staging string
FleetServerConnStr string
FleetServerPolicyID string
NoRestart bool
}

func (e *EnrollCmdOption) kibanaConfig() (*kibana.Config, error) {
Expand Down Expand Up @@ -178,18 +177,13 @@ func (c *EnrollCmd) Execute(ctx context.Context) error {
// enroll should use localhost as fleet-server is now running
// it must also restart
c.options.URL = "http://localhost:8000"
c.options.NoRestart = false
}

err := c.enrollWithBackoff(ctx)
if err != nil {
return errors.New(err, "fail to enroll")
}

if c.options.NoRestart {
return nil
}

if c.daemonReload(ctx) != nil {
c.log.Info("Elastic Agent might not be running; unable to trigger restart")
}
Expand Down
4 changes: 0 additions & 4 deletions x-pack/elastic-agent/pkg/agent/cmd/enroll.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ func newEnrollCommandWithArgs(flags *globalFlags, _ []string, streams *cli.IOStr

addEnrollFlags(cmd)
cmd.Flags().BoolP("force", "f", false, "Force overwrite the current and do not prompt for confirmation")
cmd.Flags().Bool("no-restart", false, "Skip restarting the currently running daemon")

// used by install command
cmd.Flags().BoolP("from-install", "", false, "Set by install command to signal this was executed from install")
Expand Down Expand Up @@ -141,11 +140,9 @@ func enroll(streams *cli.IOStreams, cmd *cobra.Command, flags *globalFlags, args
}
}

noRestart, _ := cmd.Flags().GetBool("no-restart")
force, _ := cmd.Flags().GetBool("force")
if fromInstall {
force = true
noRestart = true
}

// prompt only when it is not forced and is already enrolled
Expand Down Expand Up @@ -192,7 +189,6 @@ func enroll(streams *cli.IOStreams, cmd *cobra.Command, flags *globalFlags, args
Staging: staging,
FleetServerConnStr: fServer,
FleetServerPolicyID: fPolicy,
NoRestart: noRestart,
}

c, err := application.NewEnrollCmd(
Expand Down