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

help request: I use enable_compression in log-rotate plugin, but apisix did not delete the original access log #9819

Closed
iamacnhero opened this issue Jul 12, 2023 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@iamacnhero
Copy link

Description

I configged in config.yml like this:

plugin_attr:
  log-rotate:
      interval: 86400             # rotate interval (unit: second)
      max_kept: 30                # max number of log files will be kept
      max_size: -1                # max size of log files will be kept
      enable_compression: true    # enable log file compression(gzip) or not, default false

but the original log does not deleted:

image

why? how should I fix this ?

Environment

  • APISIX version: 3.0.0
  • Operating system: Ubuntu SMP Fri Nov 5 16:31:28 UTC 2021 x86_64 GNU/Linux
  • OpenResty / Nginx version: openresty/1.21.4.1
  • etcd version: 3.5.9
  • Plugin runner version, for issues related to plugin runners: log-rotate
@jiangfucheng
Copy link
Member

local ok, stdout, stderr, reason, status = shell.run(cmd)
if not ok then
core.log.error("compress log file from ", new_filename, " to ", com_filename,
" fail, stdout: ", stdout, " stderr: ", stderr, " reason: ", reason,
" status: ", status)
return
end
ok, stderr = os_remove(new_file)
if stderr then
core.log.error("remove uncompressed log file: ", new_file,
" fail, err: ", stderr, " res:", ok)
end

It seems cause by that the log file too large cause compress command timeout and then return immediately, not remove origin file. Maybe we can increase the timeout of shell.run() method, I'm not sure if this will lead other issues. Let's listen to the opinions of others.

@iamacnhero
Copy link
Author

Indeed, the compression timed out. below is the error.log

2023/07/11 00:00:11 [error] 52#52: *45898080 [lua] log-rotate.lua:186: compression_file(): compress log file from 2023-07-11_00-00-00__access.log to 2023-07-11_00-00-00__access.log.tar.gz fail, stdout: stderr: reason: failed to wait for process: timeout status: nil, context: ngx.timer

@alptugay
Copy link
Contributor

#8620
I've created a pull request for this but is now stale. It will solve your problem

@shreemaan-abhishek
Copy link
Contributor

shreemaan-abhishek commented Jul 14, 2023

@alptugay the PR has been reopened, I have left review comments let's get this merged. 🔥

@leslie-tsang leslie-tsang moved this to 📋 Backlog in Apache APISIX backlog Jul 20, 2023
@leslie-tsang leslie-tsang added the bug Something isn't working label Jul 20, 2023
@leslie-tsang leslie-tsang moved this from 📋 Backlog to 🏗 In progress in Apache APISIX backlog Jul 20, 2023
@leslie-tsang leslie-tsang moved this from 🏗 In progress to 👀 In review in Apache APISIX backlog Jul 20, 2023
@shreemaan-abhishek shreemaan-abhishek moved this from 👀 In review to 📋 Backlog in Apache APISIX backlog Sep 5, 2023
@shreemaan-abhishek
Copy link
Contributor

fixed by #8620

@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in Apache APISIX backlog Nov 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

No branches or pull requests

5 participants