-
Notifications
You must be signed in to change notification settings - Fork 543
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
[container_log] Get rotated logs #3678
Conversation
Congratulations! One of the builds has completed. 🍾 You can install the built RPMs by following these steps:
Please note that the RPMs should be used only in a testing environment. |
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.
Thanks @Akrog
+1 on this change, thank you @Akrog |
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.
I don't like the idea of adding yet another "get logs for containers" plugin from the start. On top of that though, this should be an addition to the openshift
and kubernetes
plugins as a simple add_copy_spec()
using the existing maxage
parameter.
If the rotated logs are written to disk, there's no reason the openshift
plugin can't just collect those outside of the oc logs
command.
Makes sense not adding yet another plugin. Would it be ok to add it as an option to the I'm saying it because that plugin is already getting |
well done, thanks a lot! |
Yeah, that makes sense. |
@Akrog can you squash these two commits into one please? |
@jcastill Done. I usually try to do 1 thing on each patch, but each project is different. :-) |
sos/report/plugins/container_log.py
Outdated
# Remove size limit from containers logs when getting rotated, since | ||
# they are just symlinks to the pods logs |
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.
Our sizelimiting takes the link's destination into account when checking sizes for collections, so I'm not sure what the desire is here? We definitely do not want to have a wide open "collect all logs regardless of sizes" default posture here. We've had that bite us in the rear in the past several times - no one likes several GB sos reports.
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.
I tried, and failed, to explain it in the PR description.
The idea is that if you set the rotated
option but you don't change the limits at all you are going to either get the exact same content as without the option (because like you said getting the symlinks checks the actual destination files) or we are going to get logs from the pods that don't have a symlink (not necessarily rotated logs), in both cases it seems wrong.
Another option is for the rotated
option to ignore all the .log
files from the pods directory and only get rotated logs instead.
This later options sounds reasonable to me and in line with the option name. I'll update the PR.
sos/report/plugins/container_log.py
Outdated
def collect_subdirs(self, root=logdir, sizelimit=None, maxage=None): | ||
"""Collect *.log files from subdirs of passed root path | ||
""" | ||
for dir_name, _, _ in os.walk(root): | ||
self.add_copy_spec(self.path_join(dir_name, '*.log')) | ||
self.add_copy_spec(self.path_join(dir_name, '*.log'), | ||
sizelimit=sizelimit, |
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.
Yeah, not ignoring sizelimit entirely as a default behavior.
sos/report/plugins/container_log.py
Outdated
PluginOpt('maxage', default=None, val_type=int, | ||
desc='gather only logs with `mtime` not older than this many' | ||
' hours') |
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.
I think if we do anything here, we should add a maxage
(or since
) -esque options to all plugins by default, like we do for timeout
and postproc
.
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.
Adding that global feature in this PR doesn't feel right, so I'll submit another PR for that one.
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.
Does this PR look reasonable? #3681
option_list = [ | ||
PluginOpt('rotated', default=False, val_type=bool, | ||
desc='also get rotated logs from /var/log/pods'), | ||
] |
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.
Just noticed this on a second pass, but I'm assuming this should be dropped with the intent being that the rotated logs are collected by -k container_log.all-logs=true
once #3681 is merged?
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.
I'm stupid, you are right.
This PR is changing existing behavior and it's adding a plugin option that is not being used.
I'll make the rotated log gathering conditional to the rotated
plugin option.
In Kubernetes/OpenShift rotated logs have no symbolic link in /var/log/containers and they cannot be retrieved using `oc logs` either, so there is no way to get these rotated logs in a SOS report. This patch proposes extending the `container_log` plugin to make it also capable of retrieving rotated logs from `var/log/pods` using a plugin boolean option called `rotated`. Closes sosreport#3677 Signed-off-by: Gorka Eguileor <[email protected]>
In Kubernetes/OpenShift rotated logs have no symbolic link in /var/log/containers and they cannot be retrieved using
oc logs
either, so there is no way to get these rotated logs in a SOS report.This patch proposes a new functionality for the
container_log
plugin to retrieve rotated logs for the containers.Since there may be lots of rotated logs we also add the
maxage
option.The plugin will not only download the
/var/log/pods
files but also the/var/log/container
symlinks.Closes #3677
Signed-off-by: Gorka Eguileor [email protected]
Please place an 'X' inside each '[]' to confirm you adhere to our Contributor Guidelines