Skip to content

[ILM] set policy for index API does not work if index is on complete step for a phase #34302

@colings86

Description

@colings86

Steps to reproduce:

  1. Create two policies:
PUT _ilm/my_lifecycle2
{
  "policy": {
    "phases": {
      "hot": {
        "actions": {
          "rollover": {
            "max_age": "30s"
          }
        }
      },
      "warm": {
        "actions": {
          "forcemerge": {
            "max_num_segments": 1
          },
          "allocate": {
            "number_of_replicas": 1
          }
        }
      },
      "delete": {
        "minimum_age": "2m",
        "actions": {
          "delete": {}
        }
      }
    }
  }
}

PUT _ilm/my_lifecycle3
{
  "policy": {
    "phases": {
      "hot": {
        "actions": {
          "rollover": {
            "max_age": "30s"
          }
        }
      },
      "warm": {
        "actions": {
          "forcemerge": {
            "max_num_segments": 1
          },
          "allocate": {
            "number_of_replicas": 1
          }
        }
      },
      "delete": {
        "minimum_age": "2m",
        "actions": {
          "delete": {}
        }
      }
    }
  }
}
  1. Create an index template and an index for the policies using my_lifecycle3:
PUT _template/my_template
{
  "index_patterns": ["test-*"],
  "settings": {
    "number_of_shards": 2,
    "number_of_replicas": 0,
    "index.lifecycle.name": "my_lifecycle3",
    "index.lifecycle.rollover_alias": "test-alias"
  }
}

PUT test-000001
{
  "aliases": {
    "test-alias":{
      "is_write_index": true
    }
  }
}
  1. Wait for the test-000001 index to complete all actions in the warm phase
  2. Try to move test-000001 to use my_lifecycle2:
PUT test-000001/_ilm/my_lifecycle2
  1. Observe error response:
{
  "error": {
    "root_cause": [
      {
        "type": "illegal_argument_exception",
        "reason": "[complete] is not a valid action for phase [warm] in lifecycle type [timeseries]"
      }
    ],
    "type": "illegal_argument_exception",
    "reason": "[complete] is not a valid action for phase [warm] in lifecycle type [timeseries]"
  },
  "status": 400
}

Maybe we should go back to letting users set the index.lifecycle.name setting on the update settings API now that there are no restrictions on when the policy can be changed on an index?

Metadata

Metadata

Labels

:Data Management/ILM+SLMDO NOT USE. Use ":StorageEngine/ILM" or ":Distributed Coordination/SLM" instead.>bugblocker

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions