Skip to content

Commit f610e84

Browse files
committed
feat: support talosVersion in TalosControlPlane CRD
This PR imports a later version of the bootstrap provider, so that we can support the `talosVersion` field when specifying config gen options for controlplane nodes. It should also be noted that, because of the use of some util packages in the cluster API code, we needed to drop down our go mod versions for kubernetes. No big changes here, just removing some contexts that aren't supported in 1.17.x. We'll move these back up when CAPI moves up too. Signed-off-by: Spencer Smith <[email protected]>
1 parent 7d5a132 commit f610e84

File tree

4 files changed

+79
-127
lines changed

4 files changed

+79
-127
lines changed

config/crd/bases/controlplane.cluster.x-k8s.io_taloscontrolplanes.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ spec:
8888
type: string
8989
generateType:
9090
type: string
91+
talosVersion:
92+
type: string
9193
required:
9294
- generateType
9395
type: object
@@ -112,6 +114,8 @@ spec:
112114
type: string
113115
generateType:
114116
type: string
117+
talosVersion:
118+
type: string
115119
required:
116120
- generateType
117121
type: object

controllers/taloscontrolplane_controller.go

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -355,14 +355,14 @@ func (r *TalosControlPlaneReconciler) scaleDownControlPlane(ctx context.Context,
355355
if !machine.ObjectMeta.DeletionTimestamp.IsZero() {
356356
r.Log.Info("Machine is in process of deletion", "machine", machine.Name)
357357

358-
node, err := clientset.CoreV1().Nodes().Get(ctx, machine.Status.NodeRef.Name, metav1.GetOptions{})
358+
node, err := clientset.CoreV1().Nodes().Get(machine.Status.NodeRef.Name, metav1.GetOptions{})
359359
if err != nil {
360360
return ctrl.Result{RequeueAfter: 20 * time.Second}, err
361361
}
362362

363363
r.Log.Info("Deleting node", "machine", machine.Name, "node", node.Name)
364364

365-
err = clientset.CoreV1().Nodes().Delete(ctx, node.Name, metav1.DeleteOptions{})
365+
err = clientset.CoreV1().Nodes().Delete(node.Name, &metav1.DeleteOptions{})
366366
if err != nil {
367367
return ctrl.Result{RequeueAfter: 20 * time.Second}, err
368368
}
@@ -381,7 +381,7 @@ func (r *TalosControlPlaneReconciler) scaleDownControlPlane(ctx context.Context,
381381

382382
var address string
383383

384-
node, err := clientset.CoreV1().Nodes().Get(ctx, oldest.Status.NodeRef.Name, metav1.GetOptions{})
384+
node, err := clientset.CoreV1().Nodes().Get(oldest.Status.NodeRef.Name, metav1.GetOptions{})
385385
if err != nil {
386386
return ctrl.Result{RequeueAfter: 20 * time.Second}, err
387387
}
@@ -480,7 +480,7 @@ func (r *TalosControlPlaneReconciler) scaleDownControlPlane(ctx context.Context,
480480

481481
r.Log.Info("Deleting node", "machine", oldest.Name, "node", node.Name)
482482

483-
err = clientset.CoreV1().Nodes().Delete(ctx, node.Name, metav1.DeleteOptions{})
483+
err = clientset.CoreV1().Nodes().Delete(node.Name, &metav1.DeleteOptions{})
484484
if err != nil {
485485
return ctrl.Result{RequeueAfter: 20 * time.Second}, err
486486
}
@@ -695,10 +695,7 @@ func (r *TalosControlPlaneReconciler) updateStatus(ctx context.Context, tcp *con
695695
return fmt.Errorf("machine %q does not have a noderef", ownedMachine.Name)
696696
}
697697

698-
ctx, cancel := context.WithTimeout(ctx, 15*time.Second)
699-
defer cancel()
700-
701-
node, err := clientset.CoreV1().Nodes().Get(ctx, ownedMachine.Status.NodeRef.Name, metav1.GetOptions{})
698+
node, err := clientset.CoreV1().Nodes().Get(ownedMachine.Status.NodeRef.Name, metav1.GetOptions{})
702699
if err != nil {
703700
return fmt.Errorf("failed to get node %q: %w", node.Name, err)
704701
}
@@ -739,7 +736,7 @@ func (r *TalosControlPlaneReconciler) updateStatus(ctx context.Context, tcp *con
739736
// We consider ourselves "initialized" if the workload cluster returns any number of nodes.
740737
// We also do not return client list errors (just log them) as it's expected that it will fail
741738
// for a while until the cluster is up.
742-
nodeList, err := clientset.CoreV1().Nodes().List(ctx, metav1.ListOptions{})
739+
nodeList, err := clientset.CoreV1().Nodes().List(metav1.ListOptions{})
743740
if err == nil {
744741
if len(nodeList.Items) > 0 {
745742
tcp.Status.Initialized = true

go.mod

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@ go 1.13
55
require (
66
cloud.google.com/go v0.47.0 // indirect
77
github.com/go-logr/logr v0.1.0
8-
github.com/golang/protobuf v1.4.2
8+
github.com/golang/protobuf v1.4.3
99
github.com/onsi/ginkgo v1.12.1
1010
github.com/onsi/gomega v1.10.1
1111
github.com/pkg/errors v0.9.1
12-
github.com/talos-systems/cluster-api-bootstrap-provider-talos v0.2.0-alpha.8
13-
github.com/talos-systems/talos/pkg/machinery v0.0.0-20201203014938-ed31056d91d0
14-
k8s.io/api v0.18.6
15-
k8s.io/apimachinery v0.18.6
16-
k8s.io/apiserver v0.18.6
17-
k8s.io/client-go v0.18.6
12+
github.com/talos-systems/cluster-api-bootstrap-provider-talos v0.2.0-alpha.10
13+
github.com/talos-systems/talos/pkg/machinery v0.0.0-20210216142802-8d7a36cc0cc2
14+
k8s.io/api v0.17.9
15+
k8s.io/apimachinery v0.17.9
16+
k8s.io/apiserver v0.17.9
17+
k8s.io/client-go v0.17.9
1818
k8s.io/utils v0.0.0-20200619165400-6e3d28b6ed19
19-
sigs.k8s.io/cluster-api v0.3.9
20-
sigs.k8s.io/controller-runtime v0.6.3
19+
sigs.k8s.io/cluster-api v0.3.12
20+
sigs.k8s.io/controller-runtime v0.5.14
2121
)

0 commit comments

Comments
 (0)