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

[1.10] Add log-level option to conmon and crio.conf #1692

Merged
merged 1 commit into from Jul 30, 2018

Conversation

umohnani8
Copy link
Member

@umohnani8 umohnani8 commented Jul 11, 2018

conmon now has a --log-level flag that changes
the verbosity of the logs based on the value it
is set to. From logrus, panic(0), fatal(1), error(2) tells
conmon to print all pexit and nexit logs (this
is the default). warn(3) adds the nwarn logs, info(4)
adds the ninfo logs, and finally debug(5) adds the ndebug
logs as well.

Adds a log_level field in the crio.conf that can have the
following options: panic, fatal, error, warn, info, and debug.
Changes default from info to error.

Signed-off-by: umohnani8 umohnani@redhat.com

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jul 11, 2018
@umohnani8
Copy link
Member Author

@mrunalp @runcom PTAL

@mrunalp
Copy link
Member

mrunalp commented Jul 11, 2018

/test all

@mrunalp
Copy link
Member

mrunalp commented Jul 11, 2018

@umohnani8 Let us also port this to master and release-1.11. Thank!

@mheon
Copy link
Collaborator

mheon commented Jul 11, 2018

Can we get a flag to optionally keep this? It seems valuable for debugging Podman.

@umohnani8 umohnani8 changed the title Remove "container PID" logs from conmon [1.10] Remove "container PID" logs from conmon Jul 11, 2018
@umohnani8
Copy link
Member Author

@mrunalp should I go ahead and add a flag? If so, what do we want to call the flag.

@rhatdan
Copy link
Contributor

rhatdan commented Jul 11, 2018

Can you just make it debug versus info?

@mrunalp
Copy link
Member

mrunalp commented Jul 11, 2018

@rhatdan The debug change doesn't work as it just changes what gets printed in the logs. We would need to add a flag to control it.

@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jul 11, 2018
@umohnani8
Copy link
Member Author

Added debug flag. @mrunalp @mheon @rhatdan PTAL

conmon/conmon.c Outdated
@@ -80,6 +80,18 @@
syslog(LOG_INFO, "conmon <ninfo>: " fmt " \n", ##__VA_ARGS__); \
} while (0)

