-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
fix(log-rotate): skip access log when enable_access_log is set to false #11310
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. |
Description
Fixes #11309
Checklist