From dfb3dc22f0c7bb69b1365d82c9d94f81a6fb9c5a Mon Sep 17 00:00:00 2001 From: Huiwen Date: Tue, 28 Nov 2023 14:32:05 +0800 Subject: [PATCH] [service-waiter] use ide proxy for metric report (#19141) --- install/installer/pkg/common/common.go | 2 +- install/installer/pkg/common/common_test.go | 9 ++++----- install/installer/pkg/common/constants.go | 2 ++ install/installer/pkg/components/ide-proxy/constants.go | 8 +++++--- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/install/installer/pkg/common/common.go b/install/installer/pkg/common/common.go index 67e4dab3364a90..2101fd0b40b872 100644 --- a/install/installer/pkg/common/common.go +++ b/install/installer/pkg/common/common.go @@ -535,7 +535,7 @@ func componentWaiterContainer(ctx *RenderContext, component, labels, image strin "--gitpod-host", ctx.Config.Domain, "--ide-metrics-host", - "http://" + IDEMetricsComponent + ":" + strconv.Itoa(IDEMetricsPort), + ClusterURL("http", IDEProxyComponent, ctx.Namespace, IDEProxyPort), "--namespace", ctx.Namespace, "--component", diff --git a/install/installer/pkg/common/common_test.go b/install/installer/pkg/common/common_test.go index 4a73058a01960f..9ae0032dfcb985 100644 --- a/install/installer/pkg/common/common_test.go +++ b/install/installer/pkg/common/common_test.go @@ -6,7 +6,6 @@ package common_test import ( "fmt" - "strconv" "testing" "github.com/gitpod-io/gitpod/common-go/baseserver" @@ -59,8 +58,8 @@ func TestPublicApiServerComponentWaiterContainer(t *testing.T) { container := common.PublicApiServerComponentWaiterContainer(ctx) labels := common.DefaultLabelSelector(common.PublicApiComponent) require.Equal(t, labels, "app=gitpod,component=public-api-server") - ideMetricsHost := "http://" + common.IDEMetricsComponent + ":" + strconv.Itoa(common.IDEMetricsPort) - require.Equal(t, []string{"-v", "component", "--gitpod-host", ctx.Config.Domain, "--ide-metrics-host", ideMetricsHost, "--namespace", "test_namespace", "--component", common.PublicApiComponent, "--labels", labels, "--image", ctx.Config.Repository + "/public-api-server:" + "happy_path_papi_image"}, container.Args) + ideProxyHost := common.ClusterURL("http", common.IDEProxyComponent, ctx.Namespace, common.IDEProxyPort) + require.Equal(t, []string{"-v", "component", "--gitpod-host", ctx.Config.Domain, "--ide-metrics-host", ideProxyHost, "--namespace", "test_namespace", "--component", common.PublicApiComponent, "--labels", labels, "--image", ctx.Config.Repository + "/public-api-server:" + "happy_path_papi_image"}, container.Args) } func TestServerComponentWaiterContainer(t *testing.T) { @@ -73,6 +72,6 @@ func TestServerComponentWaiterContainer(t *testing.T) { container := common.ServerComponentWaiterContainer(ctx) labels := common.DefaultLabelSelector(common.ServerComponent) require.Equal(t, labels, "app=gitpod,component=server") - ideMetricsHost := "http://" + common.IDEMetricsComponent + ":" + strconv.Itoa(common.IDEMetricsPort) - require.Equal(t, []string{"-v", "component", "--gitpod-host", ctx.Config.Domain, "--ide-metrics-host", ideMetricsHost, "--namespace", "test_namespace", "--component", common.ServerComponent, "--labels", labels, "--image", ctx.Config.Repository + "/server:" + "happy_path_server_image"}, container.Args) + ideProxyHost := common.ClusterURL("http", common.IDEProxyComponent, ctx.Namespace, common.IDEProxyPort) + require.Equal(t, []string{"-v", "component", "--gitpod-host", ctx.Config.Domain, "--ide-metrics-host", ideProxyHost, "--namespace", "test_namespace", "--component", common.ServerComponent, "--labels", labels, "--image", ctx.Config.Repository + "/server:" + "happy_path_server_image"}, container.Args) } diff --git a/install/installer/pkg/common/constants.go b/install/installer/pkg/common/constants.go index 811ba89d4dc18f..9fd9f1e94d141d 100644 --- a/install/installer/pkg/common/constants.go +++ b/install/installer/pkg/common/constants.go @@ -65,6 +65,8 @@ const ( DashboardComponent = "dashboard" IDEMetricsComponent = "ide-metrics" IDEMetricsPort = 3000 + IDEProxyComponent = "ide-proxy" + IDEProxyPort = 80 ) var ( diff --git a/install/installer/pkg/components/ide-proxy/constants.go b/install/installer/pkg/components/ide-proxy/constants.go index e34bcbde5ada0f..e608d08c8cdf66 100644 --- a/install/installer/pkg/components/ide-proxy/constants.go +++ b/install/installer/pkg/components/ide-proxy/constants.go @@ -4,10 +4,12 @@ package ide_proxy +import "github.com/gitpod-io/gitpod/installer/pkg/common" + const ( - Component = "ide-proxy" - ContainerPort = 80 + Component = common.IDEProxyComponent + ContainerPort = common.IDEProxyPort PortName = "http" - ServicePort = 80 + ServicePort = common.IDEProxyPort ReadinessPort = 8080 )