Skip to content

Commit aaa5aca

Browse files
committed
fix cluster client creation, replace panics with error returns
1 parent 33d925a commit aaa5aca

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

cmd/app/commandline.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929

3030
type Flags struct {
3131
Kubeconfig string
32+
ClusterDomain string
3233
MetricsAddress string
3334
ProbeAddress string
3435
LeaderElection bool
@@ -47,6 +48,7 @@ func ParseCmdLine() Flags {
4748
pflag.CommandLine = pflag.NewFlagSet(os.Args[0], pflag.ContinueOnError)
4849

4950
pflag.String("kubeconfig", "", "Path to a kubeconfig. Only required if out-of-cluster.")
51+
pflag.String("cluster-domain", "cluster.local", "The cluster domain configured in kube-dns")
5052
pflag.String("metrics-bind-address", ":8080", "The address the metric endpoint binds to.")
5153
pflag.String("health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
5254
pflag.Bool("leader-elect", false, "Enable leader election for controller manager. "+
@@ -78,6 +80,7 @@ func ParseCmdLine() Flags {
7880

7981
return Flags{
8082
Kubeconfig: viper.GetString("kubeconfig"),
83+
ClusterDomain: viper.GetString("cluster-domain"),
8184
MetricsAddress: viper.GetString("metrics-bind-address"),
8285
ProbeAddress: viper.GetString("health-probe-bind-address"),
8386
LeaderElection: viper.GetBool("leader-elect"),

internal/controller/etcdcluster_controller.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -706,23 +706,23 @@ func (r *EtcdClusterReconciler) createClusterFromScratch(ctx context.Context, st
706706
// TODO!
707707
// nolint:unused
708708
func (r *EtcdClusterReconciler) scaleUpFromZero(ctx context.Context) error {
709-
panic("not yet implemented")
709+
return fmt.Errorf("not yet implemented")
710710
}
711711

712712
// TODO!
713713
// nolint:unused
714714
func (r *EtcdClusterReconciler) createOrUpdateClusterStateConfigMap(ctx context.Context) error {
715-
panic("not yet implemented")
715+
return fmt.Errorf("not yet implemented")
716716
}
717717

718718
// TODO!
719719
// nolint:unused
720720
func (r *EtcdClusterReconciler) createOrUpdateStatefulSet(ctx context.Context) error {
721-
panic("not yet implemented")
721+
return fmt.Errorf("not yet implemented")
722722
}
723723

724724
// TODO!
725725
// nolint:unused
726726
func (r *EtcdClusterReconciler) promoteLearners(ctx context.Context) error {
727-
panic("not yet implemented")
727+
return fmt.Errorf("not yet implemented")
728728
}

internal/controller/factory/etcd_client.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66

77
"github.com/aenix-io/etcd-operator/api/v1alpha1"
8+
"github.com/spf13/viper"
89
clientv3 "go.etcd.io/etcd/client/v3"
910
v1 "k8s.io/api/core/v1"
1011
"k8s.io/apimachinery/pkg/types"
@@ -56,7 +57,7 @@ func configFromCluster(ctx context.Context, cluster *v1alpha1.EtcdCluster, cli c
5657
}
5758
}
5859
for name := range names {
59-
urls = append(urls, fmt.Sprintf("%s:%s", name, "2379"))
60+
urls = append(urls, fmt.Sprintf("%s.%s.%s.svc.%s:%s", name, ep.Name, cluster.Namespace, viper.GetString("cluster-domain"), "2379"))
6061
}
6162

6263
return clientv3.Config{Endpoints: urls}, nil

0 commit comments

Comments
 (0)