mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-11 04:52:08 +00:00
Merge pull request #31217 from mfanjie/fix-service-controller-defect
Automatic merge from submit-queue persist services need to be retried in service controller cache. fix issue reported by @anguslees more detail on #25189
This commit is contained in:
commit
88f6a67c7c
@ -79,6 +79,7 @@ type serviceCache struct {
|
|||||||
type ServiceController struct {
|
type ServiceController struct {
|
||||||
cloud cloudprovider.Interface
|
cloud cloudprovider.Interface
|
||||||
knownHosts []string
|
knownHosts []string
|
||||||
|
servicesToUpdate []*api.Service
|
||||||
kubeClient clientset.Interface
|
kubeClient clientset.Interface
|
||||||
clusterName string
|
clusterName string
|
||||||
balancer cloudprovider.LoadBalancer
|
balancer cloudprovider.LoadBalancer
|
||||||
@ -619,7 +620,6 @@ func getNodeConditionPredicate() cache.NodeConditionPredicate {
|
|||||||
// nodeSyncLoop handles updating the hosts pointed to by all load
|
// nodeSyncLoop handles updating the hosts pointed to by all load
|
||||||
// balancers whenever the set of nodes in the cluster changes.
|
// balancers whenever the set of nodes in the cluster changes.
|
||||||
func (s *ServiceController) nodeSyncLoop() {
|
func (s *ServiceController) nodeSyncLoop() {
|
||||||
var servicesToUpdate []*api.Service
|
|
||||||
nodes, err := s.nodeLister.NodeCondition(getNodeConditionPredicate()).List()
|
nodes, err := s.nodeLister.NodeCondition(getNodeConditionPredicate()).List()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("Failed to retrieve current set of nodes from node lister: %v", err)
|
glog.Errorf("Failed to retrieve current set of nodes from node lister: %v", err)
|
||||||
@ -629,18 +629,18 @@ func (s *ServiceController) nodeSyncLoop() {
|
|||||||
if stringSlicesEqual(newHosts, s.knownHosts) {
|
if stringSlicesEqual(newHosts, s.knownHosts) {
|
||||||
// The set of nodes in the cluster hasn't changed, but we can retry
|
// The set of nodes in the cluster hasn't changed, but we can retry
|
||||||
// updating any services that we failed to update last time around.
|
// updating any services that we failed to update last time around.
|
||||||
servicesToUpdate = s.updateLoadBalancerHosts(servicesToUpdate, newHosts)
|
s.servicesToUpdate = s.updateLoadBalancerHosts(s.servicesToUpdate, newHosts)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
glog.Infof("Detected change in list of current cluster nodes. New node set: %v", newHosts)
|
glog.Infof("Detected change in list of current cluster nodes. New node set: %v", newHosts)
|
||||||
|
|
||||||
// Try updating all services, and save the ones that fail to try again next
|
// Try updating all services, and save the ones that fail to try again next
|
||||||
// round.
|
// round.
|
||||||
servicesToUpdate = s.cache.allServices()
|
s.servicesToUpdate = s.cache.allServices()
|
||||||
numServices := len(servicesToUpdate)
|
numServices := len(s.servicesToUpdate)
|
||||||
servicesToUpdate = s.updateLoadBalancerHosts(servicesToUpdate, newHosts)
|
s.servicesToUpdate = s.updateLoadBalancerHosts(s.servicesToUpdate, newHosts)
|
||||||
glog.Infof("Successfully updated %d out of %d load balancers to direct traffic to the updated set of nodes",
|
glog.Infof("Successfully updated %d out of %d load balancers to direct traffic to the updated set of nodes",
|
||||||
numServices-len(servicesToUpdate), numServices)
|
numServices-len(s.servicesToUpdate), numServices)
|
||||||
|
|
||||||
s.knownHosts = newHosts
|
s.knownHosts = newHosts
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user