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

Improve ILM policy and alias setup log output #24480

Merged
merged 10 commits into from
Mar 26, 2021

Conversation

urso
Copy link

@urso urso commented Mar 10, 2021

  • Bug

What does this PR do?

The idxmgmt has not all 'information' to properly log the outcome of the
policy and status setup. The PR moves the reporting to the ILM package
directly, and 'unifies' the logic of EnsurePolicy and EnsureAlias.

Why is it important?

The change fixes the status reporting for the ILM and index alias setup, that is written to the logs.
With the fix one can tell if some resources have been installed, or not, depending on the actual settings in the configuration file. Before it was potentially reported that a policy/alias has been created, although the creation of the resources was disabled.

The change also updates EnsurePolicy/EnsureAlias to follow a similar pattern, which makes it a little easier to follow the code. We now allow EnsureAlias to create the first index and alias if check_exists: false and overwrite: true. If the alias already exists, no new alias will be created, as Elasticsearch will return an error.
This change in semantics fixes a setup that has ILM enabled with aforementioned settings, potentially indexing without the appropriate alias/index being setup ahead of time.

Checklist

  • My code follows the style guidelines of this project
    - [ ] I have commented my code, particularly in hard-to-understand areas
    - [ ] I have made corresponding changes to the documentation
    - [ ] I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

Related issues

@urso urso added bug Team:Elastic-Agent Label for the Agent team labels Mar 10, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/agent (Team:Agent)

@botelastic botelastic bot added needs_team Indicates that the issue/PR needs a Team:* label and removed needs_team Indicates that the issue/PR needs a Team:* label labels Mar 10, 2021
@@ -287,8 +287,9 @@ func TestDefaultSupport_Manager_EnsurePolicy(t *testing.T) {
onHasILMPolicy(testPolicy.Name).Return(true, nil),
},
},
"overwrite existing": {
"overwrite": {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test was wrong. When overwrite is enabled we ignore checkExists and always attempt to create the resource. The mock as configured checks that: HasPolicy will not be called, ILMPolicy will be created and indicates success.

urso added 2 commits March 10, 2021 20:07
The idxmgmt has not all 'information' to properly log the outcome of the
policy and status setup. The PR moves the reporting to the ILM package
directly, and 'unifies' the logic of EnsurePolicy and EnsureAlias.
@elasticmachine
Copy link
Collaborator

elasticmachine commented Mar 10, 2021

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: Pull request #24480 updated

  • Start Time: 2021-03-24T20:34:30.728+0000

  • Duration: 77 min 54 sec

  • Commit: becfee1

Test stats 🧪

Test Results
Failed 0
Passed 46425
Skipped 5104
Total 51529

Trends 🧪

Image of Build Times

Image of Tests

💚 Flaky test report

Tests succeeded.

Expand to view the summary

Test stats 🧪

Test Results
Failed 0
Passed 46425
Skipped 5104
Total 51529

CHANGELOG.next.asciidoc Outdated Show resolved Hide resolved
Copy link
Contributor

@kvch kvch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor changelog nit.

@urso urso requested a review from kvch March 24, 2021 16:23
@urso urso added the needs_backport PR is waiting to be backported to other branches. label Mar 25, 2021
@urso urso merged commit 4edc6dc into elastic:master Mar 26, 2021
@urso urso deleted the ilm-error-handling branch March 26, 2021 16:02
urso pushed a commit to urso/beats that referenced this pull request Mar 26, 2021
@urso urso added v7.13.0 and removed needs_backport PR is waiting to be backported to other branches. labels Mar 26, 2021
urso pushed a commit that referenced this pull request Mar 29, 2021
axw added a commit to axw/apm-server that referenced this pull request Apr 13, 2021
axw added a commit to elastic/apm-server that referenced this pull request Apr 13, 2021
* Update to elastic/beats@abd6a93bf275

* idxmgmt: update test due to libbeat change

See elastic/beats#24480
axw added a commit to axw/apm-server that referenced this pull request Apr 13, 2021
axw added a commit to elastic/apm-server that referenced this pull request Apr 13, 2021
bmorelli25 pushed a commit to bmorelli25/observability-docs that referenced this pull request Dec 18, 2023
* Update to elastic/beats@abd6a93bf275

* idxmgmt: update test due to libbeat change

See elastic/beats#24480
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Team:Elastic-Agent Label for the Agent team v7.13.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ILM setup misleads user when check_exists is false
3 participants