Skip to content

[BUG] copyAlias() throws exception #1488

@tender-barbarian

Description

@tender-barbarian

What is the bug?
If index is a part of only a single alias, which also happens to be rollover_alias, and copy_alias param is used in ISM policy targeting that index, then error message is produced.

How can one reproduce the bug?
Steps to reproduce the behavior:

Basically follow steps in below documentation but during ISM policy creation, add copy_alias to rollover action:
https://docs.opensearch.org/latest/im-plugin/ism/policies/#sample-policy-with-ism-template-for-auto-rollover

Then observe following error:

"component": "o.o.i.i.s.r.AttemptRolloverStep
"Successfully rolled over but failed to copy alias from [index=test-000001] to [index=test-000002]",
"org.opensearch.action.ActionRequestValidationException: Validation Failed: 1: Must specify at least one alias action;",

What is the expected behavior?
Rollover happens without errors.

What is your host/environment?

  • Version 2.19.1

Do you have any additional context?
I believe the issue is here: https://github.com/opensearch-project/index-management/blob/main/src/main/kotlin/org/opensearch/indexmanagement/indexstatemanagement/step/rollover/AttemptRolloverStep.kt#L318

If index is a part of only a single alias, which also happens to be rollover_alias, this loop will exit without filling aliasActions, which is then used to call Alias API and thus Validation Failed: 1: Must specify at least one alias action error is produced.

The fix is very simple - after the loop is finished, check whether aliasActions is empty. Linked PR implements said fix.

DISCLAIMER
One could argue that using copy_alias param in ISM policy for such index is wrong. But we do it because our policy targets indexes under the same namespace - some of which belong to a single alias (of itself) while others belong to multiple (of itself and group). I don't want to create a separate policy without copy_alias because that would require redesigning whole index namespace schema. And if that argument is not convincing enough, then IMHO it's just good practice to check wether array actually contains something before using it in a call which requires it :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions