@@ -58,74 +58,9 @@ var _ = Describe("KubeadmConfigReconciler", func() {
58
58
Expect (err ).To (Succeed ())
59
59
Expect (result .Requeue ).To (BeFalse ())
60
60
})
61
- /*
62
- When apimachinery decodes into a typed struct, the decoder strips the TypeMeta from the object;
63
- the theory at the time being that because it was a typed object, you knew its API version, group, and kind.
64
- if fact this leads to errors with k8sClient, because it loses GVK, and this leads r.Status().Patch to fail
65
- with "the server could not find the requested resource (patch kubeadmconfigs.bootstrap.cluster.x-k8s.io control-plane-config)"
66
-
67
- There's a WIP PR to k/k to fix this.
68
- After this merge, we can implement more behavioral test
69
-
70
- It("should process only control plane machines when infrastructure is ready but control plane is not", func() {
71
- cluster := newCluster("cluster2")
72
- Expect(k8sClient.Create(context.Background(), cluster)).To(Succeed())
73
- cluster.Status.InfrastructureReady = true
74
- Expect(k8sClient.Status().Update(context.Background(), cluster)).To(Succeed())
75
-
76
- controlplaneMachine := newMachine(cluster, "control-plane")
77
- controlplaneMachine.ObjectMeta.Labels[clusterv1alpha2.MachineControlPlaneLabelName] = "true"
78
- Expect(k8sClient.Create(context.Background(), controlplaneMachine)).To(Succeed())
79
-
80
- controlplaneConfig := newKubeadmConfig(controlplaneMachine, "control-plane-config")
81
- controlplaneConfig.Spec.ClusterConfiguration = &kubeadmv1beta1.ClusterConfiguration{}
82
- controlplaneConfig.Spec.InitConfiguration = &kubeadmv1beta1.InitConfiguration{}
83
- Expect(k8sClient.Create(context.Background(), controlplaneConfig)).To(Succeed())
84
-
85
- workerMachine := newMachine(cluster, "worker")
86
- Expect(k8sClient.Create(context.Background(), workerMachine)).To(Succeed())
87
-
88
- workerConfig := newKubeadmConfig(workerMachine, "worker-config")
89
- Expect(k8sClient.Create(context.Background(), workerConfig)).To(Succeed())
90
-
91
- reconciler := KubeadmConfigReconciler{
92
- Log: log.Log,
93
- Client: k8sClient,
94
- }
95
-
96
- By("Calling reconcile on a config corresponding to worker node should requeue")
97
- resultWorker, err := reconciler.Reconcile(ctrl.Request{
98
- NamespacedName: types.NamespacedName{
99
- Namespace: "default",
100
- Name: "worker-config",
101
- },
102
- })
103
- Expect(err).To(Succeed())
104
- Expect(resultWorker.Requeue).To(BeFalse())
105
- Expect(resultWorker.RequeueAfter).To(Equal(30 * time.Second))
106
-
107
- By("Calling reconcile on a config corresponding to a control plane node should create BootstrapData")
108
- resultControlPlane, err := reconciler.Reconcile(ctrl.Request{
109
- NamespacedName: types.NamespacedName{
110
- Namespace: "default",
111
- Name: "control-plane-config",
112
- },
113
- })
114
- Expect(err).To(Succeed())
115
- Expect(resultControlPlane.Requeue).To(BeFalse())
116
- Expect(resultControlPlane.RequeueAfter).To(BeZero())
117
-
118
- controlplaneConfigAfter, err := getKubeadmConfig(k8sClient, "control-plane-config")
119
- Expect(err).To(Succeed())
120
- Expect(controlplaneConfigAfter.Status.Ready).To(BeTrue())
121
- Expect(controlplaneConfigAfter.Status.BootstrapData).NotTo(BeEmpty())
122
- })
123
- */
124
61
})
125
62
})
126
63
127
- // test utils
128
-
129
64
// getKubeadmConfig returns a KubeadmConfig object from the cluster
130
65
func getKubeadmConfig (c client.Client , name string ) (* bootstrapv1.KubeadmConfig , error ) {
131
66
ctx := context .Background ()
0 commit comments