From 57690b081c6b5b5050f366123a7b9892d2cd912e Mon Sep 17 00:00:00 2001 From: Lothar Bach Date: Tue, 17 Dec 2024 12:52:10 +0100 Subject: [PATCH 1/2] filter terraform output routerIP for v4 addresses only and return only one of them just in case there could be multiples, since the rest of the code currently expects a single v4 IP --- pkg/internal/infrastructure/templates/main.tpl.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/internal/infrastructure/templates/main.tpl.tf b/pkg/internal/infrastructure/templates/main.tpl.tf index 596a21ec1..13072b4c2 100644 --- a/pkg/internal/infrastructure/templates/main.tpl.tf +++ b/pkg/internal/infrastructure/templates/main.tpl.tf @@ -229,8 +229,8 @@ data.openstack_networking_network_v2.cluster.name {{- end -}} {{- define "router-ip" -}} {{ if .create.router -}} -openstack_networking_router_v2.router.external_fixed_ip[0].ip_address +one([for external_fixed_ip in openstack_networking_router_v2.router.external_fixed_ip : external_fixed_ip.ip_address if can(regex("^(?:[0-9]{1,3}\\.){3}[0-9]{1,3}$", external_fixed_ip.ip_address))]) {{ else -}} -data.openstack_networking_router_v2.router.external_fixed_ip[0].ip_address +one([for external_fixed_ip in data.openstack_networking_router_v2.router.external_fixed_ip : external_fixed_ip.ip_address if can(regex("^(?:[0-9]{1,3}\\.){3}[0-9]{1,3}$", external_fixed_ip.ip_address))]) {{ end -}} {{- end -}} From 108532ae76faddf69f3949d213093aa146b74122 Mon Sep 17 00:00:00 2001 From: Lothar Bach Date: Thu, 16 Jan 2025 09:28:25 +0100 Subject: [PATCH 2/2] Add comment and link to issue --- pkg/internal/infrastructure/templates/main.tpl.tf | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/internal/infrastructure/templates/main.tpl.tf b/pkg/internal/infrastructure/templates/main.tpl.tf index 13072b4c2..f6624a640 100644 --- a/pkg/internal/infrastructure/templates/main.tpl.tf +++ b/pkg/internal/infrastructure/templates/main.tpl.tf @@ -227,6 +227,12 @@ openstack_networking_network_v2.cluster.name data.openstack_networking_network_v2.cluster.name {{ end -}} {{- end -}} + +// Openstack API could return an IPv6 external IP even for v4-only clusters see +// https://github.com/gardener/gardener-extension-provider-openstack/issues/897 +// We filter for IPs that match the v4 pattern (4 numbers seperated by dots) +// and only return one just in case there are mulitple as the rest of the +// codebase is currently expecting a single v4 IP {{- define "router-ip" -}} {{ if .create.router -}} one([for external_fixed_ip in openstack_networking_router_v2.router.external_fixed_ip : external_fixed_ip.ip_address if can(regex("^(?:[0-9]{1,3}\\.){3}[0-9]{1,3}$", external_fixed_ip.ip_address))])