Skip to content

fix(log-rotate): skip access log when enable_access_log is set to false #11310

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

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

flearc
Copy link
Contributor

@flearc flearc commented May 31, 2024

Description

Fixes #11309

Checklist

  • I have explained the need for this PR and the problem it solves
  • I have explained the changes or the new features added to this PR
  • I have added tests corresponding to this change
  • I have updated the documentation to reflect this change
  • I have verified that this change is backward compatible (If not, please discuss on the APISIX mailing list first)

@flearc flearc changed the title fix(log-rotate): skip access log when enable_access_log is set to false WIP: fix(log-rotate): skip access log when enable_access_log is set to false May 31, 2024
@flearc flearc changed the title WIP: fix(log-rotate): skip access log when enable_access_log is set to false fix(log-rotate): skip access log when enable_access_log is set to false Jun 7, 2024
Copy link

This pull request has been marked as stale due to 60 days of inactivity. It will be closed in 4 weeks if no further activity occurs. If you think that's incorrect or this pull request should instead be reviewed, please simply write any comment. Even if closed, you can still revive the PR at any time or discuss it on the dev@apisix.apache.org list. Thank you for your contributions.

@github-actions github-actions bot added the stale label Sep 17, 2024
@flearc
Copy link
Contributor Author

flearc commented Sep 17, 2024

@shreemaan-abhishek PTAL

@github-actions github-actions bot removed the stale label Sep 18, 2024
@@ -299,9 +303,9 @@ local function rotate()
elseif max_size > 0 then
local access_log_file_size = file_size(default_logs[DEFAULT_ACCESS_LOG_FILENAME].file)
local error_log_file_size = file_size(default_logs[DEFAULT_ERROR_LOG_FILENAME].file)
local files = core.table.new(2, 0)
local files = {}
Copy link
Contributor

Choose a reason for hiding this comment

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

why make this change? It seems unrelated to me. If it really is, you should remove it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same that no need to pre-allocate. It only needs to store one filename when enable_access_log is false.

@@ -210,7 +210,7 @@ local function rotate_file(files, now_time, max_kept, timeout)
return
end

local new_files = core.table.new(2, 0)
local new_files = core.table.new(#files, 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

seems like unrelated change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

new_files stores the name of access.log and error.log. If enable_access_log is set to false, nginx will not generate access.log file, no need to pre-allocate an array of length 2.

@@ -76,7 +77,6 @@ end


local function get_log_path_info(file_type)
local_conf = core.config.local_conf()
Copy link
Contributor

Choose a reason for hiding this comment

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

why remove this line?

Copy link
Contributor Author

@flearc flearc Sep 29, 2024

Choose a reason for hiding this comment

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

local_conf is initialized in the init function now.

@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Sep 29, 2024
@flearc
Copy link
Contributor Author

flearc commented Sep 29, 2024

@shreemaan-abhishek Thanks for your advice! I have updated my PR and I would like to explain it again that since we can disable access.log by setting enable_access_log to false, the length of files and new_files is not guaranteed to be 2. So I adjusted the logic here.

@flearc
Copy link
Contributor Author

flearc commented Oct 8, 2024

@shreemaan-abhishek The lint CI has been fixed. The other two test cases' failures seems unrelated. Please review.

Copy link

This pull request has been marked as stale due to 60 days of inactivity. It will be closed in 4 weeks if no further activity occurs. If you think that's incorrect or this pull request should instead be reviewed, please simply write any comment. Even if closed, you can still revive the PR at any time or discuss it on the dev@apisix.apache.org list. Thank you for your contributions.

@github-actions github-actions bot added the stale label Dec 16, 2024
Copy link

This pull request/issue has been closed due to lack of activity. If you think that is incorrect, or the pull request requires review, you can revive the PR at any time.

@github-actions github-actions bot closed this Jan 24, 2025
@flearc
Copy link
Contributor Author

flearc commented May 16, 2025

@Baoyuantop I can't reopen it, maybe need a new PR.

@Baoyuantop Baoyuantop reopened this May 19, 2025
@github-actions github-actions bot removed the stale label May 19, 2025
@flearc
Copy link
Contributor Author

flearc commented May 20, 2025

@Baoyuantop Two checks are failing, but they don’t appear to be related to this PR.

@Baoyuantop
Copy link
Contributor

Please merge master branch.

@flearc
Copy link
Contributor Author

flearc commented May 20, 2025

Please merge master branch.

done, please review @Baoyuantop

@flearc
Copy link
Contributor Author

flearc commented May 26, 2025

@Baoyuantop The failing CI test is not related to the changes in this PR, and I've verified that the same failure exists in the latest several commits on master, it needs to be addressed in a separate PR.

@Baoyuantop
Copy link
Contributor

Hi @flearc, can you merge the latest master branch?

@flearc
Copy link
Contributor Author

flearc commented Jun 9, 2025

Hi @flearc, can you merge the latest master branch?

@Baoyuantop done

@flearc
Copy link
Contributor Author

flearc commented Jun 13, 2025

@Baoyuantop
The t/plugin/request-id.t test failed in CI, but I couldn’t reproduce it locally. I believe the failure is not related to the changes in this PR. Could you please help check what might have caused it?

@flearc
Copy link
Contributor Author

flearc commented Jun 17, 2025

Hi @Baoyuantop, the tests have passed. Could you please assign additional reviewers for further review and merge?

@Baoyuantop Baoyuantop self-requested a review June 17, 2025 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size:M This PR changes 30-99 lines, ignoring generated files.
Projects
Status: 👀 In review
Development

Successfully merging this pull request may close these issues.

bug: log-rotate plugin should not rotate the access log when the enable_access_log setting is set to false
3 participants