From 97b619452b1dfffe6c58ce29e6d76457d53477b4 Mon Sep 17 00:00:00 2001 From: zryfish Date: Thu, 9 Jul 2020 18:06:37 +0800 Subject: [PATCH] change error message when there is no proxy address (#2372) --- pkg/kapis/cluster/v1alpha1/handler.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pkg/kapis/cluster/v1alpha1/handler.go b/pkg/kapis/cluster/v1alpha1/handler.go index 4c23a726e..6d9a360bd 100644 --- a/pkg/kapis/cluster/v1alpha1/handler.go +++ b/pkg/kapis/cluster/v1alpha1/handler.go @@ -120,7 +120,7 @@ func (h *handler) populateProxyAddress() error { } if len(service.Spec.Ports) == 0 { - return fmt.Errorf("there are no ports in proxy service spec") + return fmt.Errorf("there are no ports in proxy service %s spec", h.proxyService) } port := service.Spec.Ports[0].Port @@ -137,7 +137,9 @@ func (h *handler) populateProxyAddress() error { } if len(serviceAddress) == 0 { - return fmt.Errorf("service ingress is empty") + return fmt.Errorf("cannot generate agent deployment yaml for member cluster "+ + " because %s service has no public address, please check %s status, or set address "+ + " mannually in ClusterConfiguration", h.proxyService, h.proxyService) } h.proxyAddress = serviceAddress @@ -150,6 +152,11 @@ func (h *handler) populateProxyAddress() error { // TODO(jeff): load template from configmap func (h *handler) generateDefaultDeployment(cluster *v1alpha1.Cluster, w io.Writer) error { + _, err := url.Parse(h.proxyAddress) + if err != nil { + return fmt.Errorf("invalid proxy address %s, should format like http[s]://1.2.3.4:123", h.proxyAddress) + } + if cluster.Spec.Connection.Type == v1alpha1.ConnectionTypeDirect { return errClusterConnectionIsNotProxy }