-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Elastic Agent] Support the install, control, and uninstall of Endpoi…
…nt (#19248) (#19497) * Initial spec parsing for endpoint. * Update comment. * Fix spec test. * Update code so it copies the entire input. * Fix ast test. * Merge agent-improve-restart-loop * Merge agent-endpoint-spec * Refactor core/plugin/app into mostly core/ and use core/plugin for different app types. * Work on endpoint service application. * More fixes. * Fix format and tests. * Fix some imports. * More cleanups. * Fix export comment. * Pass the program.Spec into the descriptor. * Run endpoint verify, install, and uninstall when endpoint should be running. * Fix install and uninstall of Endpoint * Fix some small issues with service app. * Add changelog entry. * Fix lint and tests. * Fix lint. * Remove the code no longer needed because of newer config format. * Fix rules and review. * Update to Endpoint Security. * Fix issues so endpoint security runs. * Add comments. * Update docstring. * Some more fixes. * Delete the extra endpoint testdata files. * Add timeout to exec_file step. * Fix supported map. * Fix getting support programs by cmd. * Improve app started checks. * Fix buildspec. (cherry picked from commit 0fe1554)
- Loading branch information
1 parent
7a798c3
commit f9b5f18
Showing
38 changed files
with
435 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
x-pack/elastic-agent/pkg/agent/operation/operation_uninstall.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
// or more contributor license agreements. Licensed under the Elastic License; | ||
// you may not use this file except in compliance with the Elastic License. | ||
|
||
package operation | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/artifact/uninstall" | ||
"github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/logger" | ||
"github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/state" | ||
) | ||
|
||
// operationUninstall uninstalls a artifact from predefined location | ||
type operationUninstall struct { | ||
logger *logger.Logger | ||
program Descriptor | ||
uninstaller uninstall.Uninstaller | ||
} | ||
|
||
func newOperationUninstall( | ||
logger *logger.Logger, | ||
program Descriptor, | ||
uninstaller uninstall.Uninstaller) *operationUninstall { | ||
|
||
return &operationUninstall{ | ||
logger: logger, | ||
program: program, | ||
uninstaller: uninstaller, | ||
} | ||
} | ||
|
||
// Name is human readable name identifying an operation | ||
func (o *operationUninstall) Name() string { | ||
return "operation-uninstall" | ||
} | ||
|
||
// Check checks whether uninstall needs to be ran. | ||
// | ||
// Always true. | ||
func (o *operationUninstall) Check(_ context.Context, _ Application) (bool, error) { | ||
return true, nil | ||
} | ||
|
||
// Run runs the operation | ||
func (o *operationUninstall) Run(ctx context.Context, application Application) (err error) { | ||
defer func() { | ||
if err != nil { | ||
application.SetState(state.Failed, err.Error()) | ||
} | ||
}() | ||
|
||
return o.uninstaller.Uninstall(ctx, o.program.BinaryName(), o.program.Version(), o.program.Directory()) | ||
} |
Oops, something went wrong.