@@ -26,6 +26,7 @@ import (
26
26
corev1 "k8s.io/api/core/v1"
27
27
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
28
28
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
29
+ "k8s.io/apimachinery/pkg/util/sets"
29
30
"k8s.io/utils/ptr"
30
31
ctrl "sigs.k8s.io/controller-runtime"
31
32
"sigs.k8s.io/controller-runtime/pkg/client"
@@ -426,6 +427,8 @@ func summarizeNodeV1Beta2Conditions(_ context.Context, node *corev1.Node) (metav
426
427
semanticallyFalseStatus := 0
427
428
unknownStatus := 0
428
429
430
+ conditionCount := 0
431
+ conditionMessages := sets.Set [string ]{}
429
432
messages := []string {}
430
433
for _ , conditionType := range []corev1.NodeConditionType {corev1 .NodeReady , corev1 .NodeMemoryPressure , corev1 .NodeDiskPressure , corev1 .NodePIDPressure } {
431
434
var condition * corev1.NodeCondition
@@ -447,6 +450,8 @@ func summarizeNodeV1Beta2Conditions(_ context.Context, node *corev1.Node) (metav
447
450
if m == "" {
448
451
m = fmt .Sprintf ("Condition is %s" , condition .Status )
449
452
}
453
+ conditionCount ++
454
+ conditionMessages .Insert (m )
450
455
messages = append (messages , fmt .Sprintf ("* Node.%s: %s" , condition .Type , m ))
451
456
if condition .Status == corev1 .ConditionUnknown {
452
457
unknownStatus ++
@@ -461,6 +466,8 @@ func summarizeNodeV1Beta2Conditions(_ context.Context, node *corev1.Node) (metav
461
466
if m == "" {
462
467
m = fmt .Sprintf ("Condition is %s" , condition .Status )
463
468
}
469
+ conditionCount ++
470
+ conditionMessages .Insert (m )
464
471
messages = append (messages , fmt .Sprintf ("* Node.%s: %s" , condition .Type , m ))
465
472
if condition .Status == corev1 .ConditionUnknown {
466
473
unknownStatus ++
@@ -471,6 +478,9 @@ func summarizeNodeV1Beta2Conditions(_ context.Context, node *corev1.Node) (metav
471
478
}
472
479
}
473
480
481
+ if conditionCount > 1 && len (conditionMessages ) == 1 {
482
+ messages = []string {fmt .Sprintf ("* Node.AllConditions: %s" , conditionMessages .UnsortedList ()[0 ])}
483
+ }
474
484
message := strings .Join (messages , "\n " )
475
485
if semanticallyFalseStatus > 0 {
476
486
return metav1 .ConditionFalse , clusterv1 .MachineNodeNotHealthyV1Beta2Reason , message
0 commit comments