Skip to content

Commit bdcf9bd

Browse files
committed
remove node ready state requirement
The LB health checks will take care of this.
1 parent a728f95 commit bdcf9bd

3 files changed

Lines changed: 11 additions & 44 deletions

File tree

cloud-controller-manager/do/loadbalancers.go

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -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
534533
type 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).
579579
func 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
639627
func 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

cloud-controller-manager/do/loadbalancers_test.go

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6857,18 +6857,6 @@ func TestFilterAndClassifyNodes_ExternalLB(t *testing.T) {
68576857
expectedSingleStackV4: []string{"node2"},
68586858
expectedDualStack: []string{"node1"},
68596859
},
6860-
{
6861-
name: "not ready nodes filtered",
6862-
nodes: []*v1.Node{
6863-
newNodeWithIPs("node1", "10.0.0.1", "2001:db8::1", true),
6864-
newNodeWithIPs("node2", "10.0.0.2", "2001:db8::2", false),
6865-
},
6866-
isInternalLB: false,
6867-
expectedReadyCount: 1,
6868-
expectedFilteredCount: 1,
6869-
expectedAllDualStack: true,
6870-
expectedDualStack: []string{"node1"},
6871-
},
68726860
{
68736861
name: "nodes without external IPs filtered",
68746862
nodes: []*v1.Node{
@@ -6948,15 +6936,6 @@ func TestFilterAndClassifyNodes_InternalLB(t *testing.T) {
69486936
expectedReadyCount: 2,
69496937
expectedFilteredCount: 0,
69506938
},
6951-
{
6952-
name: "not ready nodes filtered",
6953-
nodes: []*v1.Node{
6954-
newNodeWithInternalIPOnly("node1", "192.168.1.1", true),
6955-
newNodeWithInternalIPOnly("node2", "192.168.1.2", false),
6956-
},
6957-
expectedReadyCount: 1,
6958-
expectedFilteredCount: 1,
6959-
},
69606939
}
69616940

69626941
for _, test := range testcases {

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ require (
2121
k8s.io/client-go v0.35.0
2222
k8s.io/cloud-provider v0.35.0
2323
k8s.io/component-base v0.35.0
24-
k8s.io/component-helpers v0.35.0
2524
k8s.io/klog/v2 v2.130.1
2625
k8s.io/utils v0.0.0-20260108192941-914a6e750570
2726
sigs.k8s.io/controller-runtime v0.22.4
@@ -122,6 +121,7 @@ require (
122121
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
123122
k8s.io/apiextensions-apiserver v0.35.0 // indirect
124123
k8s.io/apiserver v0.35.0 // indirect
124+
k8s.io/component-helpers v0.35.0 // indirect
125125
k8s.io/controller-manager v0.35.0 // indirect
126126
k8s.io/kms v0.35.0 // indirect
127127
k8s.io/kube-openapi v0.0.0-20251125145642-4e65d59e963e // indirect

0 commit comments

Comments
 (0)