-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
base: master
Are you sure you want to change the base?
Conversation
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. |
@shreemaan-abhishek PTAL |
@@ -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 = {} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems like unrelated change.
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why remove this line?
There was a problem hiding this comment.
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.
@shreemaan-abhishek Thanks for your advice! I have updated my PR and I would like to explain it again that since we can disable |
@shreemaan-abhishek The lint CI has been fixed. The other two test cases' failures seems unrelated. Please review. |
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. |
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. |
@Baoyuantop I can't reopen it, maybe need a new PR. |
@Baoyuantop Two checks are failing, but they don’t appear to be related to this PR. |
Please merge master branch. |
done, please review @Baoyuantop |
@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. |
Hi @flearc, can you merge the latest master branch? |
@Baoyuantop done |
@Baoyuantop |
Hi @Baoyuantop, the tests have passed. Could you please assign additional reviewers for further review and merge? |
Description
Fixes #11309
Checklist