@@ -35,7 +35,6 @@ import (
3535 cloudprovider "k8s.io/cloud-provider"
3636 "k8s.io/cloud-provider/api"
3737 servicehelpers "k8s.io/cloud-provider/service/helpers"
38- nodeutil "k8s.io/component-helpers/node/util"
3938 "k8s.io/klog/v2"
4039 utilnet "k8s.io/utils/net"
4140
@@ -532,6 +531,7 @@ const (
532531
533532// nodeState contains the classification and filtering results for nodes
534533type nodeState struct {
534+ // readyNodes are nodes that are ready to serve as LB backends
535535 readyNodes []* v1.Node
536536 filteredCount int
537537 singleStackV4Nodes []* v1.Node
@@ -570,11 +570,11 @@ func (ns *nodeState) isAllDualStack() bool {
570570 return ns .hasDualStackNodes () && ! ns .hasSingleStackV4 ()
571571}
572572
573- // filterAndClassifyNodes filters nodes by readiness and (for EXTERNAL LBs) external IPs,
574- // then classifies remaining nodes as singleStackV4, singleStackV6, or dualStack.
573+ // filterAndClassifyNodes filters nodes by available IP stacks and differentiates between
574+ // singleStackV4, singleStackV6, or dualStack.
575575//
576- // For INTERNAL load balancers, only Ready status is checked ( public IPs not required) .
577- // For EXTERNAL load balancers, nodes must be Ready, have at least one external IP,
576+ // For INTERNAL load balancers, public IPs not required, private assumed .
577+ // For EXTERNAL load balancers, have at least one external IP,
578578// and singleStackV6 nodes are filtered out (not supported for external connectivity).
579579func filterAndClassifyNodes (nodes []* v1.Node , isInternalLB bool ) * nodeState {
580580 state := & nodeState {
@@ -585,20 +585,14 @@ func filterAndClassifyNodes(nodes []*v1.Node, isInternalLB bool) *nodeState {
585585 }
586586
587587 for _ , node := range nodes {
588- // Filter 1: Check NodeReady condition (applies to ALL LB types)
589- if ! isNodeReady (node ) {
590- klog .V (4 ).Infof ("Node %s filtered: not in Ready state" , node .Name )
591- state .filteredCount ++
592- continue
593- }
594-
595- // For INTERNAL LBs, Ready is sufficient - no need for public IPs
588+ // For INTERNAL LBs, no need for public IPs - assuming ready
589+ // this is just here so that we can expand in the future when internalLBs support v6 or other features.
596590 if isInternalLB {
597591 state .readyNodes = append (state .readyNodes , node )
598592 continue
599593 }
600594
601- // Filter 2: For EXTERNAL LBs, check for external IPs and classify
595+ // For EXTERNAL LBs, check for external IPs and classify
602596 classification := classifyNode (node )
603597
604598 if classification == nodeClassPublicNetUnready {
@@ -629,12 +623,6 @@ func filterAndClassifyNodes(nodes []*v1.Node, isInternalLB bool) *nodeState {
629623 return state
630624}
631625
632- // isNodeReady checks if node has Ready condition = True
633- func isNodeReady (node * v1.Node ) bool {
634- _ , condition := nodeutil .GetNodeCondition (& node .Status , v1 .NodeReady )
635- return condition != nil && condition .Status == v1 .ConditionTrue
636- }
637-
638626// classifyNode determines node's IP stack classification
639627func classifyNode (node * v1.Node ) nodeClassification {
640628 hasIPv4 := false
@@ -938,10 +926,10 @@ func (l *loadBalancers) buildLoadBalancerRequest(ctx context.Context, service *v
938926 // Log filtering results
939927 if nodeState .filteredCount > 0 {
940928 if isInternalLB {
941- klog .V (2 ).Infof ("Service %s/%s: Filtered out %d non-ready nodes, %d ready nodes remaining (INTERNAL LB)" ,
929+ klog .V (2 ).Infof ("Service %s/%s: Filtered out %d non-lb- ready nodes, %d lb- ready nodes remaining (INTERNAL LB)" ,
942930 service .Namespace , service .Name , nodeState .filteredCount , len (nodeState .readyNodes ))
943931 } else {
944- klog .V (2 ).Infof ("Service %s/%s: Filtered out %d non-ready/non-public nodes, %d ready nodes remaining (%d dualStack, %d singleStackV4)" ,
932+ klog .V (2 ).Infof ("Service %s/%s: Filtered out %d non-lb- ready/non-public nodes, %d lb- ready nodes remaining (%d dualStack, %d singleStackV4)" ,
945933 service .Namespace , service .Name , nodeState .filteredCount ,
946934 len (nodeState .readyNodes ), len (nodeState .dualStackNodes ), len (nodeState .singleStackV4Nodes ))
947935
0 commit comments