From e82ea2a68eeb7b8b15a93b1f3af06a1e4da763be Mon Sep 17 00:00:00 2001 From: Rahul Ganesh <31204974+rahulbabu95@users.noreply.github.com> Date: Thu, 2 May 2024 13:07:59 -0700 Subject: [PATCH] Update external etcd patch to use the right address type (#3139) * Patch external etcd address type on capi Signed-off-by: Rahul Ganesh * Update checksum and git version on patch Signed-off-by: Rahul Ganesh --------- Signed-off-by: Rahul Ganesh --- .../kubernetes-sigs/cluster-api/CHECKSUMS | 20 ++++----- .../0002-Add-unstacked-etcd-support.patch | 44 +++++++++++-------- 2 files changed, 36 insertions(+), 28 deletions(-) diff --git a/projects/kubernetes-sigs/cluster-api/CHECKSUMS b/projects/kubernetes-sigs/cluster-api/CHECKSUMS index dc74be74da..15f9042dbc 100644 --- a/projects/kubernetes-sigs/cluster-api/CHECKSUMS +++ b/projects/kubernetes-sigs/cluster-api/CHECKSUMS @@ -1,10 +1,10 @@ -6bba78988012aa87cb9183306d10251a1a3d0b60abb745b04d6e59867ad1ceb8 _output/bin/cluster-api/linux-amd64/cluster-api-provider-docker-manager -f45e064aa92a4b2cfa59790dcde0c84aaad11254280fa3945619ca136709279b _output/bin/cluster-api/linux-amd64/clusterctl -08c4257e4a09d5872a572d18d4fffef7949a06536abb73bee41163f7c106c696 _output/bin/cluster-api/linux-amd64/kubeadm-bootstrap-manager -636c057cdf5d9df954e40e9038b1d19910874330aa499254fe1dbbdd527cbab7 _output/bin/cluster-api/linux-amd64/kubeadm-control-plane-manager -be36d90a7072f27b8dccb4b89987b5477f31e63a119b80bac34b88330dbc666a _output/bin/cluster-api/linux-amd64/manager -6353550c01f81fb84508884c4f673ca8223687a574944a14ba7eee0bd8dd5aee _output/bin/cluster-api/linux-arm64/cluster-api-provider-docker-manager -dc65a837b71323d52fd07890f9a2f593ee2e9b457d52544dda366e51eb92ada8 _output/bin/cluster-api/linux-arm64/clusterctl -aa3b0e916d0810db6a202028264bc8a06f022725f640c44a1e4edf7d1c290e82 _output/bin/cluster-api/linux-arm64/kubeadm-bootstrap-manager -d6bf65b48674ad359001607fc3bc3c6bfdac529eef62330118187314aa1ecf82 _output/bin/cluster-api/linux-arm64/kubeadm-control-plane-manager -81ced85cf7ac15084268ea97b340cfb955a2ebe5b375317dc99c0a735d0216a7 _output/bin/cluster-api/linux-arm64/manager +97885516484c0cd2d17819caab87657f1558781cdd60460df9d43b99bafcaa1c _output/bin/cluster-api/linux-amd64/cluster-api-provider-docker-manager +c49708de56a97cd2c4bb1725638ce3a462fcd21e274e8d75f37b801e1ff0241e _output/bin/cluster-api/linux-amd64/clusterctl +8cb9fcbc71c4f0fd8e6a43bb22de3fef24641adc6c4ac30edb0c54944f37bfd5 _output/bin/cluster-api/linux-amd64/kubeadm-bootstrap-manager +f5d728ba39ca189ba472d4488b9c2406b436a8e19f5cbe723ec2fcabca8596e5 _output/bin/cluster-api/linux-amd64/kubeadm-control-plane-manager +f94f16b34f7958f5f3abfe03944e062d2d53e39595404a800bb388f933efa3ed _output/bin/cluster-api/linux-amd64/manager +5358d226dc97b98ac2337555f0053224cfb20f486997ee9d78e2fbec3ae340f4 _output/bin/cluster-api/linux-arm64/cluster-api-provider-docker-manager +98cf98ff3e4b5faad7143d208228ae75bfefd6546fb68ef84b59c7fb87614272 _output/bin/cluster-api/linux-arm64/clusterctl +0062cd1a92139ce6fabdaab1b07ccfedb4e5b007b8b6cca0695caae4f62abcbb _output/bin/cluster-api/linux-arm64/kubeadm-bootstrap-manager +22eff299bbdca8ebd334cb198172f6ce3ac5902a96dde08d8d4d14e4bdead4ff _output/bin/cluster-api/linux-arm64/kubeadm-control-plane-manager +b7b52050eb621d612f23e982629efae2893b15d4f6cffac1b2bc147ae13950b3 _output/bin/cluster-api/linux-arm64/manager diff --git a/projects/kubernetes-sigs/cluster-api/patches/0002-Add-unstacked-etcd-support.patch b/projects/kubernetes-sigs/cluster-api/patches/0002-Add-unstacked-etcd-support.patch index e00a9b82b5..62eaa06296 100644 --- a/projects/kubernetes-sigs/cluster-api/patches/0002-Add-unstacked-etcd-support.patch +++ b/projects/kubernetes-sigs/cluster-api/patches/0002-Add-unstacked-etcd-support.patch @@ -1,4 +1,4 @@ -From 84d971991787d5f4a445432f58704d9216b8983d Mon Sep 17 00:00:00 2001 +From f248f2cd01d1b22ccbee25fa986998fe71e56ebc Mon Sep 17 00:00:00 2001 From: Rajashree Mandaogane Date: Mon, 28 Jun 2021 13:44:50 -0700 Subject: [PATCH 02/37] Add unstacked etcd support @@ -85,13 +85,13 @@ commits on the new 1.0.1 branch. This commit adds back the permission. .../cluster/cluster_controller_test.go | 136 +++++++++++++++++ .../machine/machine_controller_noderef.go | 8 + .../machine_controller_noderef_test.go | 48 ++++++ - .../machine/machine_controller_phases.go | 115 ++++++++++++++ + .../machine/machine_controller_phases.go | 123 +++++++++++++++ .../controllers/dockermachine_controller.go | 35 +++-- util/collections/machine_filters.go | 26 ++++ util/secret/certificates.go | 3 + util/secret/consts.go | 2 + util/util.go | 6 + - 25 files changed, 882 insertions(+), 22 deletions(-) + 25 files changed, 890 insertions(+), 22 deletions(-) diff --git a/api/v1beta1/cluster_types.go b/api/v1beta1/cluster_types.go index 12c258f22..680e99731 100644 @@ -1264,7 +1264,7 @@ index 48ebcabf3..9a150640d 100644 + } +} diff --git a/internal/controllers/machine/machine_controller_phases.go b/internal/controllers/machine/machine_controller_phases.go -index 1bd41f4d8..32cddef3d 100644 +index 1bd41f4d8..e3cbf6932 100644 --- a/internal/controllers/machine/machine_controller_phases.go +++ b/internal/controllers/machine/machine_controller_phases.go @@ -19,6 +19,7 @@ package machine @@ -1289,7 +1289,7 @@ index 1bd41f4d8..32cddef3d 100644 // Set the phase to "failed" if any of Status.FailureReason or Status.FailureMessage is not-nil. if m.Status.FailureReason != nil || m.Status.FailureMessage != nil { m.Status.SetTypedPhase(clusterv1.MachinePhaseFailed) -@@ -321,6 +329,113 @@ func (r *Reconciler) reconcileInfrastructure(ctx context.Context, s *scope) (ctr +@@ -321,6 +329,121 @@ func (r *Reconciler) reconcileInfrastructure(ctx context.Context, s *scope) (ctr return ctrl.Result{}, errors.Wrapf(err, "failed to retrieve addresses from infrastructure provider for Machine %q in namespace %q", m.Name, m.Namespace) } @@ -1320,21 +1320,29 @@ index 1bd41f4d8..32cddef3d 100644 + if err := r.Client.Get(ctx, client.ObjectKey{Namespace: cluster.Namespace, Name: etcdSecretName}, existingSecret); err != nil { + if apierrors.IsNotFound(err) { + // secret doesn't exist, so create it for the init machine -+ var machineIP string ++ var internalIP, internalDNS, externalIP, externalDNS, machineIP string + for _, address := range m.Status.Addresses { -+ if address.Type == clusterv1.MachineInternalIP || address.Type == clusterv1.MachineInternalDNS { -+ machineIP = address.Address -+ break ++ switch address.Type { ++ case clusterv1.MachineInternalIP: ++ internalIP = address.Address ++ case clusterv1.MachineInternalDNS: ++ internalDNS = address.Address ++ case clusterv1.MachineExternalIP: ++ externalIP = address.Address ++ case clusterv1.MachineExternalDNS: ++ externalDNS = address.Address + } + } + -+ if machineIP == "" { -+ for _, address := range m.Status.Addresses { -+ if address.Type == clusterv1.MachineExternalIP || address.Type == clusterv1.MachineExternalDNS { -+ machineIP = address.Address -+ break -+ } -+ } ++ // The order of these checks determines the precedence of the address to use ++ if externalDNS != "" { ++ machineIP = externalDNS ++ } else if externalIP != "" { ++ machineIP = externalIP ++ } else if internalDNS != "" { ++ machineIP = internalDNS ++ } else if internalIP != "" { ++ machineIP = internalIP + } + + if machineIP == "" { @@ -1458,7 +1466,7 @@ index 8b517275a..029c5614b 100644 + return ok +} diff --git a/util/collections/machine_filters.go b/util/collections/machine_filters.go -index 775e9a8b8..0e52c4f45 100644 +index 6c0c7813a..aa585b6ec 100644 --- a/util/collections/machine_filters.go +++ b/util/collections/machine_filters.go @@ -122,6 +122,18 @@ func ControlPlaneMachines(clusterName string) func(machine *clusterv1.Machine) b @@ -1480,7 +1488,7 @@ index 775e9a8b8..0e52c4f45 100644 // AdoptableControlPlaneMachines returns a filter to find all un-controlled control plane machines. // Usage: GetFilteredMachinesForCluster(ctx, client, cluster, AdoptableControlPlaneMachines(cluster.Name, controlPlane)). func AdoptableControlPlaneMachines(clusterName string) func(machine *clusterv1.Machine) bool { -@@ -225,6 +237,20 @@ func ControlPlaneSelectorForCluster(clusterName string) labels.Selector { +@@ -261,6 +273,20 @@ func ControlPlaneSelectorForCluster(clusterName string) labels.Selector { ) }