This commit is contained in:
reyesj2
2025-11-21 16:04:26 -06:00
parent b80ec95fa8
commit 415ea07a4f

View File

@@ -64,88 +64,51 @@
{# advanced ilm actions #} {# advanced ilm actions #}
{% if settings.policy is defined and settings.policy.phases is defined %} {% if settings.policy is defined and settings.policy.phases is defined %}
{# start HOT actions #} {% set PHASE_NAMES = ["hot", "warm", "cold"] %}
{# only run if hot action is defined for this index #} {% for P in PHASE_NAMES %}
{% if settings.policy.phases.hot is defined and settings.policy.phases.hot.actions is defined %} {% if settings.policy.phases[P] is defined and settings.policy.phases[P].actions is defined %}
{% set HA = settings.policy.phases.hot.actions %} {% set PHASE = settings.policy.phases[P].actions %}
{% if HA.shrink is defined %} {# remove allocate action if number_of_replicas isn't configured #}
{% if HA.shrink.method is defined %} {% if PHASE.allocate is defined %}
{% if HA.shrink.method == 'COUNT' and HA.shrink.number_of_shards is defined and HA.shrink.number_of_shards %} {% if PHASE.allocate.number_of_replicas is defined and not PHASE.allocate.number_of_replicas %}
{% do PHASE.pop('allocate', none) %}
{% endif %}
{% endif %}
{# start shrink action #}
{% if PHASE.shrink is defined %}
{% if PHASE.shrink.method is defined %}
{% if PHASE.shrink.method == 'COUNT' and PHASE.shrink.number_of_shards is defined and PHASE.shrink.number_of_shards %}
{# remove max_primary_shard_size value when doing shrink operation by count vs size #} {# remove max_primary_shard_size value when doing shrink operation by count vs size #}
{% do HA.shrink.pop('max_primary_shard_size', none) %} {% do PHASE.shrink.pop('max_primary_shard_size', none) %}
{% elif HA.shrink.method == 'SIZE' and HA.shrink.max_primary_shard_size is defined and HA.shrink.max_primary_shard_size %} {% elif PHASE.shrink.method == 'SIZE' and PHASE.shrink.max_primary_shard_size is defined and PHASE.shrink.max_primary_shard_size %}
{# remove number_of_shards value when doing shrink operation by size vs count #} {# remove number_of_shards value when doing shrink operation by size vs count #}
{% do HA.shrink.pop('number_of_shards', none) %} {% do PHASE.shrink.pop('number_of_shards', none) %}
{% else %} {% else %}
{# method isn't defined or missing a required config number_of_shards/max_primary_shard_size #} {# method isn't defined or missing a required config number_of_shards/max_primary_shard_size #}
{% do HA.pop('shrink', none) %} {% do PHASE.pop('shrink', none) %}
{% endif %} {% endif %}
{% endif %} {% endif %}
{% endif %} {% endif %}
{# always remove method since its only used for SOC config, not in the actual ilm policy #} {# always remove shrink method since its only used for SOC config, not in the actual ilm policy #}
{% if HA.shrink is defined %} {% if PHASE.shrink is defined %}
{% do HA.shrink.pop('method', none) %} {% do PHASE.shrink.pop('method', none) %}
{% endif %} {% endif %}
{# end shrink action #} {# end shrink action #}
{# start force merge #} {# start force merge #}
{% if HA.forcemerge is defined %} {% if PHASE.forcemerge is defined %}
{% if HA.forcemerge.index_codec is defined and HA.forcemerge.index_codec %} {% if PHASE.forcemerge.index_codec is defined and PHASE.forcemerge.index_codec %}
{% do HA.forcemerge.update({'index_codec': 'best_compression'}) %} {% do PHASE.forcemerge.update({'index_codec': 'best_compression'}) %}
{% else %} {% else %}
{% do HA.forcemerge.pop('index_codec', none) %} {% do PHASE.forcemerge.pop('index_codec', none) %}
{% endif %} {% endif %}
{% if HA.forcemerge.max_num_segments is defined and not HA.forcemerge.max_num_segments %} {% if PHASE.forcemerge.max_num_segments is defined and not PHASE.forcemerge.max_num_segments %}
{# max_num_segments is empty, drop it #} {# max_num_segments is empty, drop it #}
{% do HA.pop('forcemerge', none) %} {% do PHASE.pop('forcemerge', none) %}
{% endif %} {% endif %}
{% endif %} {% endif %}
{# end force merge #} {# end force merge #}
{% endif %} {% endif %}
{# end HOT actions #} {% endfor %}
{# Start WARM actions #}
{# only run if warm action is defined for this index #}
{% if settings.policy.phases.warm is defined and settings.policy.phases.warm.actions is defined %}
{% set WA = settings.policy.phases.warm.actions %}
{# start warm shrink action #}
{% if WA.shrink is defined %}
{% if WA.shrink.method is defined %}
{% if WA.shrink.method == 'COUNT' and WA.shrink.number_of_shards is defined and WA.shrink.number_of_shards %}
{# remove max_primary_shard_size value when doing shrink operation by count vs size #}
{% do WA.shrink.pop('max_primary_shard_size', none) %}
{% elif WA.shrink.method == 'SIZE' and WA.shrink.max_primary_shard_size is defined and WA.shrink.max_primary_shard_size %}
{# remove number_of_shards value when doing shrink operation by size vs count #}
{% do WA.shrink.pop('number_of_shards', none) %}
{% else %}
{# method isn't defined or missing a required config number_of_shards/max_primary_shard_size #}
{% do WA.pop('shrink', none) %}
{% endif %}
{% endif %}
{% endif %}
{# always remove method since its only used for SOC config, not in the actual ilm policy #}
{% if WA.shrink is defined %}
{% do WA.shrink.pop('method', none) %}
{% endif %}
{# end shrink action #}
{# start force merge #}
{% if WA.forcemerge is defined %}
{% if WA.forcemerge.index_codec is defined and WA.forcemerge.index_codec %}
{% do WA.forcemerge.update({'index_codec': 'best_compression'}) %}
{% else %}
{% do WA.forcemerge.pop('index_codec', none) %}
{% endif %}
{% if WA.forcemerge.max_num_segments is defined and not WA.forcemerge.max_num_segments %}
{# max_num_segments is empty, drop it #}
{% do WA.pop('forcemerge', none) %}
{% endif %}
{% endif %}
{# end force merge #}
{% if WA.allocate is defined %}
{% if WA.allocate.number_of_replicas is defined and not WA.allocate.number_of_replicas %}
{% do WA.pop('allocate', none) %}
{% endif %}
{% endif %}
{% endif %}
{# end WARM actions #}
{% endif %} {% endif %}
{% do ES_INDEX_SETTINGS.update({index | replace("_x_", "."): ES_INDEX_SETTINGS_GLOBAL_OVERRIDES[index]}) %} {% do ES_INDEX_SETTINGS.update({index | replace("_x_", "."): ES_INDEX_SETTINGS_GLOBAL_OVERRIDES[index]}) %}