8
8
"context"
9
9
"fmt"
10
10
"strings"
11
+ "time"
11
12
12
13
controlplanev1 "github.com/siderolabs/cluster-api-control-plane-provider-talos/api/v1alpha3"
13
14
"github.com/siderolabs/talos/pkg/machinery/api/machine"
@@ -17,6 +18,10 @@ import (
17
18
)
18
19
19
20
func (r * TalosControlPlaneReconciler ) etcdHealthcheck (ctx context.Context , tcp * controlplanev1.TalosControlPlane , cluster * clusterv1.Cluster , ownedMachines []clusterv1.Machine ) error {
21
+ ctx , cancel := context .WithTimeout (ctx , time .Second * 5 )
22
+
23
+ defer cancel ()
24
+
20
25
machines := []clusterv1.Machine {}
21
26
22
27
for _ , machine := range ownedMachines {
@@ -98,6 +103,10 @@ func (r *TalosControlPlaneReconciler) etcdHealthcheck(ctx context.Context, tcp *
98
103
// gracefulEtcdLeave removes a given machine from the etcd cluster by forfeiting leadership
99
104
// and issuing a "leave" request from the machine itself.
100
105
func (r * TalosControlPlaneReconciler ) gracefulEtcdLeave (ctx context.Context , c * talosclient.Client , cluster client.ObjectKey , machineToLeave clusterv1.Machine ) error {
106
+ ctx , cancel := context .WithTimeout (ctx , time .Second * 5 )
107
+
108
+ defer cancel ()
109
+
101
110
r .Log .Info ("verifying etcd status" , "machine" , machineToLeave .Name , "node" , machineToLeave .Status .NodeRef .Name )
102
111
103
112
svcs , err := c .ServiceInfo (ctx , "etcd" )
@@ -129,6 +138,10 @@ func (r *TalosControlPlaneReconciler) gracefulEtcdLeave(ctx context.Context, c *
129
138
// forceEtcdLeave removes a given machine from the etcd cluster by telling another CP node to remove the member.
130
139
// This is used in times when the machine was deleted out from under us.
131
140
func (r * TalosControlPlaneReconciler ) forceEtcdLeave (ctx context.Context , c * talosclient.Client , cluster client.ObjectKey , memberName string ) error {
141
+ ctx , cancel := context .WithTimeout (ctx , time .Second * 5 )
142
+
143
+ defer cancel ()
144
+
132
145
r .Log .Info ("removing etcd member" , "memberName" , memberName )
133
146
134
147
return c .EtcdRemoveMember (
@@ -142,6 +155,10 @@ func (r *TalosControlPlaneReconciler) forceEtcdLeave(ctx context.Context, c *tal
142
155
// auditEtcd rolls through all etcd members to see if there's a matching controlplane machine
143
156
// It uses the first controlplane node returned as the etcd endpoint
144
157
func (r * TalosControlPlaneReconciler ) auditEtcd (ctx context.Context , tcp * controlplanev1.TalosControlPlane , cluster client.ObjectKey , cpName string ) error {
158
+ ctx , cancel := context .WithTimeout (ctx , time .Second * 5 )
159
+
160
+ defer cancel ()
161
+
145
162
machines , err := r .getControlPlaneMachinesForCluster (ctx , cluster , cpName )
146
163
if err != nil {
147
164
return err
0 commit comments