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

Commit cbf3778

Browse files
authored
Merge pull request #267 from newrelic-forks/fix/refresh-token-nil-dereference
fix: ensure there's a token to refresh
2 parents 780614d + 61fe177 commit cbf3778

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

controllers/kubeadmconfig_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ func (r *KubeadmConfigReconciler) Reconcile(req ctrl.Request) (_ ctrl.Result, re
148148
err = patchHelper.Patch(ctx, config)
149149
return ctrl.Result{}, err
150150
// 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
151-
case config.Status.Ready:
151+
case config.Status.Ready && (config.Spec.JoinConfiguration != nil && config.Spec.JoinConfiguration.Discovery.BootstrapToken != nil):
152152
token := config.Spec.JoinConfiguration.Discovery.BootstrapToken.Token
153153

154154
// gets the remote secret interface client for the current cluster

controllers/kubeadmconfig_controller_test.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,13 @@ func TestKubeadmConfigReconciler_Reconcile_GenerateCloudConfigData(t *testing.T)
398398
t.Fatal("Expected status ready")
399399
}
400400
if cfg.Status.BootstrapData == nil {
401-
t.Fatal("Expected status ready")
401+
t.Fatal("Expected generated bootstrap data")
402+
}
403+
404+
// Ensure that we don't fail trying to refresh any bootstrap tokens
405+
_, err = k.Reconcile(request)
406+
if err != nil {
407+
t.Fatalf("Failed to reconcile:\n %+v", err)
402408
}
403409
}
404410

0 commit comments

Comments
 (0)