-
Notifications
You must be signed in to change notification settings - Fork 81
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
Support for remote ES output #3051
Merged
Merged
Changes from 87 commits
Commits
Show all changes
99 commits
Select commit
Hold shift + click to select a range
44b6985
first draft of remote output
juliaElastic f870e55
remove commented code
juliaElastic 4605e04
storing remote es clients in bulker
juliaElastic b6b47af
remote service_token from policy sent to agent
juliaElastic d82a117
fix lint
juliaElastic 0ceb201
rename remoteEsList and type
juliaElastic c63fb1e
added missing check
juliaElastic 6795a82
Merge branch 'main' into remote-es
juliaElastic 6cd8491
fixes after merge main
juliaElastic 4b72d71
fix lint
juliaElastic 1d6c31f
added changelog
juliaElastic 53de755
create bulker for remote es
juliaElastic 5bbc1f1
cleanup unused remoteEsClients and functions
juliaElastic ab7487d
fix linter
juliaElastic e901a80
renamed to remote_elasticsearch
juliaElastic 2465b2a
added tracer, removed opts
juliaElastic 1fd90a8
enable intrumentation on remote es client
juliaElastic 8db4da2
Merge branch 'main' into remote-es
juliaElastic 7953456
updated changelog
juliaElastic 9452494
Merge branch 'main' into remote-es
juliaElastic 11bc90c
try copy policyData
juliaElastic 8312727
revert policyData, printing out value of policy
juliaElastic 8cae7a4
setting policyData in other integration tests
juliaElastic bff9015
added missing param
juliaElastic a52b32b
watching for remote output cfg changes and restart
juliaElastic 41f4ced
fixes
juliaElastic 649bfdb
fix linter
juliaElastic f6994bd
fix
juliaElastic 84787bd
copy map instead of reference
juliaElastic d36f83a
added integration test
juliaElastic 255c28b
unit test on CheckRemoteOutputChanged
juliaElastic 108fe47
fix lint
juliaElastic fd7e406
fix lint
juliaElastic 4f99d62
added tests on policy_output remote ES
juliaElastic cc6a02e
added test on parsed_policy change
juliaElastic 6dc08cd
fix lint
juliaElastic 9a0e8b1
invalidate api key if remote output is removed
juliaElastic 830b401
fix lint
juliaElastic fa4698a
Merge branch 'main' into remote-es
juliaElastic 62a49c6
fix after conflicts
juliaElastic 0f1ed68
reporting remote es error in fleet-server state
juliaElastic 1d865d8
ignore lint error
juliaElastic 72a7249
fix test
juliaElastic 6ee9086
fix test
juliaElastic 374b1ae
fix test
juliaElastic dad52b0
fixed test
juliaElastic 8d4dbbc
start new bulker if remote config changed
juliaElastic de6724a
fix tests
juliaElastic e465d3d
added test for retire remote api key
juliaElastic bf6c9e3
monitor tests
juliaElastic 2cc1e7d
Merge branch 'main' into remote-es
juliaElastic 608ba26
remote es ping in standalone self monitor
juliaElastic 699ac62
added break
juliaElastic 81899b3
fix lint
juliaElastic 14f9507
fix issue
juliaElastic 963b87a
license header
juliaElastic 180cae8
fix lint
juliaElastic 3989856
cleanup, more test
juliaElastic 6b727b8
added test on engine
juliaElastic 60a3122
use output bulker when read update api key
juliaElastic 8797823
added remote es ping to self.go
juliaElastic 1be0575
review comments
juliaElastic dcf39f9
invalidate all ids with corresponding output
juliaElastic bb32a41
only add toRetireAPIKeys if does not exist
juliaElastic 3261472
added a retry loop to integration test
juliaElastic 991c689
fixed monitor tests
juliaElastic 75fdb8f
remove break loop in self monitor
juliaElastic a8447b2
fix lint
juliaElastic 9c7d6fe
openapi spec: added degraded state to desc
juliaElastic 8df35d1
added 2nd elasticsearch to integration test
juliaElastic 3b2dc11
Merge branch 'main' into remote-es
juliaElastic 10021a8
added build.Info to remote bulkers from fleet
juliaElastic 4c99949
added semaphore for updating bulkerMap
juliaElastic 8182bab
revert self monitor degraded on remote es error
juliaElastic 37106b0
fix tests
juliaElastic 64277ff
verify api key exists in remote es
juliaElastic ea1d3bd
fix lint
juliaElastic e15f995
remote remoteOutputErrorMap as not used
juliaElastic 6d4f87e
fix lint
juliaElastic 85142e2
revert openapi description about degraded state
juliaElastic 727daa4
reading output from policies index if bulker not found
juliaElastic 462c063
unit test on handleAck
juliaElastic 96bdb42
added test to query policies
juliaElastic 053fbed
fix test
juliaElastic 60cd6ee
fix integration test
juliaElastic 760ea2f
added integration test for invalidate api key
juliaElastic 9382975
test for child bulker cancel
juliaElastic 0006533
fixed test, replace semaphore with mutex
juliaElastic 41219f0
removed unused arg
juliaElastic 75c890b
added warning log if api keys orphaned
juliaElastic 4d2d67d
removed unused error
juliaElastic cd877f1
fix lint
juliaElastic aa7bf11
Merge branch 'main' into remote-es
juliaElastic d1ffe3f
try to fix test
juliaElastic 5885068
read output secret before prepare remote es
juliaElastic 4d5b906
try to fix test
juliaElastic d39141a
removed test
juliaElastic 299cdae
removed unused imports
juliaElastic 6fdba62
Merge branch 'main' into remote-es
juliaElastic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,32 @@ | ||
# Kind can be one of: | ||
# - breaking-change: a change to previously-documented behavior | ||
# - deprecation: functionality that is being removed in a later release | ||
# - bug-fix: fixes a problem in a previous version | ||
# - enhancement: extends functionality but does not break or fix existing behavior | ||
# - feature: new functionality | ||
# - known-issue: problems that we are aware of in a given version | ||
# - security: impacts on the security of a product or a user’s deployment. | ||
# - upgrade: important information for someone upgrading from a prior version | ||
# - other: does not fit into any of the other categories | ||
kind: feature | ||
|
||
# Change summary; a 80ish characters long description of the change. | ||
summary: Support for remote elasticsearch output | ||
|
||
# Long description; in case the summary is not enough to describe the change | ||
# this field accommodate a description without length limits. | ||
# NOTE: This field will be rendered only for breaking-change and known-issue kinds at the moment. | ||
#description: | ||
|
||
# Affected component; usually one of "elastic-agent", "fleet-server", "filebeat", "metricbeat", "auditbeat", "all", etc. | ||
component: | ||
|
||
# PR URL; optional; the PR number that added the changeset. | ||
# If not present is automatically filled by the tooling finding the PR where this changelog fragment has been added. | ||
# NOTE: the tooling supports backports, so it's able to fill the original PR number instead of the backport PR number. | ||
# Please provide it if you are adding a fragment for a different PR. | ||
pr: 3051 | ||
|
||
# Issue URL; optional; the GitHub issue related to this changeset (either closes or is part of). | ||
# If not present is automatically filled by the tooling with the issue linked to the PR number. | ||
#issue: https://github.com/owner/repo/1234 |
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
ELASTICSEARCH_VERSION=8.12.0-c18d0d89-SNAPSHOT | ||
ELASTICSEARCH_VERSION=8.12.0-7521d760-SNAPSHOT | ||
ELASTICSEARCH_USERNAME=elastic | ||
ELASTICSEARCH_PASSWORD=changeme | ||
TEST_ELASTICSEARCH_HOSTS=localhost:9200 | ||
TEST_REMOTE_ELASTICSEARCH_HOST=localhost:9201 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -571,6 +571,74 @@ func TestInvalidateAPIKeys(t *testing.T) { | |
} | ||
} | ||
|
||
func TestInvalidateAPIKeysRemoteOutput(t *testing.T) { | ||
toRetire := []model.ToRetireAPIKeyIdsItems{{ | ||
ID: "toRetire1", | ||
Output: "remote1", | ||
}, { | ||
ID: "toRetire11", | ||
Output: "remote1", | ||
}, { | ||
ID: "toRetire2", | ||
Output: "remote2", | ||
}} | ||
|
||
bulker := ftesting.NewMockBulk() | ||
remoteBulker := ftesting.NewMockBulk() | ||
remoteBulker2 := ftesting.NewMockBulk() | ||
bulker.On("GetBulker", "remote1").Return(remoteBulker) | ||
bulker.On("GetBulker", "remote2").Return(remoteBulker2) | ||
|
||
remoteBulker.On("APIKeyInvalidate", | ||
context.Background(), []string{"toRetire1", "toRetire11"}). | ||
Return(nil) | ||
remoteBulker2.On("APIKeyInvalidate", | ||
context.Background(), []string{"toRetire2"}). | ||
Return(nil) | ||
|
||
logger := testlog.SetLogger(t) | ||
ack := &AckT{bulk: bulker} | ||
ack.invalidateAPIKeys(context.Background(), logger, toRetire, "") | ||
|
||
bulker.AssertExpectations(t) | ||
remoteBulker.AssertExpectations(t) | ||
juliaElastic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
remoteBulker2.AssertExpectations(t) | ||
} | ||
|
||
func TestInvalidateAPIKeysRemoteOutputReadFromPolicies(t *testing.T) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
toRetire := []model.ToRetireAPIKeyIdsItems{{ | ||
ID: "toRetire1", | ||
Output: "remote1", | ||
}} | ||
|
||
remoteBulker := ftesting.NewMockBulk() | ||
remoteBulker.On("APIKeyInvalidate", | ||
context.Background(), []string{"toRetire1"}). | ||
Return(nil) | ||
|
||
bulkerFn := func(t *testing.T) *ftesting.MockBulk { | ||
m := ftesting.NewMockBulk() | ||
m.On("Search", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(&es.ResultT{HitsT: es.HitsT{ | ||
Hits: []es.HitT{{ | ||
Source: []byte(`{"data":{"outputs":{"remote1":{}}}}`), | ||
}}, | ||
}}, nil).Once() | ||
|
||
m.On("CreateAndGetBulker", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(remoteBulker, false, nil) | ||
m.On("GetBulker", "remote1").Return(nil) | ||
return m | ||
} | ||
|
||
bulker := bulkerFn(t) | ||
|
||
logger := testlog.SetLogger(t) | ||
ack := &AckT{bulk: bulker} | ||
ack.invalidateAPIKeys(context.Background(), logger, toRetire, "") | ||
|
||
bulker.AssertExpectations(t) | ||
remoteBulker.AssertExpectations(t) | ||
} | ||
|
||
func TestAckHandleUpgrade(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we can't find the policy associated with an output and need to invalidate the API key, that means it's an orphaned key, right?
Should we emit a WARN log about the key for the agent being orphaned?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed to warning log