mirror of
https://github.com/kubernetes-sigs/external-dns.git
synced 2025-08-06 09:36:58 +02:00
Fix deletion of DNS Records for VirtualServices on error
This commit is contained in:
parent
d2dd32abbc
commit
d56ad7f683
@ -187,16 +187,16 @@ func (sc *virtualServiceSource) AddEventHandler(ctx context.Context, handler fun
|
|||||||
sc.virtualserviceInformer.Informer().AddEventHandler(eventHandlerFunc(handler))
|
sc.virtualserviceInformer.Informer().AddEventHandler(eventHandlerFunc(handler))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sc *virtualServiceSource) getGateway(ctx context.Context, gatewayStr string, virtualService *networkingv1alpha3.VirtualService) *networkingv1alpha3.Gateway {
|
func (sc *virtualServiceSource) getGateway(ctx context.Context, gatewayStr string, virtualService *networkingv1alpha3.VirtualService) (*networkingv1alpha3.Gateway, error) {
|
||||||
if gatewayStr == "" || gatewayStr == IstioMeshGateway {
|
if gatewayStr == "" || gatewayStr == IstioMeshGateway {
|
||||||
// This refers to "all sidecars in the mesh"; ignore.
|
// This refers to "all sidecars in the mesh"; ignore.
|
||||||
return nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace, name, err := parseGateway(gatewayStr)
|
namespace, name, err := parseGateway(gatewayStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Debugf("Failed parsing gatewayStr %s of VirtualService %s/%s", gatewayStr, virtualService.Namespace, virtualService.Name)
|
log.Debugf("Failed parsing gatewayStr %s of VirtualService %s/%s", gatewayStr, virtualService.Namespace, virtualService.Name)
|
||||||
return nil
|
return nil, err
|
||||||
}
|
}
|
||||||
if namespace == "" {
|
if namespace == "" {
|
||||||
namespace = virtualService.Namespace
|
namespace = virtualService.Namespace
|
||||||
@ -205,14 +205,14 @@ func (sc *virtualServiceSource) getGateway(ctx context.Context, gatewayStr strin
|
|||||||
gateway, err := sc.istioClient.NetworkingV1alpha3().Gateways(namespace).Get(ctx, name, metav1.GetOptions{})
|
gateway, err := sc.istioClient.NetworkingV1alpha3().Gateways(namespace).Get(ctx, name, metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("Failed retrieving gateway %s referenced by VirtualService %s/%s: %v", gatewayStr, virtualService.Namespace, virtualService.Name, err)
|
log.Errorf("Failed retrieving gateway %s referenced by VirtualService %s/%s: %v", gatewayStr, virtualService.Namespace, virtualService.Name, err)
|
||||||
return nil
|
return nil, err
|
||||||
}
|
}
|
||||||
if gateway == nil {
|
if gateway == nil {
|
||||||
log.Debugf("Gateway %s referenced by VirtualService %s/%s not found: %v", gatewayStr, virtualService.Namespace, virtualService.Name, err)
|
log.Debugf("Gateway %s referenced by VirtualService %s/%s not found: %v", gatewayStr, virtualService.Namespace, virtualService.Name, err)
|
||||||
return nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return gateway
|
return gateway, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sc *virtualServiceSource) endpointsFromTemplate(ctx context.Context, virtualService *networkingv1alpha3.VirtualService) ([]*endpoint.Endpoint, error) {
|
func (sc *virtualServiceSource) endpointsFromTemplate(ctx context.Context, virtualService *networkingv1alpha3.VirtualService) ([]*endpoint.Endpoint, error) {
|
||||||
@ -290,7 +290,10 @@ func (sc *virtualServiceSource) targetsFromVirtualService(ctx context.Context, v
|
|||||||
var targets []string
|
var targets []string
|
||||||
// for each host we need to iterate through the gateways because each host might match for only one of the gateways
|
// for each host we need to iterate through the gateways because each host might match for only one of the gateways
|
||||||
for _, gateway := range virtualService.Spec.Gateways {
|
for _, gateway := range virtualService.Spec.Gateways {
|
||||||
gateway := sc.getGateway(ctx, gateway, virtualService)
|
gateway, err := sc.getGateway(ctx, gateway, virtualService)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
if gateway == nil {
|
if gateway == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user