diff --git a/api/v1/ytsaurus_types.go b/api/v1/ytsaurus_types.go index 21d54aee..7008433d 100644 --- a/api/v1/ytsaurus_types.go +++ b/api/v1/ytsaurus_types.go @@ -571,6 +571,11 @@ type CommonSpec struct { //+kubebuilder:default:=false //+optional UseIPv4 bool `json:"useIpv4"` + //+optional + KeepSocket *bool `json:"keepSocket,omitempty"` + //+optional + ForceTCP *bool `json:"forceTcp,omitempty"` + //+kubebuilder:default:=true //+optional UseShortNames bool `json:"useShortNames"` diff --git a/api/v1/zz_generated.deepcopy.go b/api/v1/zz_generated.deepcopy.go index 5c705428..537d0038 100644 --- a/api/v1/zz_generated.deepcopy.go +++ b/api/v1/zz_generated.deepcopy.go @@ -345,6 +345,16 @@ func (in *CommonSpec) DeepCopyInto(out *CommonSpec) { *out = new(RPCTransportSpec) (*in).DeepCopyInto(*out) } + if in.KeepSocket != nil { + in, out := &in.KeepSocket, &out.KeepSocket + *out = new(bool) + **out = **in + } + if in.ForceTCP != nil { + in, out := &in.ForceTCP, &out.ForceTCP + *out = new(bool) + **out = **in + } if in.ExtraPodAnnotations != nil { in, out := &in.ExtraPodAnnotations, &out.ExtraPodAnnotations *out = make(map[string]string, len(*in)) diff --git a/config/crd/bases/cluster.ytsaurus.tech_remoteexecnodes.yaml b/config/crd/bases/cluster.ytsaurus.tech_remoteexecnodes.yaml index 0e2a9327..8df00987 100644 --- a/config/crd/bases/cluster.ytsaurus.tech_remoteexecnodes.yaml +++ b/config/crd/bases/cluster.ytsaurus.tech_remoteexecnodes.yaml @@ -689,6 +689,8 @@ spec: additionalProperties: type: string type: object + forceTcp: + type: boolean hostNetwork: default: false description: Use the host's network namespace for all components. @@ -901,6 +903,8 @@ spec: resources required. type: object type: object + keepSocket: + type: boolean locations: items: properties: diff --git a/config/crd/bases/cluster.ytsaurus.tech_ytsaurus.yaml b/config/crd/bases/cluster.ytsaurus.tech_ytsaurus.yaml index ec1b34f5..2b628cc1 100644 --- a/config/crd/bases/cluster.ytsaurus.tech_ytsaurus.yaml +++ b/config/crd/bases/cluster.ytsaurus.tech_ytsaurus.yaml @@ -10024,6 +10024,8 @@ spec: additionalProperties: type: string type: object + forceTcp: + type: boolean hostNetwork: default: false description: Use the host's network namespace for all components. @@ -12495,6 +12497,8 @@ spec: jobImage: description: Default docker image for user jobs. type: string + keepSocket: + type: boolean masterCaches: properties: affinity: diff --git a/docs/api.md b/docs/api.md index 155880c6..10244e60 100644 --- a/docs/api.md +++ b/docs/api.md @@ -239,6 +239,8 @@ _Appears in:_ | `ephemeralCluster` _boolean_ | Allow prioritizing performance over data safety. Useful for tests and experiments. | false | | | `useIpv6` _boolean_ | | false | | | `useIpv4` _boolean_ | | false | | +| `keepSocket` _boolean_ | | | | +| `forceTcp` _boolean_ | | | | | `useShortNames` _boolean_ | | true | | | `hostNetwork` _boolean_ | Use the host's network namespace for all components. | false | | | `usePorto` _boolean_ | | false | | @@ -1145,6 +1147,8 @@ _Appears in:_ | `ephemeralCluster` _boolean_ | Allow prioritizing performance over data safety. Useful for tests and experiments. | false | | | `useIpv6` _boolean_ | | false | | | `useIpv4` _boolean_ | | false | | +| `keepSocket` _boolean_ | | | | +| `forceTcp` _boolean_ | | | | | `useShortNames` _boolean_ | | true | | | `hostNetwork` _boolean_ | Use the host's network namespace for all components. | false | | | `usePorto` _boolean_ | | false | | @@ -1662,8 +1666,7 @@ Ytsaurus is the Schema for the ytsaurus API -_Appears in:_ -- [YtsaurusValidator](#ytsaurusvalidator) + | Field | Description | Default | Validation | | --- | --- | --- | --- | @@ -1693,6 +1696,8 @@ _Appears in:_ | `ephemeralCluster` _boolean_ | Allow prioritizing performance over data safety. Useful for tests and experiments. | false | | | `useIpv6` _boolean_ | | false | | | `useIpv4` _boolean_ | | false | | +| `keepSocket` _boolean_ | | | | +| `forceTcp` _boolean_ | | | | | `useShortNames` _boolean_ | | true | | | `hostNetwork` _boolean_ | Use the host's network namespace for all components. | false | | | `usePorto` _boolean_ | | false | | @@ -1729,5 +1734,3 @@ _Appears in:_ - - diff --git a/pkg/ytconfig/canondata/TestGetStrawberryControllerConfig/test.canondata b/pkg/ytconfig/canondata/TestGetStrawberryControllerConfig/test.canondata index e76c575f..b3a01eb1 100644 --- a/pkg/ytconfig/canondata/TestGetStrawberryControllerConfig/test.canondata +++ b/pkg/ytconfig/canondata/TestGetStrawberryControllerConfig/test.canondata @@ -11,7 +11,7 @@ chyt={ "address_resolver"={ "enable_ipv4"=%true; - "enable_ipv6"=%true; + "enable_ipv6"=%false; retries=1000; }; }; diff --git a/pkg/ytconfig/canondata/TestResolverOptionsKeepSocketAndForceTCP/test.canondata b/pkg/ytconfig/canondata/TestResolverOptionsKeepSocketAndForceTCP/test.canondata new file mode 100644 index 00000000..f0ff21c6 --- /dev/null +++ b/pkg/ytconfig/canondata/TestResolverOptionsKeepSocketAndForceTCP/test.canondata @@ -0,0 +1,146 @@ +{ + "address_resolver"={ + "enable_ipv4"=%true; + "enable_ipv6"=%false; + "keep_socket"=%true; + "force_tcp"=%true; + retries=1000; + }; + "solomon_exporter"={ + host="{POD_SHORT_HOSTNAME}"; + "instance_tags"={ + pod="{K8S_POD_NAME}"; + }; + }; + logging={ + writers={ + debug={ + type=file; + "file_name"="/var/log/master.debug.log.zstd"; + format="plain_text"; + "compression_method"=zstd; + "enable_compression"=%true; + "enable_system_messages"=%true; + "rotation_policy"={ + "rotation_period"=900000; + "max_total_size_to_keep"=10737418240; + }; + }; + error={ + type=file; + "file_name"="/var/log/master.error.log"; + format="plain_text"; + "enable_system_messages"=%true; + }; + info={ + type=file; + "file_name"="/var/log/master.info.log"; + format="plain_text"; + "enable_system_messages"=%true; + }; + }; + rules=[ + { + "min_level"=info; + writers=[ + info; + ]; + family="plain_text"; + }; + { + "min_level"=error; + writers=[ + error; + ]; + family="plain_text"; + }; + { + "exclude_categories"=[ + Bus; + ]; + "min_level"=debug; + writers=[ + debug; + ]; + family="plain_text"; + }; + ]; + "flush_period"=3000; + }; + "monitoring_port"=10010; + "rpc_port"=9010; + "timestamp_provider"={ + addresses=[ + "ms-test-0.masters-test.fake.svc.fake.zone:9010"; + ]; + }; + "cluster_connection"={ + "cluster_name"=test; + "primary_master"={ + addresses=[ + "ms-test-0.masters-test.fake.svc.fake.zone:9010"; + ]; + peers=[ + { + address="ms-test-0.masters-test.fake.svc.fake.zone:9010"; + voting=%true; + }; + ]; + "cell_id"="65726e65-ad6b7562-259-79747361"; + }; + "discovery_connection"={ + addresses=[ + "ds-test-0.discovery-test.fake.svc.fake.zone:9020"; + "ds-test-1.discovery-test.fake.svc.fake.zone:9020"; + "ds-test-2.discovery-test.fake.svc.fake.zone:9020"; + ]; + }; + "master_cache"={ + addresses=[ + "msc-test-0.master-caches-test.fake.svc.fake.zone:9018"; + "msc-test-1.master-caches-test.fake.svc.fake.zone:9018"; + "msc-test-2.master-caches-test.fake.svc.fake.zone:9018"; + ]; + "cell_id"="65726e65-ad6b7562-259-79747361"; + "enable_master_cache_discovery"=%false; + }; + }; + "cypress_annotations"={ + "k8s_node_name"="{K8S_NODE_NAME}"; + "k8s_pod_name"="{K8S_POD_NAME}"; + "k8s_pod_namespace"="{K8S_POD_NAMESPACE}"; + "physical_host"="{K8S_NODE_NAME}"; + }; + snapshots={ + path="/yt/master-data/master-snapshots"; + }; + changelogs={ + path="/yt/master-data/master-changelogs"; + }; + "use_new_hydra"=%true; + "hydra_manager"={ + "max_changelog_count_to_keep"=10; + "max_snapshot_count_to_keep"=1543; + }; + "cypress_manager"={ + "default_table_replication_factor"=1; + "default_file_replication_factor"=1; + "default_journal_replication_factor"=1; + "default_journal_read_quorum"=1; + "default_journal_write_quorum"=1; + }; + "primary_master"={ + addresses=[ + "ms-test-0.masters-test.fake.svc.fake.zone:9010"; + ]; + peers=[ + { + address="ms-test-0.masters-test.fake.svc.fake.zone:9010"; + voting=%true; + }; + ]; + "cell_id"="65726e65-ad6b7562-259-79747361"; + }; + "secondary_masters"=[ + ]; +} \ No newline at end of file diff --git a/pkg/ytconfig/chyt.go b/pkg/ytconfig/chyt.go index 49e7a43c..6b050448 100644 --- a/pkg/ytconfig/chyt.go +++ b/pkg/ytconfig/chyt.go @@ -27,7 +27,18 @@ type ChytInitCluster struct { Families []string `yson:"families"` } -func getStrawberryController() StrawberryController { +type ChytConfig struct { + AddressResolver AddressResolver `yson:"address_resolver"` +} + +func getStrawberryController(resolver AddressResolver) (StrawberryController, error) { + chytConfig := ChytConfig{ + AddressResolver: resolver, + } + chytYsonConfig, err := marshallYsonConfig(chytConfig) + if err != nil { + return StrawberryController{}, err + } return StrawberryController{ Strawberry: Strawberry{ Root: "//sys/strawberry", @@ -36,10 +47,10 @@ func getStrawberryController() StrawberryController { RobotUsername: consts.StrawberryControllerUserName, }, Controllers: map[string]yson.RawValue{ - "chyt": yson.RawValue("{address_resolver={enable_ipv4=%true;enable_ipv6=%true;retries=1000}}"), + "chyt": chytYsonConfig, }, HTTPAPIEndpoint: fmt.Sprintf(":%v", consts.StrawberryHTTPAPIPort), - } + }, nil } func getChytInitCluster() ChytInitCluster { diff --git a/pkg/ytconfig/common.go b/pkg/ytconfig/common.go index c598c46d..d1d5bff8 100644 --- a/pkg/ytconfig/common.go +++ b/pkg/ytconfig/common.go @@ -49,9 +49,11 @@ type ClusterConnection struct { } type AddressResolver struct { - EnableIPv4 bool `yson:"enable_ipv4"` - EnableIPv6 bool `yson:"enable_ipv6"` - Retries *int `yson:"retries,omitempty"` + EnableIPv4 bool `yson:"enable_ipv4"` + EnableIPv6 bool `yson:"enable_ipv6"` + KeepSocket *bool `yson:"keep_socket,omitempty"` + ForceTCP *bool `yson:"force_tcp,omitempty"` + Retries *int `yson:"retries,omitempty"` LocalhostNameOverride *string `yson:"localhost_name_override,omitempty"` } diff --git a/pkg/ytconfig/generator.go b/pkg/ytconfig/generator.go index a2b10802..2b490723 100644 --- a/pkg/ytconfig/generator.go +++ b/pkg/ytconfig/generator.go @@ -157,9 +157,11 @@ func (g *Generator) fillDriver(c *Driver) { func (g *BaseGenerator) fillAddressResolver(c *AddressResolver) { var retries = 1000 - c.EnableIPv4 = g.commonSpec.UseIPv4 c.EnableIPv6 = g.commonSpec.UseIPv6 + c.KeepSocket = g.commonSpec.KeepSocket + c.ForceTCP = g.commonSpec.ForceTCP + if !c.EnableIPv6 && !c.EnableIPv4 { // In case when nothing is specified, we prefer IPv4 due to compatibility reasons. c.EnableIPv4 = true @@ -310,7 +312,12 @@ func (g *Generator) GetClusterConnection() ([]byte, error) { } func (g *Generator) GetStrawberryControllerConfig() ([]byte, error) { - c := getStrawberryController() + var resolver AddressResolver + g.fillAddressResolver(&resolver) + c, err := getStrawberryController(resolver) + if err != nil { + return nil, err + } proxy := g.GetHTTPProxiesAddress(consts.DefaultHTTPProxyRole) c.LocationProxies = []string{proxy} c.HTTPLocationAliases = map[string][]string{ diff --git a/pkg/ytconfig/generator_test.go b/pkg/ytconfig/generator_test.go index d6ad1fdd..399329de 100644 --- a/pkg/ytconfig/generator_test.go +++ b/pkg/ytconfig/generator_test.go @@ -402,6 +402,16 @@ func TestGetYQLAgentConfig(t *testing.T) { canonize.Assert(t, cfg) } +func TestResolverOptionsKeepSocketAndForceTCP(t *testing.T) { + ytsaurus := getYtsaurusWithEverything() + ytsaurus.Spec.CommonSpec.ForceTCP = ptr.To(true) + ytsaurus.Spec.CommonSpec.KeepSocket = ptr.To(true) + g := NewGenerator(ytsaurus, testClusterDomain) + cfg, err := g.GetMasterConfig(&ytsaurus.Spec.PrimaryMasters) + require.NoError(t, err) + canonize.Assert(t, cfg) +} + func TestGetMasterCachesWithFixedHostsConfig(t *testing.T) { ytsaurus := withFixedMasterCachesHosts(getYtsaurusWithEverything()) g := NewGenerator(ytsaurus, testClusterDomain) diff --git a/ytop-chart/templates/crds/remoteexecnodes.cluster.ytsaurus.tech.yaml b/ytop-chart/templates/crds/remoteexecnodes.cluster.ytsaurus.tech.yaml index bcbc5f37..d33c7ab1 100644 --- a/ytop-chart/templates/crds/remoteexecnodes.cluster.ytsaurus.tech.yaml +++ b/ytop-chart/templates/crds/remoteexecnodes.cluster.ytsaurus.tech.yaml @@ -700,6 +700,8 @@ spec: additionalProperties: type: string type: object + forceTcp: + type: boolean hostNetwork: default: false description: Use the host's network namespace for all components. @@ -912,6 +914,8 @@ spec: resources required. type: object type: object + keepSocket: + type: boolean locations: items: properties: diff --git a/ytop-chart/templates/crds/ytsaurus.cluster.ytsaurus.tech.yaml b/ytop-chart/templates/crds/ytsaurus.cluster.ytsaurus.tech.yaml index cc62b8e2..d3f96a06 100644 --- a/ytop-chart/templates/crds/ytsaurus.cluster.ytsaurus.tech.yaml +++ b/ytop-chart/templates/crds/ytsaurus.cluster.ytsaurus.tech.yaml @@ -10035,6 +10035,8 @@ spec: additionalProperties: type: string type: object + forceTcp: + type: boolean hostNetwork: default: false description: Use the host's network namespace for all components. @@ -12506,6 +12508,8 @@ spec: jobImage: description: Default docker image for user jobs. type: string + keepSocket: + type: boolean masterCaches: properties: affinity: