-
Notifications
You must be signed in to change notification settings - Fork 101
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
Support structure logging for livenessprobe container #168
Changes from all commits
dffae97
cc85cbe
817e991
4ccdb51
f7a9dea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,8 @@ import ( | |
connlib "github.com/kubernetes-csi/csi-lib-utils/connection" | ||
"github.com/kubernetes-csi/csi-lib-utils/metrics" | ||
"github.com/kubernetes-csi/csi-lib-utils/rpc" | ||
logsapi "k8s.io/component-base/logs/api/v1" | ||
json "k8s.io/component-base/logs/json" | ||
) | ||
|
||
const ( | ||
|
@@ -46,6 +48,7 @@ var ( | |
metricsAddress = flag.String("metrics-address", "", "(deprecated) The TCP network address where the prometheus metrics endpoint will listen (example: `:8080`). The default is empty string, which means metrics endpoint is disabled. If set, `--http-endpoint` cannot be set, and the address cannot resolve to localhost + the port from `--health-port`.") | ||
httpEndpoint = flag.String("http-endpoint", "", "The TCP network address where the HTTP server for diagnostics, including CSI driver health check and metrics. The default is empty string, which means the server is disabled. If set, `--health-port` and `--metrics-address` cannot be explicitly set.") | ||
metricsPath = flag.String("metrics-path", "/metrics", "The HTTP path where prometheus metrics will be exposed. Default is `/metrics`.") | ||
logFormatJSON = flag.Bool("log-format-json", false, "set log formatter to json") | ||
) | ||
|
||
type healthProbe struct { | ||
|
@@ -131,6 +134,11 @@ func main() { | |
klog.Error("only one of `--metrics-address` and `--http-endpoint` can be explicitly set.") | ||
os.Exit(1) | ||
} | ||
if *logFormatJSON { | ||
jsonFactory := json.Factory{} | ||
logger, _ := jsonFactory.Create(logsapi.LoggingConfiguration{Format: "json"}) | ||
klog.InfoS("logging livenessprobe",logger) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is just logging There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mauriciopoppe ok i will re check this, if it's possible could you provide me pointer on this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wrote some pointers in kubernetes-csi/node-driver-registrar#228 (comment) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sure i will check that thanks |
||
} | ||
var addr string | ||
if *httpEndpoint != "" { | ||
addr = *httpEndpoint | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,4 +50,5 @@ | |
args: | ||
- --v=4 | ||
- --csi-address=/csi/csi.sock | ||
- --log-format-json=true | ||
# |
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
we should follow the same flag as the kubelet which is
logging-format
https://github.com/kubernetes/component-base/blob/v0.25.3/logs/api/v1/options.go#L185There 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.
Sure i will modify this to
logging-format