Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherry-pick #17613 to 7.7: Do not rotate log files on startup when interval is configured and rotateonstartup is disabled #17645

Merged
merged 1 commit into from
Apr 14, 2020

Conversation

kvch
Copy link
Contributor

@kvch kvch commented Apr 9, 2020

Cherry-pick of PR #17613 to 7.7 branch. Original message:

What does this PR do?

This PR modifies the interval rotator which is responsible for rotating log files of Filebeat after the specified interval. From now on rotateonstartup option is taken into account when setting up this rotator. If the option is set to false, Filebeat tries to set the lastRotate time to the log file configured. If it cannot be found, Filebeat will not attempt to set the variable. But it is not a problem, as there is no file to rotate.

If the user restarts filebeat right before it is able to rotate the first log file, it won't get rotated when Filebeat restarts. For example, the interval is set to 24h, and the user restarts Filebeat after 23 hours, the log file will not be rotated after one more hour. It will be rotated after the 24 hours of runtime has elapsed, as lastRotate is set the modification time of the file.

Why is it important?

Previously, if both logging.files.interval was configured and logging.files.rotateonstartup was disabled, Filebeat rotated output log files regardless of the rotateonstartup options.

Checklist

  • 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.next.asciidoc or CHANGELOG-developer.next.asciidoc.

…tateonstartup is disabled (elastic#17613)

## What does this PR do?

This PR modifies the interval rotator which is responsible for rotating log files of Filebeat after the specified interval. From now on `rotateonstartup` option is taken into account when setting up this rotator. If the option is set to `false`, Filebeat tries to set the `lastRotate` time to the log file configured. If it cannot be found, Filebeat will not attempt to set the variable. But it is not a problem, as there is no file to rotate.

If the user restarts filebeat right before it is able to rotate the first log file, it won't get rotated when Filebeat restarts. For example, the interval is set to 24h, and the user restarts Filebeat after 23 hours, the log file will not be rotated after one more hour. It will be rotated after the 24 hours of runtime has elapsed, as `lastRotate` is set the modification time of the file.

## Why is it important?

Previously, if both `logging.files.interval` was configured and `logging.files.rotateonstartup` was disabled, Filebeat rotated output log files regardless of the `rotateonstartup` options.
(cherry picked from commit 78fafb5)
@kvch kvch added [zube]: In Review backport Team:Services (Deprecated) Label for the former Integrations-Services team labels Apr 9, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/integrations-services (Team:Services)

Copy link
Contributor

@ycombinator ycombinator left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Backport LGTM.

@kvch kvch merged commit 6176cf1 into elastic:7.7 Apr 14, 2020
leweafan pushed a commit to leweafan/beats that referenced this pull request Apr 28, 2023
…tateonstartup is disabled (elastic#17613) (elastic#17645)

## What does this PR do?

This PR modifies the interval rotator which is responsible for rotating log files of Filebeat after the specified interval. From now on `rotateonstartup` option is taken into account when setting up this rotator. If the option is set to `false`, Filebeat tries to set the `lastRotate` time to the log file configured. If it cannot be found, Filebeat will not attempt to set the variable. But it is not a problem, as there is no file to rotate.

If the user restarts filebeat right before it is able to rotate the first log file, it won't get rotated when Filebeat restarts. For example, the interval is set to 24h, and the user restarts Filebeat after 23 hours, the log file will not be rotated after one more hour. It will be rotated after the 24 hours of runtime has elapsed, as `lastRotate` is set the modification time of the file.

## Why is it important?

Previously, if both `logging.files.interval` was configured and `logging.files.rotateonstartup` was disabled, Filebeat rotated output log files regardless of the `rotateonstartup` options.
(cherry picked from commit e4d9513)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport Team:Services (Deprecated) Label for the former Integrations-Services team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants