@@ -17,13 +17,15 @@ limitations under the License.
17
17
package nodegroupset
18
18
19
19
import (
20
+ "fmt"
20
21
"math"
21
22
22
23
apiv1 "k8s.io/api/core/v1"
23
24
"k8s.io/apimachinery/pkg/api/resource"
24
25
"k8s.io/autoscaler/cluster-autoscaler/config"
25
26
"k8s.io/autoscaler/cluster-autoscaler/simulator/framework"
26
27
"k8s.io/autoscaler/cluster-autoscaler/utils/scheduler"
28
+ klog "k8s.io/klog/v2"
27
29
)
28
30
29
31
// BasicIgnoredLabels define a set of basic labels that should be ignored when comparing the similarity
@@ -122,34 +124,44 @@ func IsCloudProviderNodeInfoSimilar(
122
124
123
125
for kind , qtyList := range capacity {
124
126
if len (qtyList ) != 2 {
127
+ dissimilarNodesLog (n1 .Node ().Name , n2 .Node ().Name , fmt .Sprintf ("missing capacity %q" , kind ))
125
128
return false
126
129
}
127
130
switch kind {
128
131
case apiv1 .ResourceMemory :
129
132
if ! resourceListWithinTolerance (qtyList , ratioOpts .MaxCapacityMemoryDifferenceRatio ) {
133
+ dissimilarNodesLog (n1 .Node ().Name , n2 .Node ().Name , "memory not within tolerance" )
130
134
return false
131
135
}
132
136
default :
133
137
// For other capacity types we require exact match.
134
138
// If this is ever changed, enforcing MaxCoresTotal limits
135
139
// as it is now may no longer work.
136
140
if qtyList [0 ].Cmp (qtyList [1 ]) != 0 {
141
+ dissimilarNodesLog (n1 .Node ().Name , n2 .Node ().Name , fmt .Sprintf ("capacity resource %q does not match" , kind ))
137
142
return false
138
143
}
139
144
}
140
145
}
141
146
142
147
// For allocatable and free we allow resource quantities to be within a few % of each other
143
148
if ! resourceMapsWithinTolerance (allocatable , ratioOpts .MaxAllocatableDifferenceRatio ) {
149
+ dissimilarNodesLog (n1 .Node ().Name , n2 .Node ().Name , "allocatable resources not within tolerance" )
144
150
return false
145
151
}
146
152
if ! resourceMapsWithinTolerance (free , ratioOpts .MaxFreeDifferenceRatio ) {
153
+ dissimilarNodesLog (n1 .Node ().Name , n2 .Node ().Name , "free resources not within tolerance" )
147
154
return false
148
155
}
149
156
150
157
if ! compareLabels (nodes , ignoredLabels ) {
158
+ dissimilarNodesLog (n1 .Node ().Name , n2 .Node ().Name , "labels do not match" )
151
159
return false
152
160
}
153
161
154
162
return true
155
163
}
164
+
165
+ func dissimilarNodesLog (node1 , node2 , message string ) {
166
+ klog .V (5 ).Infof ("nodes %q and %q are not similar, %s" , node1 , node2 , message )
167
+ }
0 commit comments