Skip to content

Commit

Permalink
fix: KubeadmControlPlane controller crash if infra template is not found
Browse files Browse the repository at this point in the history
Signed-off-by: Fan Shang Xiang <[email protected]>
  • Loading branch information
MartinForReal committed Mar 23, 2020
1 parent 35f28e9 commit 4fc4bee
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
1 change: 0 additions & 1 deletion bootstrap/kubeadm/api/v1alpha2/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ func Convert_v1alpha3_KubeadmConfigStatus_To_v1alpha2_KubeadmConfigStatus(in *ku
return nil
}


// Convert_v1alpha2_KubeadmConfigSpec_To_v1alpha3_KubeadmConfigSpec converts this KubeadmConfigSpec to the Hub version (v1alpha3).
func Convert_v1alpha2_KubeadmConfigSpec_To_v1alpha3_KubeadmConfigSpec(in *KubeadmConfigSpec, out *kubeadmbootstrapv1alpha3.KubeadmConfigSpec, s apiconversion.Scope) error {
return autoConvert_v1alpha2_KubeadmConfigSpec_To_v1alpha3_KubeadmConfigSpec(in, out, s)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ const (
// DependentCertRequeueAfter is how long to wait before checking again to see if
// dependent certificates have been created.
DependentCertRequeueAfter = 30 * time.Second

// DependentInfraTemplateRequeueAfter is how long to wait before checking again to see if
// dependent InfraTemplate have been created.
DependentInfraTemplateRequeueAfter = 30 * time.Second
)

// +kubebuilder:rbac:groups=core,resources=events,verbs=get;list;watch;create;patch
Expand Down Expand Up @@ -150,6 +154,11 @@ func (r *KubeadmControlPlaneReconciler) Reconcile(req ctrl.Request) (res ctrl.Re
return ctrl.Result{}, nil
}

// Make sure to reconcile the external infrastructure reference.
if err := r.reconcileExternalReference(ctx, cluster, kcp.Spec.InfrastructureTemplate); err != nil {
return ctrl.Result{RequeueAfter: DependentInfraTemplateRequeueAfter}, err
}

// Initialize the patch helper.
patchHelper, err := patch.NewHelper(kcp, r.Client)
if err != nil {
Expand Down Expand Up @@ -196,11 +205,6 @@ func (r *KubeadmControlPlaneReconciler) reconcile(ctx context.Context, cluster *
// If object doesn't have a finalizer, add one.
controllerutil.AddFinalizer(kcp, controlplanev1.KubeadmControlPlaneFinalizer)

// Make sure to reconcile the external infrastructure reference.
if err := r.reconcileExternalReference(ctx, cluster, kcp.Spec.InfrastructureTemplate); err != nil {
return ctrl.Result{}, err
}

// Generate Cluster Certificates if needed
config := kcp.Spec.KubeadmConfigSpec.DeepCopy()
config.JoinConfiguration = nil
Expand Down

0 comments on commit 4fc4bee

Please sign in to comment.