Skip to content
This repository was archived by the owner on Jul 30, 2021. It is now read-only.

fix: ensure there's a token to refresh #267

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion controllers/kubeadmconfig_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func (r *KubeadmConfigReconciler) Reconcile(req ctrl.Request) (_ ctrl.Result, re
err = patchHelper.Patch(ctx, config)
return ctrl.Result{}, err
// If we've already embedded a time-limited join token into a config, but are still waiting for the token to be used, refresh it
case config.Status.Ready:
case config.Status.Ready && (config.Spec.JoinConfiguration != nil && config.Spec.JoinConfiguration.Discovery.BootstrapToken != nil):
token := config.Spec.JoinConfiguration.Discovery.BootstrapToken.Token

// gets the remote secret interface client for the current cluster
Expand Down
8 changes: 7 additions & 1 deletion controllers/kubeadmconfig_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,13 @@ func TestKubeadmConfigReconciler_Reconcile_GenerateCloudConfigData(t *testing.T)
t.Fatal("Expected status ready")
}
if cfg.Status.BootstrapData == nil {
t.Fatal("Expected status ready")
t.Fatal("Expected generated bootstrap data")
}

// Ensure that we don't fail trying to refresh any bootstrap tokens
_, err = k.Reconcile(request)
if err != nil {
t.Fatalf("Failed to reconcile:\n %+v", err)
}
}

Expand Down