1
0
mirror of https://github.com/rancher/rke.git synced 2025-08-29 11:43:07 +00:00

Check if certificates are present in state

Problem: If certificates are empty in cluster state (or missing rkestate file), RKE and Rancher would throw NPE.

Solution: Check if certificates are present or error out (for now this situation needs manual intervention)
This commit is contained in:
Sebastiaan van Steenis 2019-07-10 20:40:42 +02:00 committed by Alena Prokharchyk
parent f360207416
commit 63b6ece7b9

View File

@ -25,6 +25,7 @@ const (
)
func ReconcileCluster(ctx context.Context, kubeCluster, currentCluster *Cluster, flags ExternalFlags, svcOptions *v3.KubernetesServicesOptions) error {
logrus.Debugf("[reconcile] currentCluster: %+v\n", currentCluster)
log.Infof(ctx, "[reconcile] Reconciling cluster state")
kubeCluster.UpdateWorkersOnly = flags.UpdateOnly
if currentCluster == nil {
@ -32,6 +33,10 @@ func ReconcileCluster(ctx context.Context, kubeCluster, currentCluster *Cluster,
kubeCluster.UpdateWorkersOnly = false
return nil
}
// If certificates are not present, this is broken state and should error out
if len(currentCluster.Certificates) == 0 {
return fmt.Errorf("Certificates are not present in cluster state, recover rkestate file or certificate information in cluster state")
}
kubeClient, err := k8s.NewClient(kubeCluster.LocalKubeConfigPath, kubeCluster.K8sWrapTransport)
if err != nil {