mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-09 20:17:41 +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
@ -77,13 +77,14 @@ type serviceCache struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ServiceController struct {
|
type ServiceController struct {
|
||||||
cloud cloudprovider.Interface
|
cloud cloudprovider.Interface
|
||||||
knownHosts []string
|
knownHosts []string
|
||||||
kubeClient clientset.Interface
|
servicesToUpdate []*api.Service
|
||||||
clusterName string
|
kubeClient clientset.Interface
|
||||||
balancer cloudprovider.LoadBalancer
|
clusterName string
|
||||||
zone cloudprovider.Zone
|
balancer cloudprovider.LoadBalancer
|
||||||
cache *serviceCache
|
zone cloudprovider.Zone
|
||||||
|
cache *serviceCache
|
||||||
// A store of services, populated by the serviceController
|
// A store of services, populated by the serviceController
|
||||||
serviceStore cache.StoreToServiceLister
|
serviceStore cache.StoreToServiceLister
|
||||||
// Watches changes to all services
|
// Watches changes to all services
|
||||||
@ -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