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
pull/710/head
iwilltry42 3 years ago
parent a5c1d3becb
commit 25c6f65948
No known key found for this signature in database
GPG Key ID: 7BA57AD1CFF16110
  1. 4
      pkg/client/cluster.go

@ -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
}

Loading…
Cancel
Save