Skip to content

Commit

Permalink
feat: support talosVersion in TalosControlPlane CRD
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
rsmitty committed Feb 17, 2021
1 parent 7d5a132 commit f610e84
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 127 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ spec:
type: string
generateType:
type: string
talosVersion:
type: string
required:
- generateType
type: object
Expand All @@ -112,6 +114,8 @@ spec:
type: string
generateType:
type: string
talosVersion:
type: string
required:
- generateType
type: object
Expand Down
15 changes: 6 additions & 9 deletions controllers/taloscontrolplane_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,14 +355,14 @@ func (r *TalosControlPlaneReconciler) scaleDownControlPlane(ctx context.Context,
if !machine.ObjectMeta.DeletionTimestamp.IsZero() {
r.Log.Info("Machine is in process of deletion", "machine", machine.Name)

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

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

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

var address string

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

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

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

ctx, cancel := context.WithTimeout(ctx, 15*time.Second)
defer cancel()

node, err := clientset.CoreV1().Nodes().Get(ctx, ownedMachine.Status.NodeRef.Name, metav1.GetOptions{})
node, err := clientset.CoreV1().Nodes().Get(ownedMachine.Status.NodeRef.Name, metav1.GetOptions{})
if err != nil {
return fmt.Errorf("failed to get node %q: %w", node.Name, err)
}
Expand Down Expand Up @@ -739,7 +736,7 @@ func (r *TalosControlPlaneReconciler) updateStatus(ctx context.Context, tcp *con
// We consider ourselves "initialized" if the workload cluster returns any number of nodes.
// We also do not return client list errors (just log them) as it's expected that it will fail
// for a while until the cluster is up.
nodeList, err := clientset.CoreV1().Nodes().List(ctx, metav1.ListOptions{})
nodeList, err := clientset.CoreV1().Nodes().List(metav1.ListOptions{})
if err == nil {
if len(nodeList.Items) > 0 {
tcp.Status.Initialized = true
Expand Down
18 changes: 9 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ go 1.13
require (
cloud.google.com/go v0.47.0 // indirect
github.com/go-logr/logr v0.1.0
github.com/golang/protobuf v1.4.2
github.com/golang/protobuf v1.4.3
github.com/onsi/ginkgo v1.12.1
github.com/onsi/gomega v1.10.1
github.com/pkg/errors v0.9.1
github.com/talos-systems/cluster-api-bootstrap-provider-talos v0.2.0-alpha.8
github.com/talos-systems/talos/pkg/machinery v0.0.0-20201203014938-ed31056d91d0
k8s.io/api v0.18.6
k8s.io/apimachinery v0.18.6
k8s.io/apiserver v0.18.6
k8s.io/client-go v0.18.6
github.com/talos-systems/cluster-api-bootstrap-provider-talos v0.2.0-alpha.10
github.com/talos-systems/talos/pkg/machinery v0.0.0-20210216142802-8d7a36cc0cc2
k8s.io/api v0.17.9
k8s.io/apimachinery v0.17.9
k8s.io/apiserver v0.17.9
k8s.io/client-go v0.17.9
k8s.io/utils v0.0.0-20200619165400-6e3d28b6ed19
sigs.k8s.io/cluster-api v0.3.9
sigs.k8s.io/controller-runtime v0.6.3
sigs.k8s.io/cluster-api v0.3.12
sigs.k8s.io/controller-runtime v0.5.14
)
Loading

0 comments on commit f610e84

Please sign in to comment.