@@ -317,7 +317,7 @@ var _ = Describe("Storage controller medium tests", func() {
317317
318318 storage .Spec .Service .GRPC .Port = 2137
319319
320- configWithNewPorts , err := patchGRPCPortsInConfiguration (storage .Spec .Configuration , 2137 , - 1 )
320+ configWithNewPorts , err := patchGRPCPortsInConfiguration (storage .Spec .Configuration , - 1 , 2137 )
321321 Expect (err ).To (BeNil ())
322322 storage .Spec .Configuration = configWithNewPorts
323323
@@ -348,17 +348,23 @@ var _ = Describe("Storage controller medium tests", func() {
348348 )
349349 })
350350
351- By ("Checking additionalPort propagation in GRPC Service..." , func () {
351+ By ("Checking insecurePort propagation in GRPC Service..." , func () {
352352 storage := v1alpha1.Storage {}
353353 Expect (k8sClient .Get (ctx , types.NamespacedName {
354354 Name : testobjects .StorageName ,
355355 Namespace : testobjects .YdbNamespace ,
356356 }, & storage )).Should (Succeed ())
357357
358358 storage .Spec .Service .GRPC .Port = v1alpha1 .GRPCPort
359- storage .Spec .Service .GRPC .AdditionalPort = 2136
359+ storage .Spec .Service .GRPC .InsecurePort = 2136
360+ storage .Spec .Service .GRPC .TLSConfiguration .Enabled = true
361+
362+ configWithNewPorts , err := patchGRPCPortsInConfiguration (
363+ storage .Spec .Configuration ,
364+ storage .Spec .Service .GRPC .Port ,
365+ storage .Spec .Service .GRPC .InsecurePort ,
366+ )
360367
361- configWithNewPorts , err := patchGRPCPortsInConfiguration (storage .Spec .Configuration , 2135 , 2136 )
362368 Expect (err ).To (BeNil ())
363369 storage .Spec .Configuration = configWithNewPorts
364370
@@ -382,9 +388,9 @@ var _ = Describe("Storage controller medium tests", func() {
382388 g .Expect (len (ports )).To (Equal (2 ), "expected 2 ports but got %d" , len (ports ))
383389 g .Expect (ports [0 ].Port ).To (Equal (int32 (v1alpha1 .GRPCPort )))
384390 g .Expect (ports [0 ].Name ).To (Equal (v1alpha1 .GRPCServicePortName ))
385- g .Expect (ports [1 ].Port ).To (Equal (storage .Spec .Service .GRPC .AdditionalPort ))
386- g .Expect (ports [1 ].Name ).To (Equal (v1alpha1 .GRPCServiceAdditionalPortName ))
387- g .Expect (ports [1 ].TargetPort .IntVal ).To (Equal (storage .Spec .Service .GRPC .AdditionalPort ))
391+ g .Expect (ports [1 ].Port ).To (Equal (storage .Spec .Service .GRPC .InsecurePort ))
392+ g .Expect (ports [1 ].Name ).To (Equal (v1alpha1 .GRPCServiceInsecurePortName ))
393+ g .Expect (ports [1 ].TargetPort .IntVal ).To (Equal (storage .Spec .Service .GRPC .InsecurePort ))
388394 return nil
389395 }, test .Timeout , test .Interval ).Should (Succeed (),
390396 "Service %s/%s should eventually have proper ports" , testobjects .YdbNamespace , serviceName ,
@@ -398,38 +404,48 @@ var _ = Describe("Storage controller medium tests", func() {
398404 Namespace : testobjects .YdbNamespace ,
399405 }, & storage )).Should (Succeed ())
400406
407+ storage .Spec .Service .GRPC .TLSConfiguration .Enabled = true
408+
401409 storage .Spec .Service .GRPC .Port = v1alpha1 .GRPCPort
402410 By ("Specify 2136 in manifest spec..." )
403- storage .Spec .Service .GRPC .AdditionalPort = 2136
411+ storage .Spec .Service .GRPC .InsecurePort = 2136
404412
405413 By ("And then specify 2137 in manifest spec..." )
406414 configWithNewPorts , err := patchGRPCPortsInConfiguration (storage .Spec .Configuration , v1alpha1 .GRPCPort , 2137 )
407415 Expect (err ).To (BeNil ())
408416 storage .Spec .Configuration = configWithNewPorts
409417
410418 err = k8sClient .Update (ctx , & storage )
411- Expect (err ).To (MatchError (ContainSubstring ("grpc port mismatch" )))
419+ Expect (err ).To (MatchError (ContainSubstring (
420+ "inconsistent grpc insecure ports: spec.service.grpc.insecure_port (2136) != configuration.grpc_config.port (2137)" ,
421+ )))
412422 })
413423 })
414424})
415425
416- func patchGRPCPortsInConfiguration (in string , port , sslPort int ) (string , error ) {
417- m := make (map [string ]interface {} )
426+ func patchGRPCPortsInConfiguration (in string , sslPort , port int32 ) (string , error ) {
427+ m := make (map [string ]any )
418428 if err := yaml .Unmarshal ([]byte (in ), & m ); err != nil {
419429 return "" , err
420430 }
421431
422- cfg , _ := m ["grpc_config" ].(map [string ]interface {} )
432+ cfg , _ := m ["grpc_config" ].(map [string ]any )
423433 if cfg == nil {
424- cfg = make (map [string ]interface {} )
434+ cfg = make (map [string ]any )
425435 }
426436
427437 if sslPort != - 1 {
428438 cfg ["ssl_port" ] = sslPort
439+ } else {
440+ delete (cfg , "ssl_port" )
429441 }
442+
430443 if port != - 1 {
431444 cfg ["port" ] = port
445+ } else {
446+ delete (cfg , "port" )
432447 }
448+
433449 m ["grpc_config" ] = cfg
434450
435451 res , err := yaml .Marshal (m )
0 commit comments