Skip to content

Fix continuous container restarts after Fleet policy updates#15772

Draft
samuelvl wants to merge 1 commit into
elastic:mainfrom
samuelvl:fix-infinity-loop-container-logging
Draft

Fix continuous container restarts after Fleet policy updates#15772
samuelvl wants to merge 1 commit into
elastic:mainfrom
samuelvl:fix-infinity-loop-container-logging

Conversation

@samuelvl

@samuelvl samuelvl commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes an infinite restart loop in container deployments after a Fleet logging policy update.

Containers without LOGS_PATH start with logging directed to stderr:

agent.logging:
  to_stderr: true
  to_files: false

The policy handler used NewFromConfig for checking configuration changes, which starts with the normal file-logging defaults before applying the policy:

cfg := DefaultConfiguration()  // to_files=true, to_stderr=false
policy.UnpackTo(cfg)           // level=debug

The handler then compared these values with the current container settings:

current:  to_files=false, to_stderr=true
incoming: to_files=true,  to_stderr=false

The agent reconciled the logging change and restarted. After the restart, container logging went back to stderr and the same policy caused another restart.

The solution is using the container logging settings as the baseline for each Fleet policy update. Fleet values override that baseline only when they are explicitly provided.

Why is it important?

It prevents containers from restarting indefinitely after a normal Fleet policy update.

Checklist

  • I have read and understood the pull request guidelines of this project.
  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • [ ] I have made corresponding changes to the documentation
  • [ ] I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in ./changelog/fragments using the changelog tool
  • I have added an integration test or an E2E test

Disruptive User Impact

None expected. Existing container logging settings are preserved unless Fleet explicitly changes them.

How to test this PR locally

Run the following integration test locally:

BUILD_AGENT=true EXTERNAL=true PACKAGES="tar.gz" TEST_PACKAGES="tar.gz" \
  mage -v integration:local TestLoggingFilePathChangedViaFleet

Related issues

@samuelvl samuelvl added bug Something isn't working Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team backport-9.4 Automated backport to the 9.4 branch labels Jul 23, 2026
@infra-vault-gh-plugin-prod

infra-vault-gh-plugin-prod Bot commented Jul 23, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-9.4 Automated backport to the 9.4 branch bug Something isn't working Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Infinity reboot agent 9.4.3

1 participant