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

libbeat/idxmgmt/ilm: fix alias creation #26146

Merged
merged 2 commits into from
Jun 8, 2021
Merged

Conversation

axw
Copy link
Member

@axw axw commented Jun 4, 2021

What does this PR do?

When creating the initial index/write alias fails, don't check the status code, just check if the alias exists regardless of the error. The status code will be different (at least 400 and 500) depending on failure scenario.

Why is it important?

This fixes a bug where alias creation fails when the alias exists but points to another index, and the initial index does not exist, e.g. due to ILM deletion.

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.

How to test this PR locally

  1. Run a beat with setup.ilm.overwrite: true
  2. In Elasticsearch, force a rollover (POST /<alias>/_rollover) and delete the initial index
  3. Restart the beat; there should be no errors due to creating the write alias

Related issues

Closes #26142

When creating the initial index/write alias fails, don't
check the status code, just check if the alias exists
regardless of the error. This fixes a bug where alias
creation fails when the alias exists but points to another
index, and the initial index does not exist (e.g. due to
ILM deletion.)
@axw axw added bug v8.0.0 v7.14.0 backport-v7.13.0 Automated backport with mergify backport-v7.14.0 Automated backport with mergify v7.13.2 labels Jun 4, 2021
@axw axw requested a review from urso June 4, 2021 05:13
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Jun 4, 2021
@botelastic
Copy link

botelastic bot commented Jun 4, 2021

This pull request doesn't have a Team:<team> label.

@elasticmachine
Copy link
Collaborator

elasticmachine commented Jun 4, 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: axw commented: /test

  • Start Time: 2021-06-08T03:21:33.897+0000

  • Duration: 64 min 50 sec

  • Commit: a01ef2f

Test stats 🧪

Test Results
Failed 0
Passed 1254
Skipped 197
Total 1451

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 1254
Skipped 197
Total 1451

Copy link
Contributor

@simitt simitt left a comment

Choose a reason for hiding this comment

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

LGTM

@mergify
Copy link
Contributor

mergify bot commented Jun 7, 2021

This pull request is now in conflicts. Could you fix it? 🙏
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/

git fetch upstream
git checkout -b ilm-createalias-exists upstream/ilm-createalias-exists
git merge upstream/master
git push upstream ilm-createalias-exists

@axw
Copy link
Member Author

axw commented Jun 8, 2021

@Mergifyio update

@mergify
Copy link
Contributor

mergify bot commented Jun 8, 2021

Command update: success

Branch already up to date

@axw
Copy link
Member Author

axw commented Jun 8, 2021

/test

@axw axw merged commit 7bd96c2 into elastic:master Jun 8, 2021
@axw axw deleted the ilm-createalias-exists branch June 8, 2021 04:26
mergify bot pushed a commit that referenced this pull request Jun 8, 2021
When creating the initial index/write alias fails, don't
check the status code, just check if the alias exists
regardless of the error. This fixes a bug where alias
creation fails when the alias exists but points to another
index, and the initial index does not exist (e.g. due to
ILM deletion.)

(cherry picked from commit 7bd96c2)
mergify bot pushed a commit that referenced this pull request Jun 8, 2021
When creating the initial index/write alias fails, don't
check the status code, just check if the alias exists
regardless of the error. This fixes a bug where alias
creation fails when the alias exists but points to another
index, and the initial index does not exist (e.g. due to
ILM deletion.)

(cherry picked from commit 7bd96c2)
axw added a commit that referenced this pull request Jun 8, 2021
* libbeat/idxmgmt/ilm: fix alias creation (#26146)

When creating the initial index/write alias fails, don't
check the status code, just check if the alias exists
regardless of the error. This fixes a bug where alias
creation fails when the alias exists but points to another
index, and the initial index does not exist (e.g. due to
ILM deletion.)

(cherry picked from commit 7bd96c2)

* Apply suggestions from code review

Co-authored-by: Andrew Wilkins <axw@elastic.co>
axw added a commit that referenced this pull request Jun 8, 2021
* libbeat/idxmgmt/ilm: fix alias creation (#26146)

When creating the initial index/write alias fails, don't
check the status code, just check if the alias exists
regardless of the error. This fixes a bug where alias
creation fails when the alias exists but points to another
index, and the initial index does not exist (e.g. due to
ILM deletion.)

(cherry picked from commit 7bd96c2)

* Update CHANGELOG.next.asciidoc

Co-authored-by: Andrew Wilkins <axw@elastic.co>
mdelapenya added a commit to mdelapenya/beats that referenced this pull request Jun 21, 2021
* master: (26 commits)
  Report total and free CPU for vSphere virtual machines (elastic#26167)
  [filebeat] Add preserve_original_event option to o365audit input (elastic#26273)
  Change xml processor names in script processor to match convention (elastic#26263)
  [Oracle] Fixing default values for paths in config template (elastic#26276)
  Add more ECS fields to logs (elastic#25998)
  [Heartbeat] Fix broken invocation of synth package (elastic#26228)
  rename sqs file name (elastic#26227)
  Populate the agent action result if there is no matching action handlers (elastic#26152)
  Add ISO8601 as supported timestamp type (elastic#25564)
  Move Filebeat azure module to GA (elastic#26168)
  Filebeat azure module pipeline fixes and changes (elastic#26148)
  libbeat: monitor version (elastic#26214)
  Add new parser to filestream input: container (elastic#26115)
  [Metricbeat] Add state_statefulset replicas.ready (elastic#26088)
  Disable test processors system test for windows 10 (elastic#26216)
  Fix startup with failing configuration (elastic#26126)
  Remove 32 bits version of Elastic Agent. (elastic#25708)
  Chane fleetmode detection to ony use management.enabled (elastic#26180)
  Make `filestream` input GA (elastic#26127)
  libbeat/idxmgmt/ilm: fix alias creation (elastic#26146)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-v7.13.0 Automated backport with mergify backport-v7.14.0 Automated backport with mergify bug needs_team Indicates that the issue/PR needs a Team:* label v7.13.2 v7.14.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

libbeat/idxmgmt: alias creation fails when setup.ilm.overwrite: true and alias exists
4 participants