@@ -21,7 +21,7 @@ import (
2121 "os"
2222 "time"
2323
24- "github.com/golang/glog "
24+ "k8s.io/klog/v2 "
2525
2626 "k8s.io/node-problem-detector/pkg/custompluginmonitor/plugin"
2727 cpmtypes "k8s.io/node-problem-detector/pkg/custompluginmonitor/types"
@@ -59,25 +59,25 @@ func NewCustomPluginMonitorOrDie(configPath string) types.Monitor {
5959 }
6060 f , err := os .ReadFile (configPath )
6161 if err != nil {
62- glog .Fatalf ("Failed to read configuration file %q: %v" , configPath , err )
62+ klog .Fatalf ("Failed to read configuration file %q: %v" , configPath , err )
6363 }
6464 err = json .Unmarshal (f , & c .config )
6565 if err != nil {
66- glog .Fatalf ("Failed to unmarshal configuration file %q: %v" , configPath , err )
66+ klog .Fatalf ("Failed to unmarshal configuration file %q: %v" , configPath , err )
6767 }
6868 // Apply configurations
6969 err = (& c .config ).ApplyConfiguration ()
7070 if err != nil {
71- glog .Fatalf ("Failed to apply configuration for %q: %v" , configPath , err )
71+ klog .Fatalf ("Failed to apply configuration for %q: %v" , configPath , err )
7272 }
7373
7474 // Validate configurations
7575 err = c .config .Validate ()
7676 if err != nil {
77- glog .Fatalf ("Failed to validate custom plugin config %+v: %v" , c .config , err )
77+ klog .Fatalf ("Failed to validate custom plugin config %+v: %v" , c .config , err )
7878 }
7979
80- glog .Infof ("Finish parsing custom plugin monitor config file %s: %+v" , c .configPath , c .config )
80+ klog .Infof ("Finish parsing custom plugin monitor config file %s: %+v" , c .configPath , c .config )
8181
8282 c .plugin = plugin .NewPlugin (c .config )
8383 // A 1000 size channel should be big enough.
@@ -96,26 +96,26 @@ func initializeProblemMetricsOrDie(rules []*cpmtypes.CustomRule) {
9696 if rule .Type == types .Perm {
9797 err := problemmetrics .GlobalProblemMetricsManager .SetProblemGauge (rule .Condition , rule .Reason , false )
9898 if err != nil {
99- glog .Fatalf ("Failed to initialize problem gauge metrics for problem %q, reason %q: %v" ,
99+ klog .Fatalf ("Failed to initialize problem gauge metrics for problem %q, reason %q: %v" ,
100100 rule .Condition , rule .Reason , err )
101101 }
102102 }
103103 err := problemmetrics .GlobalProblemMetricsManager .IncrementProblemCounter (rule .Reason , 0 )
104104 if err != nil {
105- glog .Fatalf ("Failed to initialize problem counter metrics for %q: %v" , rule .Reason , err )
105+ klog .Fatalf ("Failed to initialize problem counter metrics for %q: %v" , rule .Reason , err )
106106 }
107107 }
108108}
109109
110110func (c * customPluginMonitor ) Start () (<- chan * types.Status , error ) {
111- glog .Infof ("Start custom plugin monitor %s" , c .configPath )
111+ klog .Infof ("Start custom plugin monitor %s" , c .configPath )
112112 go c .plugin .Run ()
113113 go c .monitorLoop ()
114114 return c .statusChan , nil
115115}
116116
117117func (c * customPluginMonitor ) Stop () {
118- glog .Infof ("Stop custom plugin monitor %s" , c .configPath )
118+ klog .Infof ("Stop custom plugin monitor %s" , c .configPath )
119119 c .tomb .Stop ()
120120}
121121
@@ -133,16 +133,16 @@ func (c *customPluginMonitor) monitorLoop() {
133133 select {
134134 case result , ok := <- resultChan :
135135 if ! ok {
136- glog .Errorf ("Result channel closed: %s" , c .configPath )
136+ klog .Errorf ("Result channel closed: %s" , c .configPath )
137137 return
138138 }
139- glog .V (3 ).Infof ("Receive new plugin result for %s: %+v" , c .configPath , result )
139+ klog .V (3 ).Infof ("Receive new plugin result for %s: %+v" , c .configPath , result )
140140 status := c .generateStatus (result )
141- glog .V (3 ).Infof ("New status generated: %+v" , status )
141+ klog .V (3 ).Infof ("New status generated: %+v" , status )
142142 c .statusChan <- status
143143 case <- c .tomb .Stopping ():
144144 c .plugin .Stop ()
145- glog .Infof ("Custom plugin monitor stopped: %s" , c .configPath )
145+ klog .Infof ("Custom plugin monitor stopped: %s" , c .configPath )
146146 c .tomb .Done ()
147147 return
148148 }
@@ -256,15 +256,15 @@ func (c *customPluginMonitor) generateStatus(result cpmtypes.Result) *types.Stat
256256 err := problemmetrics .GlobalProblemMetricsManager .IncrementProblemCounter (
257257 event .Reason , 1 )
258258 if err != nil {
259- glog .Errorf ("Failed to update problem counter metrics for %q: %v" ,
259+ klog .Errorf ("Failed to update problem counter metrics for %q: %v" ,
260260 event .Reason , err )
261261 }
262262 }
263263 for _ , condition := range c .conditions {
264264 err := problemmetrics .GlobalProblemMetricsManager .SetProblemGauge (
265265 condition .Type , condition .Reason , condition .Status == types .True )
266266 if err != nil {
267- glog .Errorf ("Failed to update problem gauge metrics for problem %q, reason %q: %v" ,
267+ klog .Errorf ("Failed to update problem gauge metrics for problem %q, reason %q: %v" ,
268268 condition .Type , condition .Reason , err )
269269 }
270270 }
@@ -277,7 +277,7 @@ func (c *customPluginMonitor) generateStatus(result cpmtypes.Result) *types.Stat
277277 }
278278 // Log only if condition has changed
279279 if len (activeProblemEvents ) != 0 || len (inactiveProblemEvents ) != 0 {
280- glog .V (0 ).Infof ("New status generated: %+v" , status )
280+ klog .V (0 ).Infof ("New status generated: %+v" , status )
281281 }
282282 return status
283283}
@@ -297,7 +297,7 @@ func toConditionStatus(s cpmtypes.Status) types.ConditionStatus {
297297func (c * customPluginMonitor ) initializeStatus () {
298298 // Initialize the default node conditions
299299 c .conditions = initialConditions (c .config .DefaultConditions )
300- glog .Infof ("Initialize condition generated: %+v" , c .conditions )
300+ klog .Infof ("Initialize condition generated: %+v" , c .conditions )
301301 // Update the initial status
302302 c .statusChan <- & types.Status {
303303 Source : c .config .Source ,
0 commit comments