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

Use zap logger with logrotation, file logging for ip-reconciler #210

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

xagent003
Copy link
Contributor

@xagent003 xagent003 commented Mar 29, 2022

Fix for #198

This solves many logging issues we've had with whereabouts and the ip-reconciler. We already have this working on our custom whereabouts fork we use in production (https://github.com/platform9/whereabouts), would like to get it merged upstream:

  1. ip-reconciler logs are lost once the Pod is terminated. This was made worse by changing the succesful job history to 0 since all the bugs we've seen were when the Job was Succesful. So, have it mount a volume on host and write to a proper log file. This way if container is cleaned up, the logs are still accessible.

  2. whereabouts is using a custom logging package which is a wrapper around Printf. Instead, use a common logger like Zap logger. Also, use lumberjack package for built in file rotation. This works for both whereabouts and new file based ip-reconciler logging in point 1 above, and the logs are rotated automatically.

Yes, the default logging level is debug. I think we need it until this matures as we see a lot of whereabouts and ip-reconciler issues that simply would not be debuggable otherwise.

@xagent003 xagent003 force-pushed the private/arjun/upstreamLoggingFix branch from 665119a to 3cb6f11 Compare March 29, 2022 23:44
@maiqueb
Copy link
Collaborator

maiqueb commented Mar 31, 2022

Fix for #198

This solves many logging issues we've had with whereabouts and the ip-reconciler. We already have this working on our custom whereabouts fork we use in production (https://github.com/platform9/whereabouts), would like to get it merged upstream:

  1. ip-reconciler logs are lost once the Pod is terminated. This was made worse by changing the succesful job history to 0 since all the bugs we've seen were when the Job was Succesful. So, have it mount a volume on host and write to a proper log file. This way if container is cleaned up, the logs are still accessible.

Makes sense to me.

  1. whereabouts is using a custom logging package which is a wrapper around Printf. Instead, use a common logger like Zap logger. Also, use lumberjack package for built in file rotation. This works for both whereabouts and new file based ip-reconciler logging in point 1 above, and the logs are rotated automatically.

Makes sense to me. Thanks for the effort in this one.

Yes, the default logging level is debug. I think we need it until this matures as we see a lot of whereabouts and ip-reconciler issues that simply would not be debuggable otherwise.

I don't understand why you are removing the log-level configuration parameter. It still makes sense to have it.

Copy link
Collaborator

@maiqueb maiqueb left a comment

Choose a reason for hiding this comment

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

Shouldn't the vendored files be added as well ? I think you haven't go mod vendor - but I might be wrong.

@@ -13,11 +13,11 @@ const defaultReconcilerTimeout = 30

func main() {
kubeConfigFile := flag.String("kubeconfig", "", "the path to the Kubernetes configuration file")
logLevel := flag.String("log-level", "error", "the logging level for the `ip-reconciler` app. Valid values are: \"debug\", \"verbose\", \"error\", and \"panic\".")
logFile := flag.String("log-file", "/host/var/log/ip-reconciler.log", "File on host for ip-reconciler to log to")
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't understand why you are removing the log level parameter. It still makes sense.

Also, you cannot use this default - i.e. what if the cronjob spec does not feature the volume mount ? It will fail.

You should use a default on the container file system, but override that in the daemonset spec shipped in whereabouts.

@@ -8,7 +8,7 @@ metadata:
app: whereabouts
spec:
concurrencyPolicy: Forbid
successfulJobsHistoryLimit: 0
successfulJobsHistoryLimit: 3
Copy link
Collaborator

Choose a reason for hiding this comment

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

If you're now logging to the host's file-system, why would we want to preserve these around ?

@xagent003
Copy link
Contributor Author

@maiqueb you're right, I think I can make the log-level configureable in zap/lumberjack... will try adding that.

@dougbtv
Copy link
Member

dougbtv commented Apr 1, 2022

Thanks for the review Miguel. I'm in favor of this PR, these changes make sense. +1 re: log-level configuration, good to go with that in place. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants