Unable to shrink index using curator

I have an action file with 7 steps.

---
actions:
  1:
    action: rollover
    description: >-
      Rollover index <index>-logs-*
    options:
      name: active-<index>-logs #Enter alias name not index name
      conditions:
        max_age: 1d
      new_index: "<index-logs-{now/d}-1>"
      extra_settings:
        index.number_of_shards: 2
        index.number_of_replicas: 1
        index.routing.allocation.include.box_type: hot
      continue_if_exception: False
      disable_action: False #True
  2:
    action: alias
    description: add search alias to all indices
    options:
      name: search-index-logs
      disable_action: False
      continue_if_exception: False #True
    add:
      filters:
        - filtertype: pattern
          kind: prefix
          value: index-logs-
  3:
    action: alias
    description: >-
      Add alias to new index and remove active index from old index
    options:
      name: active-index-logs
      disable_action: False #True
      continue_if_exception: False
    add:
      filters:
        - filtertype: pattern
          kind: prefix
          value: index-logs-
        - filtertype: age
          source: creation_date
          #timestring: '%Y.%m.%d'
          direction: younger
          unit: days
          unit_count: 1
    remove:
      filters:
        - filtertype: pattern
          kind: prefix
          value: index-logs-
        - filtertype: age
          source: creation_date
          #timestring: '%Y.%m.%d'
          direction: older
          unit: days
          unit_count: 1
  4:
    action: alias
    description: add inactive alias
    options:
      name: inactive-index-logs
      disable_action: False #True
      continue_if_exception: False
    add:
      filters:
        - filtertype: pattern
          kind: prefix
          value: index-logs-
        - filtertype: age
          source: creation_date
          #timestring: '%Y.%m.%d'
          direction: older
          unit: days
          unit_count: 1
  5:
    action: index_settings
    description: >-
      Set old indices to read-only
    options:
      disable_action: False #True
      index_settings:
        index:
          blocks:
            write: True
      continue_if_exception: False
      preserve_existing: False
      ignore_unavailable: True
    filters:
      - filtertype: alias
        aliases: inactive-index-logs
      - filtertype: age
        source: creation_date
        direction: older
        unit: days
        unit_count: 1
  6:
    action: shrink
    description: >-
      Shrink old index-indices to 1 shard
    options:
      timeout_override: 300
      disable_action: False #True
      continue_if_exception: True
      shrink_node: DETERMINISTIC
      number_of_shards: 1
      number_of_replicas: 0
      shrink_prefix: inactive-
      shrink_suffix: null
      delete_after: False
      post_allocation:
        allocation_type: include
        key: box_type
        value: hot
      wait_for_active_shards: 1
      wait_for_completion: True
      wait_for_rebalance: False
      wait_interval: 30
      extra_settings:
        settings:
          index.blocks.write: true
    filters:
      - filtertype: alias
        aliases: inactive-index-logs
      - filtertype: age
        source: creation_date
        direction: younger
        unit: days
        unit_count: 2
      - filtertype: age
        source: creation_date
        direction: older
        unit: days
        unit_count: 1
  7:
    action: delete_indices
    description: Delete inactive indexes that are more than X days old
    options:
      timeout_override: 300
      disable_action: False #True
      continue_if_exception: False
    filters:
      - filtertype: alias
        aliases: inactive-fusion-logs
      - filtertype: age
        source: creation_date
        #timestring: '%Y.%m.%d'
        direction: older
        unit: days
        unit_count: 7```

The issue is that after running step 5 where the index settings are successfully updated with `index.blocks.write: True`
In the shrink step the index setting changes to `index.blocks.write: False` .

I'm using ES 6.2.2 and Curator 5.8.

Hi @fidsamuraiCrelio,

I just checked the documentation in which it is mentioned that "Make Index read only".

As you can see the below Shrink API document where the value is assigned as null.

we can't perform any write operations once index is in shrink state.

Br,
Harsh Bajaj

@harshbajaj16
Step 5 of my action file makes all indices older than 1 day get the setting of index.blocks.write: True.

The issue is that when I run the shrink action(Step 6) for some reason it changes the setting to -
index.blocks.write: False

Using Curator just FYI

Hi @fidsamuraiCrelio ,

Yes understood and have seen in step 6 u have mentioned 1 day that's why it is changing the value from true to false.

indices are going to shrink state with write value as false because Elasticsearch shrink operation doesn't allowed us to write on shrink indices.

Br,
Harsh Bajaj

@harshbajaj16 ,

Sorry could you explain it again?

From what I understood from the doc the shrink operation will only work if we make the index read-only right?
I've provided a suffix to the new index so that it will create as inactive-index-logs-(datestamp)
In that case only the new index needs write permissions right?

Or am I missing some important step?

@harshbajaj16 ,

Okay so I went through the documentation again.
I think I understood my mistake.
In step 6(shrink) in extra_settings I'd put index.blocks.write: True instead I need to put index.blocks.write: null is that correct?

HI @fidsamuraiCrelio,

yes, Pls try to run with this configuration mentioned in document and let me know if you are facing any issue.

Br,
Harsh Bajaj

Hi @harshbajaj16,

I tried the new setting but it still doesn't work, our old index setting still changes from index.blocks.write: True to index.blocks.write: False.

Anything else I can try?

HI @fidsamuraiCrelio,

Could you pls let me know about your use case so that i can understand and update accordingly.

Br,
Harsh Bajaj

@harshbajaj16 ,

We currently use ES 6.2.2.
We're using Curator instead of ILM as that was introduced in ES 6.8+.
Steps we want to take -

  1. Rollover index everyday.
  2. Add "search" alias on all indices
  3. Remove "active" alias from rolled over index and put it on the new index.
  4. Add "inactive" alias on rolled over index.
  5. Change index setting of old index to block writes.
  6. Shrink index.
  7. Delete any indices that are older than 7 days.

Let me know if you need any further details.

Hi @harshbajaj16 !

Anything you would like me to change in the config?

Can somebody help with this issue?

I went through some other configurations and added permit_masters: True.

But now I just get the following log -

2022-04-11 09:39:19,875 INFO      GET http://172.31.1.43:9200/_all/_settings?expand_wildcards=open%2Cclosed [status:200 request:0.004s]
2022-04-11 09:39:19,877 INFO      GET http://172.31.1.43:9200/ [status:200 request:0.002s]
2022-04-11 09:39:19,893 INFO      GET http://172.31.1.43:9200/_cluster/state/metadata/.kibana,.tasks,active-activity-log,activity,activitylog,app,blog,center_comments,centreautoincrementkeys,deals,debug_issue,distinctalltests,distincttestdistance,dummy_index,facebook,fus$
2022-04-11 09:39:19,907 INFO      GET http://172.31.1.43:9200/.kibana,.tasks,active-activity-log,activity,activitylog,app,blog,center_comments,centreautoincrementkeys,deals,debug_issue,distinctalltests,distincttestdistance,dummy_index,facebook,fusion,fusion-logs-2022.03.$
2022-04-11 09:39:19,915 INFO      GET http://172.31.1.43:9200/.kibana,.tasks,active-activity-log,activity,activitylog,app,blog,center_comments,centreautoincrementkeys,deals,debug_issue,distinctalltests,distincttestdistance,dummy_index,facebook,fusion,fusion-logs-2022.03.$
2022-04-11 09:39:19,922 INFO      GET http://172.31.1.43:9200/fusion-logs-2022.04.08-1,fusion-logs-2022.04.09-1/_settings [status:200 request:0.002s]
2022-04-11 09:39:19,924 INFO      GET http://172.31.1.43:9200/ [status:200 request:0.002s]
2022-04-11 09:39:19,924 INFO      Shrinking 2 selected indices: ['fusion-logs-2022.04.08-1', 'fusion-logs-2022.04.09-1']
2022-04-11 09:39:19,924 INFO      Source index: fusion-logs-2022.04.08-1 -- Target index: inactive-fusion-logs-2022.04.08-1-shrink
2022-04-11 09:39:19,929 INFO      GET http://172.31.1.43:9200/fusion-logs-2022.04.08-1/_stats [status:200 request:0.002s]
2022-04-11 09:39:19,931 INFO      GET http://172.31.1.43:9200/fusion-logs-2022.04.08-1 [status:200 request:0.002s]
2022-04-11 09:39:19,951 INFO      GET http://172.31.1.43:9200/_nodes/stats [status:200 request:0.019s]
2022-04-11 09:39:19,953 INFO      GET http://172.31.1.43:9200/_nodes [status:200 request:0.002s]
2022-04-11 09:39:19,972 INFO      GET http://172.31.1.43:9200/_nodes/stats [status:200 request:0.019s]
2022-04-11 09:39:19,973 WARNING   Not skipping node "Vm0c4H9" which is a master node (not recommended), but permit_masters is True
2022-04-11 09:39:19,975 INFO      GET http://172.31.1.43:9200/fusion-logs-2022.04.08-1/_stats [status:200 request:0.002s]
2022-04-11 09:39:19,975 INFO      Moving shards to shrink node: "Vm0c4H9"
2022-04-11 09:39:19,987 INFO      PUT http://172.31.1.43:9200/fusion-logs-2022.04.08-1/_settings [status:200 request:0.012s]
2022-04-11 09:39:19,991 INFO      GET http://172.31.1.43:9200/_cluster/state/_all/fusion-logs-2022.04.08-1 [status:200 request:0.003s]
2022-04-11 09:39:50,018 INFO      GET http://172.31.1.43:9200/_cluster/state/_all/fusion-logs-2022.04.08-1 [status:200 request:0.003s]
2022-04-11 09:40:20,051 INFO      GET http://172.31.1.43:9200/_cluster/state/_all/fusion-logs-2022.04.08-1 [status:200 request:0.003s]
2022-04-11 09:40:50,057 INFO      GET http://172.31.1.43:9200/_cluster/state/_all/fusion-logs-2022.04.08-1 [status:200 request:0.003s]
2022-04-11 09:41:20,069 INFO      GET http://172.31.1.43:9200/_cluster/state/_all/fusion-logs-2022.04.08-1 [status:200 request:0.003s]
2022-04-11 09:41:50,102 INFO      GET http://172.31.1.43:9200/_cluster/state/_all/fusion-logs-2022.04.08-1 [status:200 request:0.003s]
2022-04-11 09:42:20,135 INFO      GET http://172.31.1.43:9200/_cluster/state/_all/fusion-logs-2022.04.08-1 [status:200 request:0.003s]
2022-04-11 09:42:50,169 INFO      GET http://172.31.1.43:9200/_cluster/state/_all/fusion-logs-2022.04.08-1 [status:200 request:0.003s]
2022-04-11 09:43:20,202 INFO      GET http://172.31.1.43:9200/_cluster/state/_all/fusion-logs-2022.04.08-1 [status:200 request:0.003s]
2022-04-11 09:43:50,235 INFO      GET http://172.31.1.43:9200/_cluster/state/_all/fusion-logs-2022.04.08-1 [status:200 request:0.003s]
2022-04-11 09:44:20,242 INFO      GET http://172.31.1.43:9200/_cluster/state/_all/fusion-logs-2022.04.08-1 [status:200 request:0.003s]
2022-04-11 09:44:50,275 INFO      GET http://172.31.1.43:9200/_cluster/state/_all/fusion-logs-2022.04.08-1 [status:200 request:0.003s]
2022-04-11 09:45:20,317 INFO      GET http://172.31.1.43:9200/_cluster/state/_all/fusion-logs-2022.04.08-1 [status:200 request:0.011s]
2022-04-11 09:45:50,345 INFO      GET http://172.31.1.43:9200/_cluster/state/_all/fusion-logs-2022.04.08-1 [status:200 request:0.003s]
2022-04-11 09:46:20,379 INFO      GET http://172.31.1.43:9200/_cluster/state/_all/fusion-logs-2022.04.08-1 [status:200 request:0.003s]
2022-04-11 09:46:50,388 INFO      GET http://172.31.1.43:9200/_cluster/state/_all/fusion-logs-2022.04.08-1 [status:200 request:0.003s]
2022-04-11 09:47:20,394 INFO      GET http://172.31.1.43:9200/_cluster/state/_all/fusion-logs-2022.04.08-1 [status:200 request:0.003s]
2022-04-11 09:47:50,428 INFO      GET http://172.31.1.43:9200/_cluster/state/_all/fusion-logs-2022.04.08-1 [status:200 request:0.003s]
2022-04-11 09:48:20,462 INFO      GET http://172.31.1.43:9200/_cluster/state/_all/fusion-logs-2022.04.08-1 [status:200 request:0.003s]
2022-04-11 09:48:50,493 INFO      GET http://172.31.1.43:9200/_cluster/state/_all/fusion-logs-2022.04.08-1 [status:200 request:0.003s]
2022-04-11 09:49:20,505 INFO      GET http://172.31.1.43:9200/_cluster/state/_all/fusion-logs-2022.04.08-1 [status:200 request:0.003s]
2022-04-11 09:49:50,523 INFO      GET http://172.31.1.43:9200/_cluster/state/_all/fusion-logs-2022.04.08-1 [status:200 request:0.003s]
2022-04-11 09:50:20,556 INFO      GET http://172.31.1.43:9200/_cluster/state/_all/fusion-logs-2022.04.08-1 [status:200 request:0.003s]
2022-04-11 09:50:50,585 INFO      GET http://172.31.1.43:9200/_cluster/state/_all/fusion-logs-2022.04.08-1 [status:200 request:0.003s]
2022-04-11 09:51:20,618 INFO      GET http://172.31.1.43:9200/_cluster/state/_all/fusion-logs-2022.04.08-1 [status:200 request:0.003s]
2022-04-11 09:51:50,652 INFO      GET http://172.31.1.43:9200/_cluster/state/_all/fusion-logs-2022.04.08-1 [status:200 request:0.003s]
2022-04-11 09:52:20,676 INFO      GET http://172.31.1.43:9200/_cluster/state/_all/fusion-logs-2022.04.08-1 [status:200 request:0.003s]
2022-04-11 09:52:50,706 INFO      GET http://172.31.1.43:9200/_cluster/state/_all/fusion-logs-2022.04.08-1 [status:200 request:0.003s]```

Can anyone help?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.