From 5e791f7bf20ee33bf004191301f6f19a7472e348 Mon Sep 17 00:00:00 2001 From: Stanislav Burtsev Date: Wed, 10 Jul 2024 17:39:09 +0200 Subject: [PATCH] Added externalProxy parameter for UI. This parameter is described in ytsaurus-ui as: if defined it will be used instead of `proxy`-field for some direct heavy url/commands like: read_table, write_table, get-job-stderr, ... --- api/v1/ytsaurus_types.go | 4 ++++ api/v1/zz_generated.deepcopy.go | 5 +++++ .../bases/cluster.ytsaurus.tech_ytsaurus.yaml | 6 ++++++ docs/api.md | 3 ++- .../test.canondata | 19 +++++++++++++++++++ pkg/ytconfig/generator.go | 1 + pkg/ytconfig/generator_test.go | 11 ++++++++++- pkg/ytconfig/ui.go | 1 + ytop-chart/templates/ytsaurus-crd.yaml | 6 ++++++ 9 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 pkg/ytconfig/canondata/TestGetUIClustersConfigWithSettings/test.canondata diff --git a/api/v1/ytsaurus_types.go b/api/v1/ytsaurus_types.go index 375eda65..73f5e7cb 100644 --- a/api/v1/ytsaurus_types.go +++ b/api/v1/ytsaurus_types.go @@ -485,6 +485,10 @@ type UISpec struct { Resources corev1.ResourceRequirements `json:"resources,omitempty"` InstanceCount int32 `json:"instanceCount,omitempty"` + // If defined it will be used for direct heavy url/commands like: read_table, write_table, etc. + //+optional + ExternalProxy *string `json:"externalProxy,omitempty"` + // Odin is a service for monitoring the availability of YTsaurus clusters. //+optional OdinBaseUrl *string `json:"odinBaseUrl,omitempty"` diff --git a/api/v1/zz_generated.deepcopy.go b/api/v1/zz_generated.deepcopy.go index cc21d689..c01cf7c9 100644 --- a/api/v1/zz_generated.deepcopy.go +++ b/api/v1/zz_generated.deepcopy.go @@ -1480,6 +1480,11 @@ func (in *UISpec) DeepCopyInto(out *UISpec) { **out = **in } in.Resources.DeepCopyInto(&out.Resources) + if in.ExternalProxy != nil { + in, out := &in.ExternalProxy, &out.ExternalProxy + *out = new(string) + **out = **in + } if in.OdinBaseUrl != nil { in, out := &in.OdinBaseUrl, &out.OdinBaseUrl *out = new(string) diff --git a/config/crd/bases/cluster.ytsaurus.tech_ytsaurus.yaml b/config/crd/bases/cluster.ytsaurus.tech_ytsaurus.yaml index af896241..4d43b587 100644 --- a/config/crd/bases/cluster.ytsaurus.tech_ytsaurus.yaml +++ b/config/crd/bases/cluster.ytsaurus.tech_ytsaurus.yaml @@ -34214,6 +34214,10 @@ spec: environment: default: testing type: string + externalProxy: + description: 'If defined it will be used for direct heavy url/commands + like: read_table, write' + type: string extraEnvVariables: items: description: EnvVar represents an environment variable present @@ -34327,6 +34331,8 @@ spec: format: int32 type: integer odinBaseUrl: + description: Odin is a service for monitoring the availability + of YTsaurus clusters. type: string resources: description: ResourceRequirements describes the compute resource diff --git a/docs/api.md b/docs/api.md index 2240e56d..47709a0e 100644 --- a/docs/api.md +++ b/docs/api.md @@ -1544,7 +1544,8 @@ _Appears in:_ | `useInsecureCookies` _boolean_ | | true | | | `resources` _[ResourceRequirements](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.28/#resourcerequirements-v1-core)_ | | | | | `instanceCount` _integer_ | | | | -| `odinBaseUrl` _string_ | | | | +| `externalProxy` _string_ | If defined it will be used for direct heavy url/commands like: read_table, write_table, etc. | | | +| `odinBaseUrl` _string_ | Odin is a service for monitoring the availability of YTsaurus clusters. | | | | `extraEnvVariables` _[EnvVar](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.28/#envvar-v1-core) array_ | | | | | `environment` _string_ | | testing | | | `theme` _string_ | | lavander | | diff --git a/pkg/ytconfig/canondata/TestGetUIClustersConfigWithSettings/test.canondata b/pkg/ytconfig/canondata/TestGetUIClustersConfigWithSettings/test.canondata new file mode 100644 index 00000000..aa76dd68 --- /dev/null +++ b/pkg/ytconfig/canondata/TestGetUIClustersConfigWithSettings/test.canondata @@ -0,0 +1,19 @@ +{ + clusters=[ + { + id=test; + name=test; + proxy="http-proxies-lb-test.fake.svc.fake.zone"; + externalProxy="https://my-external-proxy.example.com"; + secure=%false; + authentication=basic; + group="My YTsaurus clusters"; + theme=""; + environment=""; + description="My first YTsaurus. Handle with care."; + primaryMaster={ + cellTag=0; + }; + }; + ]; +} \ No newline at end of file diff --git a/pkg/ytconfig/generator.go b/pkg/ytconfig/generator.go index 2e29b87a..462fe33a 100644 --- a/pkg/ytconfig/generator.go +++ b/pkg/ytconfig/generator.go @@ -684,6 +684,7 @@ func (g *Generator) GetUIClustersConfig() ([]byte, error) { c.ID = g.ytsaurus.Name c.Name = g.ytsaurus.Name c.Proxy = g.GetHTTPProxiesAddress(consts.DefaultHTTPProxyRole) + c.ExternalProxy = g.ytsaurus.Spec.UI.ExternalProxy c.PrimaryMaster.CellTag = g.ytsaurus.Spec.PrimaryMasters.CellTag c.Theme = g.ytsaurus.Spec.UI.Theme diff --git a/pkg/ytconfig/generator_test.go b/pkg/ytconfig/generator_test.go index e5f2eacc..aef0695e 100644 --- a/pkg/ytconfig/generator_test.go +++ b/pkg/ytconfig/generator_test.go @@ -373,6 +373,13 @@ func TestGetUIClustersConfig(t *testing.T) { canonize.Assert(t, cfg) } +func TestGetUIClustersConfigWithSettings(t *testing.T) { + g := NewGenerator(withUICustom(getYtsaurus()), testClusterDomain) + cfg, err := g.GetUIClustersConfig() + require.NoError(t, err) + canonize.Assert(t, cfg) +} + func TestGetUICustomConfig(t *testing.T) { g := NewGenerator(withUICustom(getYtsaurus()), testClusterDomain) cfg, err := g.GetUICustomConfig() @@ -616,8 +623,10 @@ func withUI(ytsaurus *ytv1.Ytsaurus) *ytv1.Ytsaurus { func withUICustom(ytsaurus *ytv1.Ytsaurus) *ytv1.Ytsaurus { odinUrl := "http://odin-webservice.odin.svc.cluster.local" + externalProxy := "https://my-external-proxy.example.com" ytsaurus.Spec.UI = &ytv1.UISpec{ - OdinBaseUrl: &odinUrl, + ExternalProxy: &externalProxy, + OdinBaseUrl: &odinUrl, } return ytsaurus } diff --git a/pkg/ytconfig/ui.go b/pkg/ytconfig/ui.go index 8b629d15..06dd5201 100644 --- a/pkg/ytconfig/ui.go +++ b/pkg/ytconfig/ui.go @@ -14,6 +14,7 @@ type UICluster struct { ID string `yson:"id"` Name string `yson:"name"` Proxy string `yson:"proxy"` + ExternalProxy *string `yson:"externalProxy,omitempty"` Secure bool `yson:"secure"` Authentication UIAuthenticationType `yson:"authentication"` Group string `yson:"group"` diff --git a/ytop-chart/templates/ytsaurus-crd.yaml b/ytop-chart/templates/ytsaurus-crd.yaml index 7d3915c4..eedfdf2a 100644 --- a/ytop-chart/templates/ytsaurus-crd.yaml +++ b/ytop-chart/templates/ytsaurus-crd.yaml @@ -34003,6 +34003,10 @@ spec: environment: default: testing type: string + externalProxy: + description: 'If defined it will be used for direct heavy url/commands + like: read_table, write' + type: string extraEnvVariables: items: description: EnvVar represents an environment variable present @@ -34114,6 +34118,8 @@ spec: format: int32 type: integer odinBaseUrl: + description: Odin is a service for monitoring the availability of + YTsaurus clusters. type: string resources: description: ResourceRequirements describes the compute resource