kubernetes / node-problem-detector

This is a place for various problem detectors running on the Kubernetes nodes.
Apache License 2.0
2.85k stars 616 forks source link

Support revert-pattern in logcounter #847

Closed linxiulei closed 6 months ago

linxiulei commented 6 months ago

In addition to --pattern argument supported in logcounter binary, I'd like to have a --revert-pattern argument, which decrease the counter when matched.

The reason I need the this feature is to skip counting restarts initiated deliberately by system administrators (e.g. systemctl restart containerd). Otherwise, NPD would post a node condition that causes noise.

"condition": "FrequentContainerdRestart",
"reason": "FrequentContainerdRestart",
"path": "/home/kubernetes/bin/log-counter",
"args": [
  "--journald-source=systemd",
  "--log-path=/var/log/journal",
  "--lookback=20m",
  "--count=5",
  "--pattern=Starting containerd container runtime...",
  "--revert-pattern=Stopping containerd container runtime..."
],

Notes: