From 36d290140b9e4fdd745d65c36f1b352b2ae391c4 Mon Sep 17 00:00:00 2001 From: Matthias Teich Date: Fri, 5 Jan 2024 09:20:20 +0100 Subject: [PATCH 1/4] Prevent the creation of multiple servers per machine --- cmd/main.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index 0ccf0da..0bb376e 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -22,6 +22,7 @@ import ( "github.com/GDATASoftwareAG/cluster-api-provider-ionoscloud/internal/context" "github.com/GDATASoftwareAG/cluster-api-provider-ionoscloud/internal/ionos" "os" + "sigs.k8s.io/controller-runtime/pkg/client" // Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.) // to ensure that exec-entrypoint and run can make use of them. @@ -71,9 +72,19 @@ func main() { ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts))) mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{ - Scheme: scheme, - MetricsBindAddress: metricsAddr, - Port: 9443, + Scheme: scheme, + MetricsBindAddress: metricsAddr, + Port: 9443, + /* if we retrieve IONOSCloudMachine from the cache we occasionally get outdated data, + which leads to the creation of multiple servers for a single IONOSCloudMachine, + because we check ProviderID to decide if we need to create a new server*/ + Client: client.Options{ + Cache: &client.CacheOptions{ + DisableFor: []client.Object{ + &infrastructurev1alpha1.IONOSCloudMachine{}, + }, + }, + }, HealthProbeBindAddress: probeAddr, LeaderElection: enableLeaderElection, LeaderElectionID: "2606507e.cluster.x-k8s.io", From 7754adfaf901e912ff417f74604eec073ed495c2 Mon Sep 17 00:00:00 2001 From: Matthias Teich Date: Fri, 5 Jan 2024 09:20:20 +0100 Subject: [PATCH 2/4] Prevent the creation of multiple servers per machine --- cmd/main.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/cmd/main.go b/cmd/main.go index d801767..5e5b5b8 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -22,6 +22,7 @@ import ( "github.com/GDATASoftwareAG/cluster-api-provider-ionoscloud/internal/context" "github.com/GDATASoftwareAG/cluster-api-provider-ionoscloud/internal/ionos" "os" + "sigs.k8s.io/controller-runtime/pkg/client" // Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.) // to ensure that exec-entrypoint and run can make use of them. @@ -72,7 +73,17 @@ func main() { ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts))) mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{ - Scheme: scheme, + Scheme: scheme, + /* if we retrieve IONOSCloudMachine from the cache we occasionally get outdated data, + which leads to the creation of multiple servers for a single IONOSCloudMachine, + because we check ProviderID to decide if we need to create a new server*/ + Client: client.Options{ + Cache: &client.CacheOptions{ + DisableFor: []client.Object{ + &infrastructurev1alpha1.IONOSCloudMachine{}, + }, + }, + }, Metrics: metricsserver.Options{BindAddress: metricsAddr}, HealthProbeBindAddress: probeAddr, LeaderElection: enableLeaderElection, From c65c33ca6cf85cd6ffca16b811c7b2c178de070c Mon Sep 17 00:00:00 2001 From: Matthias Teich Date: Fri, 5 Jan 2024 09:58:46 +0100 Subject: [PATCH 3/4] fix update of controller runtime --- cmd/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/main.go b/cmd/main.go index 5e5b5b8..6a5e9c7 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -73,7 +73,7 @@ func main() { ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts))) mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{ - Scheme: scheme, + Scheme: scheme, /* if we retrieve IONOSCloudMachine from the cache we occasionally get outdated data, which leads to the creation of multiple servers for a single IONOSCloudMachine, because we check ProviderID to decide if we need to create a new server*/ From 8b26f6747ecae7c4266ef3f8a89c613b4a192bcf Mon Sep 17 00:00:00 2001 From: Matthias Teich Date: Fri, 5 Jan 2024 11:23:22 +0100 Subject: [PATCH 4/4] fix update of controller runtime --- cmd/main.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd/main.go b/cmd/main.go index d9e0777..6a5e9c7 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -22,6 +22,7 @@ import ( "github.com/GDATASoftwareAG/cluster-api-provider-ionoscloud/internal/context" "github.com/GDATASoftwareAG/cluster-api-provider-ionoscloud/internal/ionos" "os" + "sigs.k8s.io/controller-runtime/pkg/client" // Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.) // to ensure that exec-entrypoint and run can make use of them.