# Elasticsearch IndexLifecycleRunner part of source code, log level Setting is not appropriate?

**URL:** <https://discuss.elastic.co/t/elasticsearch-indexlifecyclerunner-part-of-source-code-log-level-setting-is-not-appropriate/332542>\
**Category:** Elasticsearch\
**Tags:** ilm-index-lifecycle-management\
**Created:** [May 4, 2023, 11:11am UTC](https://discuss.elastic.co/t/elasticsearch-indexlifecyclerunner-part-of-source-code-log-level-setting-is-not-appropriate/332542 "2023-05-04T11:11:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![yujie\_wang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yujie_wang/32/120620_2.png) [@yujie\_wang](https://discuss.elastic.co/u/yujie_wang)\
**Post date:** [May 4, 2023, 11:11am UTC](https://discuss.elastic.co/t/elasticsearch-indexlifecyclerunner-part-of-source-code-log-level-setting-is-not-appropriate/332542/1 "2023-05-04T11:11:38Z")

</div>

Hi,  
Recently, I've been reading the source code of the latest version (8.7.1) of Elasticsearch and I have a question about the log level settings that I can't figure out.  
I noticed that the "current step [{}] for index [{}] with policy [{}] is not recognized" issue in runPolicyAfterStateChange function and runPeriodicStep function in Elasticsearch/xpack/ilm/IndexLifecycleRunner.java are logged as an error level:

```auto
if (currentStep == null) {
            if (stepRegistry.policyExists(policy) == false) {
                markPolicyDoesNotExist(policy, indexMetadata.getIndex(), lifecycleState);
                return;
            } else {
                Step.StepKey currentStepKey = Step.getCurrentStepKey(lifecycleState);
                if (TerminalPolicyStep.KEY.equals(currentStepKey)) {
                    // This index is a leftover from before we halted execution on the final phase
                    // instead of going to the completed phase, so it's okay to ignore this index
                    // for now
                    return;
                }
                logger.error("current step [{}] for index [{}] with policy [{}] is not recognized", currentStepKey, index, policy);
                return;
            }
        }

```

but in the same java file as above, the same issue in runPeriodicStep function is logged as a warn level：

```auto
 if (currentStep == null) {
            Step.StepKey currentStepKey = Step.getCurrentStepKey(lifecycleState);
            if (TerminalPolicyStep.KEY.equals(currentStepKey)) {
                // This index is a leftover from before we halted execution on the final phase
                // instead of going to the completed phase, so it's okay to ignore this index
                // for now
                return;
            }
            logger.warn("current step [{}] for index [{}] with policy [{}] is not recognized", currentStepKey, index, policy);
            return;
        }

```

After reading the context and comments, I found that the only difference in the code is "stepRegistry.policyExists(policy) == false" this condition, but I think the latter code snippet handles more cases than the former (it doesn't exclude the ==false case),so why is the log record level of the latter code snippet lower? Or does the use of warn have a different explanation here?  
thanks

---

<div class="post-metadata">

**Author:** ![yujie\_wang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yujie_wang/32/120620_2.png) [@yujie\_wang](https://discuss.elastic.co/u/yujie_wang)\
**Post date:** [May 6, 2023, 2:37am UTC](https://discuss.elastic.co/t/elasticsearch-indexlifecyclerunner-part-of-source-code-log-level-setting-is-not-appropriate/332542/2 "2023-05-06T02:37:14Z")

</div>

Does anyone have a comment?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 5, 2023, 6:00am UTC](https://discuss.elastic.co/t/elasticsearch-indexlifecyclerunner-part-of-source-code-log-level-setting-is-not-appropriate/332542/4 "2023-06-05T06:00:44Z")

</div>

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