fix: clusterGet no error on no lb config

- clusterGet should not return an error, if it cannot get the
loadbalancer config, as it's not critical
  -> it should not rely on files created in nodehook actions
- this also fixes a nil pointer exception when cluster creation was
interrupted even before the loadbalancer was added to the cluster in
memory

Fixes #683
This commit is contained in:
iwilltry42 2021-07-21 13:23:17 +02:00
parent a5c1d3becb
commit 25c6f65948
No known key found for this signature in database
GPG Key ID: 7BA57AD1CFF16110

View File

@ -794,10 +794,10 @@ func ClusterGet(ctx context.Context, runtime k3drt.Runtime, cluster *k3d.Cluster
}
}
if cluster.ServerLoadBalancer.Node != nil {
if cluster.ServerLoadBalancer != nil && cluster.ServerLoadBalancer.Node != nil {
lbcfg, err := GetLoadbalancerConfig(ctx, runtime, cluster)
if err != nil {
return cluster, fmt.Errorf("error getting loadbalancer config for cluster %s: %w", cluster.Name, err)
log.Errorf("error getting loadbalancer config from %s: %v", cluster.ServerLoadBalancer.Node.Name, err)
}
cluster.ServerLoadBalancer.Config = &lbcfg
}