@@ -87,17 +87,17 @@ var _ = Describe("[Install] continuousIntegration", Serial, func() {
8787 err := wait .PollUntilContextTimeout (context .Background (), 10 * time .Second , 5 * time .Minute , immediate , func (ctx context.Context ) (bool , error ) {
8888 err := e2eclient .Client .Get (ctx , nname , updatedNROObj )
8989 if err != nil {
90- klog .Warningf ( "failed to get the NRO resource: %v" , err )
90+ klog .ErrorS ( err , "failed to get the NRO resource" )
9191 return false , err
9292 }
9393
9494 cond := status .FindCondition (updatedNROObj .Status .Conditions , status .ConditionAvailable )
9595 if cond == nil {
96- klog .Warningf ("missing conditions in %v " , updatedNROObj )
96+ klog .InfoS ("missing conditions" , "nroObj " , updatedNROObj )
9797 return false , err
9898 }
9999
100- klog .Infof ("condition for %s: %v" , nname .Name , cond )
100+ klog .InfoS ("condition" , "name" , nname .Name , "condition" , cond )
101101 return cond .Status == metav1 .ConditionTrue , nil
102102 })
103103 if err != nil {
@@ -117,27 +117,27 @@ var _ = Describe("[Install] continuousIntegration", Serial, func() {
117117 Eventually (func () bool {
118118 ds , err := getDaemonSetByOwnerReference (updatedNROObj .UID )
119119 if err != nil {
120- klog .Warningf ( "unable to get Daemonset %v" , err )
120+ klog .ErrorS ( err , "unable to get Daemonset" )
121121 return false
122122 }
123123
124124 if ds .Status .NumberMisscheduled != 0 {
125- klog .Warningf ( " Misscheduled: There are %d nodes that should not be running Daemon pod but are" , ds .Status .NumberMisscheduled )
125+ klog .InfoS ( " Misscheduled: There are nodes that should not be running Daemon pod, but they are" , "count " , ds .Status .NumberMisscheduled )
126126 return false
127127 }
128128
129129 if ds .Status .NumberUnavailable != 0 {
130- klog .Infof ( " NumberUnavailable %d (should be 0)" , ds .Status .NumberUnavailable )
130+ klog .InfoS ( " NumberUnavailable mismatch" , "current" , ds .Status .NumberUnavailable , "desired" , 0 )
131131 return false
132132 }
133133
134134 if ds .Status .CurrentNumberScheduled != ds .Status .DesiredNumberScheduled {
135- klog .Infof ( " CurrentNumberScheduled %d (should be %d)" , ds .Status .CurrentNumberScheduled , ds .Status .DesiredNumberScheduled )
135+ klog .InfoS ( " CurrentNumberScheduled mismatch" , "current" , ds .Status .CurrentNumberScheduled , "desired" , ds .Status .DesiredNumberScheduled )
136136 return false
137137 }
138138
139139 if ds .Status .NumberReady != ds .Status .DesiredNumberScheduled {
140- klog .Infof ( " NumberReady %d (should be %d)" , ds .Status .CurrentNumberScheduled , ds .Status .DesiredNumberScheduled )
140+ klog .InfoS ( " NumberReady mismatch" , "current" , ds .Status .NumberReady , "desired" , ds .Status .DesiredNumberScheduled )
141141 return false
142142 }
143143 return true
@@ -176,17 +176,17 @@ var _ = Describe("[Install] durability", Serial, func() {
176176 updatedNROObj := & nropv1.NUMAResourcesOperator {}
177177 err := e2eclient .Client .Get (context .TODO (), client .ObjectKeyFromObject (nroObj ), updatedNROObj )
178178 if err != nil {
179- klog .Warningf ( "failed to get the NUMAResourcesOperator CR: %v" , err )
179+ klog .ErrorS ( err , "failed to get the NUMAResourcesOperator CR" )
180180 return false
181181 }
182182
183183 cond := status .FindCondition (updatedNROObj .Status .Conditions , status .ConditionDegraded )
184184 if cond == nil {
185- klog .Warningf ("missing conditions in %v " , updatedNROObj )
185+ klog .InfoS ("missing conditions" , "nroObj " , updatedNROObj )
186186 return false
187187 }
188188
189- klog .Infof ("condition: %v " , cond )
189+ klog .InfoS ("condition" , "condition " , cond )
190190
191191 return cond .Status == metav1 .ConditionTrue
192192 }).WithTimeout (5 * time .Minute ).WithPolling (10 * time .Second ).Should (BeTrue (), "NUMAResourcesOperator condition did not become degraded" )
@@ -219,7 +219,7 @@ var _ = Describe("[Install] durability", Serial, func() {
219219 return false , err
220220 }
221221 if len (nroObj .Status .DaemonSets ) != 1 {
222- klog .Warningf ("unsupported daemonsets (/MCP) count: %d " , len (nroObj .Status .DaemonSets ))
222+ klog .InfoS ("unsupported daemonsets (/MCP)" , " count" , len (nroObj .Status .DaemonSets ))
223223 return false , nil
224224 }
225225 return true , nil
@@ -253,22 +253,18 @@ var _ = Describe("[Install] durability", Serial, func() {
253253 updatedDs := & appsv1.DaemonSet {}
254254 err := e2eclient .Client .Get (context .TODO (), dsKey .AsKey (), updatedDs )
255255 if err != nil {
256- klog .Warningf ( "failed to get the daemonset %s: %v" , dsKey .String (), err )
256+ klog .ErrorS ( err , "failed to get the daemonset" , "key" , dsKey .String ())
257257 return false
258258 }
259259
260260 if ! nrowait .AreDaemonSetPodsReady (& updatedDs .Status ) {
261- klog .Warningf ("daemonset %s desired %d scheduled %d ready %d" ,
262- dsKey .String (),
263- updatedDs .Status .DesiredNumberScheduled ,
264- updatedDs .Status .CurrentNumberScheduled ,
265- updatedDs .Status .NumberReady )
261+ klog .InfoS ("daemonset not ready" , "key" , dsKey .String (), "desired" , updatedDs .Status .DesiredNumberScheduled , "scheduled" , updatedDs .Status .CurrentNumberScheduled , "ready" , updatedDs .Status .NumberReady )
266262 return false
267263 }
268264
269- klog .Infof ("daemonset %s ready" , dsKey .String ())
265+ klog .InfoS ("daemonset ready" , "key " , dsKey .String ())
270266
271- klog .Warningf ("daemonset Generation observed %v current %v" , updatedDs .Status .ObservedGeneration , ds .Generation )
267+ klog .InfoS ("daemonset Generation" , "observedGeneration" , updatedDs .Status .ObservedGeneration , "currentGeneration" , ds .Generation )
272268 isUpdated := updatedDs .Status .ObservedGeneration > ds .Generation
273269 if ! isUpdated {
274270 return false
@@ -315,9 +311,9 @@ var _ = Describe("[Install] durability", Serial, func() {
315311 key := client .ObjectKeyFromObject (obj )
316312 if err := e2eclient .Client .Get (context .TODO (), key , obj ); ! errors .IsNotFound (err ) {
317313 if err == nil {
318- klog .Warningf ("obj %s still exists" , key .String ())
314+ klog .InfoS ("obj still exists" , "key " , key .String ())
319315 } else {
320- klog .Warningf ( "obj %s return with error: %v" , key .String (), err )
316+ klog .ErrorS ( err , "obj return with error" , "key" , key .String ())
321317 }
322318 return false
323319 }
@@ -352,8 +348,8 @@ var _ = Describe("[Install] durability", Serial, func() {
352348
353349 ds , err := getDaemonSetByOwnerReference (updatedNroObj .GetUID ())
354350 if err != nil {
355- klog . Warningf ( "failed to get the RTE DaemonSet: %v" , err )
356- klog .Warningf ( "NRO: \n %s \n " , objects .ToYAML (updatedNroObj ))
351+ // TODO: multi-line value in structured log
352+ klog .ErrorS ( err , "failed to get the RTE DaemonSet" , "nroYAML " , objects .ToYAML (updatedNroObj ))
357353 return false
358354 }
359355
@@ -369,12 +365,13 @@ var _ = Describe("[Install] durability", Serial, func() {
369365 Expect (err ).ToNot (HaveOccurred ())
370366
371367 if len (updatedConfigMaps .Items ) != 1 {
372- klog .Warningf ("expected exactly 1 RTE configmap, got: %d" , len (updatedConfigMaps .Items ))
368+ klog .InfoS ("expected exactly configmap" , "current" , len (updatedConfigMaps .Items ), "desired" , 1 )
373369 return false
374370 }
375371 rteConfigMap = & updatedConfigMaps .Items [0 ]
376372 return true
377373 }).WithTimeout (5 * time .Minute ).WithPolling (10 * time .Second ).Should (BeTrue ())
374+ // TODO: multi-line value in structured log
378375 klog .InfoS ("found RTE configmap" , "rteConfigMap" , rteConfigMap )
379376
380377 cfg , err := configuration .ValidateAndExtractRTEConfigData (rteConfigMap )
@@ -392,7 +389,7 @@ var _ = Describe("[Install] durability", Serial, func() {
392389 // the same configuration should apply to all NRT objects
393390 matchingErr := configuration .CheckTopologyManagerConfigMatching (nrt , & cfg )
394391 if matchingErr != "" {
395- klog .Warningf ("NRT %q doesn't match topologyManager configuration: %s" , nrt .Name , matchingErr )
392+ klog .InfoS ("NRT doesn't match topologyManager configuration" , "name" , nrt .Name , "problem" , matchingErr )
396393 return false
397394 }
398395 }
@@ -451,18 +448,18 @@ func getDaemonSetByOwnerReference(uid types.UID) (*appsv1.DaemonSet, error) {
451448func logRTEPodsLogs (cli client.Client , k8sCli * kubernetes.Clientset , ctx context.Context , nroObj * nropv1.NUMAResourcesOperator , reason string ) {
452449 dss , err := objects .GetDaemonSetsOwnedBy (cli , nroObj .ObjectMeta )
453450 if err != nil {
454- klog .Warningf ("no DaemonSets for %s (%s)" , nroObj .Name , nroObj .GetUID ())
451+ klog .InfoS ("no DaemonSets" , "nroName" , nroObj .Name , "nroUID" , nroObj .GetUID ())
455452 return
456453 }
457454
458- klog .Infof ( "%s (%d DaemonSet) " , reason , len (dss ))
455+ klog .InfoS ( "logging RTE pods " , " reason" , reason , "daemonsetCount" , len (dss ))
459456
460457 for _ , ds := range dss {
461- klog .Infof ("daemonset %s/%s desired %d scheduled %d ready %d" , ds .Namespace , ds .Name , ds .Status .DesiredNumberScheduled , ds .Status .CurrentNumberScheduled , ds .Status .NumberReady )
458+ klog .InfoS ("daemonset status" , "namespace" , ds .Namespace , "name" , ds .Name , "desired" , ds .Status .DesiredNumberScheduled , "scheduled" , ds .Status .CurrentNumberScheduled , "ready" , ds .Status .NumberReady )
462459
463460 labSel , err := metav1 .LabelSelectorAsSelector (ds .Spec .Selector )
464461 if err != nil {
465- klog .Warningf ( "cannot use DaemonSet label selector as selector: %v" , err )
462+ klog .ErrorS ( err , "cannot use DaemonSet label selector as selector" )
466463 continue
467464 }
468465
@@ -472,17 +469,18 @@ func logRTEPodsLogs(cli client.Client, k8sCli *kubernetes.Clientset, ctx context
472469 LabelSelector : labSel ,
473470 })
474471 if err != nil {
475- klog .Warningf ( "cannot get Pods by DaemonSet %s/%s: %v" , ds .Namespace , ds .Name , err )
472+ klog .ErrorS ( err , "cannot get Pods by DaemonSet" , "namespace" , ds .Namespace , "name" , ds .Name )
476473 continue
477474 }
478475
479476 for _ , pod := range podList .Items {
480477 logs , err := objects .GetLogsForPod (k8sCli , pod .Namespace , pod .Name , containerNameRTE )
481478 if err != nil {
482- klog .Warningf ( "DaemonSet %s/%s -> Pod %s/%s -> error getting logs: %v" , ds .Namespace , ds .Name , pod .Namespace , pod .Name , err )
479+ klog .ErrorS ( err , "cannot fetch logs" , "dsNamespace" , ds .Namespace , "dsName" , ds .Name , "podNamespace" , pod .Namespace , "podName" , pod .Name )
483480 continue
484481 }
485- klog .Infof ("DaemonSet %s/%s -> Pod %s/%s -> logs:\n %s\n -----\n " , ds .Namespace , ds .Name , pod .Namespace , pod .Name , logs )
482+ // TODO: multi-line value in structured log
483+ klog .InfoS ("fetched logs" , "dsNamespace" , ds .Namespace , "dsName" , ds .Name , "podNamespace" , pod .Namespace , "podName" , pod .Name , "logs" , logs )
486484 }
487485 }
488486}
0 commit comments