#define ndebug(s) \
do { \
Copy link
Collaborator

Choose a reason for hiding this comment

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

Might be better to include the if(opt_debug) in the macros so all debug prints will only happen if debug is set.

@runcom
Copy link
Member

runcom commented Jul 12, 2018

Why do you need this for debugging @mheon? Do you have or had any use case that helps you debug with this information? If this is successful the pid is sent back to golang where if in not wrong is printed somewhere, if not, we can add it there.

@mheon
Copy link
Collaborator

mheon commented Jul 12, 2018 via email

@runcom
Copy link
Member

runcom commented Jul 12, 2018

Our most successful debug strategy for conmon problems now is to have
people copy the command line libpod would use to launch it and then run it
themselves and see what happens. It lets us get output more reliably than
forwarding to Go with the added benefit that we can easily stick strace on
there if needed to get a better picture of where it's failing.

yeah that's exactly what we do as well to debug conmon, I still can't see how the pid printed after conmon starts is useful, but ok.

@umohnani8 umohnani8 force-pushed the 1.10 branch 4 times, most recently from 93b9213 to a362df2 Compare July 12, 2018 14:49
@umohnani8
Copy link
Member Author

/test all

@mrunalp
Copy link
Member

mrunalp commented Jul 12, 2018

We decided to add support for log-level instead.

@k8s-ci-robot k8s-ci-robot removed the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jul 19, 2018
@umohnani8
Copy link
Member Author

Added --log-level to conmon and changed when the logs are printed based on the level. Also added log_level to the crio.conf file.
@mrunalp @runcom PTAL.
Once this gets approved, I will pull in the same thing to master and 1.11.

Copy link
Contributor

@TomSweeneyRedHat TomSweeneyRedHat left a comment

Choose a reason for hiding this comment

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

Changes LGTM, any man page adjustments needed?

@umohnani8
Copy link
Member Author

/test all

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 19, 2018
@umohnani8
Copy link
Member Author

@TomSweeneyRedHat thanks! Added doc changes.

@umohnani8
Copy link
Member Author

/test all

@@ -163,7 +163,7 @@ Description=OCI-based implementation of Kubernetes Container Runtime Interface
Documentation=https://github.com/kubernetes-incubator/cri-o

[Service]
ExecStart=/usr/local/bin/crio --log-level debug
ExecStart=/usr/local/bin/crio
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be nice to show an example in crio.conf how to set up the debug level. Also based on the registry.conf discussions this morning, does the registries option at line 150 still hold?

Copy link
Member Author

Choose a reason for hiding this comment

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

That is fine, for 1.10 and below we need to add the default registries in /etc/crio/crio.conf.
Added an "optional" to show how we can change the log_level in crio.conf.

@rhatdan
Copy link
Contributor

rhatdan commented Jul 19, 2018

Kata does not work on 1.10, so we can ignore that I believe.

@umohnani8
Copy link
Member Author

/test e2e_rhel

@umohnani8 umohnani8 force-pushed the 1.10 branch 2 times, most recently from c455fa4 to 3e02a0b Compare July 19, 2018 18:54
conmon/conmon.c Outdated
@@ -171,6 +196,7 @@ static GOptionEntry opt_entries[] =
{ "log-size-max", 0, 0, G_OPTION_ARG_INT64, &opt_log_size_max, "Maximum size of log file", NULL },
{ "socket-dir-path", 0, 0, G_OPTION_ARG_STRING, &opt_socket_path, "Location of container attach sockets", NULL },
{ "version", 0, 0, G_OPTION_ARG_NONE, &opt_version, "Print the version and exit", NULL },
{ "log-level", 0, 0, G_OPTION_ARG_INT, &opt_log_level, "Print debug logs based on log level", NULL },
Copy link
Member

Choose a reason for hiding this comment

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

We should read this as ARG_STRING and map it to int for log_level.

Copy link
Member Author

Choose a reason for hiding this comment

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

But then logrus already maps the levels to int, so isn't it better to use that instead of creating a new string to int map of the levels in conmon?

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed. Reading as ARG_STRING and mapping to an int. Not the most high tech way, but it is the simplest solution I could think of. @mrunalp @runcom PTAL.

@umohnani8 umohnani8 force-pushed the 1.10 branch 2 times, most recently from b3d45c4 to d4c0fb9 Compare July 23, 2018 19:27
conmon/conmon.c Outdated
}

#define ndebug(s) \
if (parse_level(opt_log_level) > 2) { \
Copy link
Member

Choose a reason for hiding this comment

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

2 doesn't match the enum values you have defined below. We should use the enum constants instead of number in this comparison.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

@umohnani8
Copy link
Member Author

/test all

@umohnani8
Copy link
Member Author

/test e2e_rhel

1 similar comment
@umohnani8
Copy link
Member Author

/test e2e_rhel

conmon now has a --log-level flag that changes
the verbosity of the logs based on the value it
is set to. From logrus, panic(0), fatal(1), error(2) tells
conmon to print all pexit and nexit logs (this
is the default). warn(3) adds the nwarn logs, info(4)
adds the ninfo logs, and finally debug(5) adds the ndebug
logs as well.

Adds a log_level field in the crio.conf that can have the
following options: panic, fatal, error, warn, info, and debug.
Changes default from info to error.

Signed-off-by: umohnani8 <umohnani@redhat.com>
@umohnani8
Copy link
Member Author

/test all

@umohnani8
Copy link
Member Author

tests finally pass. @mrunalp @runcom PTAL

@@ -229,9 +232,9 @@ func main() {
},
cli.StringFlag{
Name: "log-level",
Usage: "log messages above specified level: debug, info (default), warn, error, fatal or panic",
Value: "error",
Copy link
Member

Choose a reason for hiding this comment

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

are we sure about this default? what was before this change overall?

Copy link
Member Author

Choose a reason for hiding this comment

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

it was info. We want the logs to be as minimal as possible by default so error seems like the best choice. When we change this in crio.conf the logs get more verbose for both cri-o and conmon.

Copy link
Member

Choose a reason for hiding this comment

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

awesome, we're good then (error's super fine!)

@rhatdan
Copy link
Contributor

rhatdan commented Jul 30, 2018

LGTM

@rhatdan rhatdan merged commit 7cc47d7 into cri-o:release-1.10 Jul 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants