mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 17:30:00 +00:00
Handle ImplementedElsewhere error in service_controller
This is used when the cloudprovider layer is not implementing loadBalancer service. Implementation will be in a different controller running on master.
This commit is contained in:
parent
5623006f98
commit
d79d4e8525
@ -339,6 +339,10 @@ func (s *ServiceController) syncLoadBalancerIfNeeded(service *v1.Service, key st
|
|||||||
}
|
}
|
||||||
newStatus, err = s.ensureLoadBalancer(service)
|
newStatus, err = s.ensureLoadBalancer(service)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if err == cloudprovider.ImplementedElsewhere {
|
||||||
|
klog.Infof("LoadBalancer for service %s not implemented by alternate controller %s, Ignoring error", key, s.cloud.ProviderName())
|
||||||
|
return op, nil
|
||||||
|
}
|
||||||
return op, fmt.Errorf("failed to ensure load balancer: %v", err)
|
return op, fmt.Errorf("failed to ensure load balancer: %v", err)
|
||||||
}
|
}
|
||||||
s.eventRecorder.Event(service, v1.EventTypeNormal, "EnsuredLoadBalancer", "Ensured load balancer")
|
s.eventRecorder.Event(service, v1.EventTypeNormal, "EnsuredLoadBalancer", "Ensured load balancer")
|
||||||
@ -703,7 +707,12 @@ func (s *ServiceController) lockedUpdateLoadBalancerHosts(service *v1.Service, h
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
if err == cloudprovider.ImplementedElsewhere {
|
||||||
|
// Skip error since LoadBalancer implementation is in some other controller. In this case, the loadBalancer will likely not
|
||||||
|
// exist and will be handled in the if block below. Adding this check in case the alternate loadBalancer implementation
|
||||||
|
// uses the same naming scheme.
|
||||||
|
return nil
|
||||||
|
}
|
||||||
// It's only an actual error if the load balancer still exists.
|
// It's only an actual error if the load balancer still exists.
|
||||||
if _, exists, err := s.balancer.GetLoadBalancer(context.TODO(), s.clusterName, service); err != nil {
|
if _, exists, err := s.balancer.GetLoadBalancer(context.TODO(), s.clusterName, service); err != nil {
|
||||||
runtime.HandleError(fmt.Errorf("failed to check if load balancer exists for service %s/%s: %v", service.Namespace, service.Name, err))
|
runtime.HandleError(fmt.Errorf("failed to check if load balancer exists for service %s/%s: %v", service.Namespace, service.Name, err))
|
||||||
|
@ -27,6 +27,7 @@ import (
|
|||||||
"k8s.io/api/core/v1"
|
"k8s.io/api/core/v1"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
"k8s.io/apimachinery/pkg/util/sets"
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
|
cloudprovider "k8s.io/cloud-provider"
|
||||||
servicehelpers "k8s.io/cloud-provider/service/helpers"
|
servicehelpers "k8s.io/cloud-provider/service/helpers"
|
||||||
"k8s.io/klog"
|
"k8s.io/klog"
|
||||||
)
|
)
|
||||||
@ -36,6 +37,10 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (g *Cloud) ensureInternalLoadBalancer(clusterName, clusterID string, svc *v1.Service, existingFwdRule *compute.ForwardingRule, nodes []*v1.Node) (*v1.LoadBalancerStatus, error) {
|
func (g *Cloud) ensureInternalLoadBalancer(clusterName, clusterID string, svc *v1.Service, existingFwdRule *compute.ForwardingRule, nodes []*v1.Node) (*v1.LoadBalancerStatus, error) {
|
||||||
|
if g.AlphaFeatureGate.Enabled("ILBSubsets") {
|
||||||
|
return nil, cloudprovider.NotImplemented
|
||||||
|
}
|
||||||
|
|
||||||
nm := types.NamespacedName{Name: svc.Name, Namespace: svc.Namespace}
|
nm := types.NamespacedName{Name: svc.Name, Namespace: svc.Namespace}
|
||||||
ports, protocol := getPortsAndProtocol(svc.Spec.Ports)
|
ports, protocol := getPortsAndProtocol(svc.Spec.Ports)
|
||||||
if protocol != v1.ProtocolTCP && protocol != v1.ProtocolUDP {
|
if protocol != v1.ProtocolTCP && protocol != v1.ProtocolUDP {
|
||||||
@ -201,6 +206,9 @@ func (g *Cloud) clearPreviousInternalResources(svc *v1.Service, loadBalancerName
|
|||||||
// updateInternalLoadBalancer is called when the list of nodes has changed. Therefore, only the instance groups
|
// updateInternalLoadBalancer is called when the list of nodes has changed. Therefore, only the instance groups
|
||||||
// and possibly the backend service need to be updated.
|
// and possibly the backend service need to be updated.
|
||||||
func (g *Cloud) updateInternalLoadBalancer(clusterName, clusterID string, svc *v1.Service, nodes []*v1.Node) error {
|
func (g *Cloud) updateInternalLoadBalancer(clusterName, clusterID string, svc *v1.Service, nodes []*v1.Node) error {
|
||||||
|
if g.AlphaFeatureGate.Enabled("ILBSubsets") {
|
||||||
|
return cloudprovider.NotImplemented
|
||||||
|
}
|
||||||
g.sharedResourceLock.Lock()
|
g.sharedResourceLock.Lock()
|
||||||
defer g.sharedResourceLock.Unlock()
|
defer g.sharedResourceLock.Unlock()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user