@@ -17,7 +17,7 @@ import (
17
17
18
18
func (r * ElastiServiceReconciler ) deletePrivateService (ctx context.Context , publichServiceNamespacedName types.NamespacedName ) (err error ) {
19
19
privateServiceNamespacedName := publichServiceNamespacedName
20
- privateServiceNamespacedName .Name = utils .GetPrivateSerivceName (publichServiceNamespacedName .Name )
20
+ privateServiceNamespacedName .Name = utils .GetPrivateServiceName (publichServiceNamespacedName .Name )
21
21
privateSVC := & v1.Service {}
22
22
if err := r .Get (ctx , privateServiceNamespacedName , privateSVC ); err != nil && ! errors .IsNotFound (err ) {
23
23
return fmt .Errorf ("failed to get private service: %w" , err )
@@ -31,9 +31,9 @@ func (r *ElastiServiceReconciler) deletePrivateService(ctx context.Context, publ
31
31
return nil
32
32
}
33
33
34
- func (r * ElastiServiceReconciler ) checkAndCreatePrivateService (ctx context.Context , publicSVC * v1.Service , es * v1alpha1.ElastiService ) (PVTName string , err error ) {
35
- PVTName = utils .GetPrivateSerivceName (publicSVC .Name )
36
- privateServiceNamespacedName := types.NamespacedName {Name : PVTName , Namespace : publicSVC .Namespace }
34
+ func (r * ElastiServiceReconciler ) checkAndCreatePrivateService (ctx context.Context , publicSVC * v1.Service , es * v1alpha1.ElastiService ) (privateServiceName string , err error ) {
35
+ privateServiceName = utils .GetPrivateServiceName (publicSVC .Name )
36
+ privateServiceNamespacedName := types.NamespacedName {Name : privateServiceName , Namespace : publicSVC .Namespace }
37
37
// See if private service already exist
38
38
privateSVC := & v1.Service {}
39
39
if err := r .Get (ctx , privateServiceNamespacedName , privateSVC ); err != nil && ! errors .IsNotFound (err ) {
@@ -42,11 +42,11 @@ func (r *ElastiServiceReconciler) checkAndCreatePrivateService(ctx context.Conte
42
42
r .Logger .Info ("Private service not found, creating one" , zap .String ("private-service" , privateServiceNamespacedName .String ()))
43
43
} else {
44
44
r .Logger .Info ("Private service already exists" , zap .String ("private-service" , privateServiceNamespacedName .String ()))
45
- return PVTName , nil
45
+ return privateServiceName , nil
46
46
}
47
47
48
48
privateSVC = publicSVC .DeepCopy ()
49
- privateSVC .SetName (PVTName )
49
+ privateSVC .SetName (privateServiceName )
50
50
// We must remove the cluster IP and node port, as it already exists for the public service
51
51
privateSVC .Spec .ClusterIP = ""
52
52
privateSVC .Spec .ClusterIPs = nil
@@ -58,14 +58,14 @@ func (r *ElastiServiceReconciler) checkAndCreatePrivateService(ctx context.Conte
58
58
59
59
// Make sure the private service is owned by the ElastiService
60
60
if err := controllerutil .SetControllerReference (es , privateSVC , r .Scheme ); err != nil {
61
- return PVTName , err
61
+ return privateServiceName , fmt . Errorf ( "checkAndCreatePrivateService: %w" , err )
62
62
}
63
63
err = r .Create (ctx , privateSVC )
64
64
if err != nil {
65
65
r .Logger .Error ("Failed to create private service" , zap .String ("private-service" , privateServiceNamespacedName .String ()), zap .Error (err ))
66
- return PVTName , err
66
+ return privateServiceName , fmt . Errorf ( "checkAndCreatePrivateService: %w" , err )
67
67
}
68
- return PVTName , nil
68
+ return privateServiceName , nil
69
69
}
70
70
71
71
// handlePublicServiceChanges handles the changes in the public service, and sync those changes in the private service
@@ -81,7 +81,7 @@ func (r *ElastiServiceReconciler) handlePublicServiceChanges(ctx context.Context
81
81
return fmt .Errorf ("public service is not same as mentioned in CRD; informer misconfigured" )
82
82
}
83
83
// Get Private Service
84
- PVTName := utils .GetPrivateSerivceName (publicSVC .Name )
84
+ PVTName := utils .GetPrivateServiceName (publicSVC .Name )
85
85
privateServiceNamespacedName := types.NamespacedName {Name : PVTName , Namespace : publicSVC .Namespace }
86
86
privateSVC := & v1.Service {}
87
87
if err := r .Get (ctx , privateServiceNamespacedName , privateSVC ); err != nil && ! errors .IsNotFound (err ) {
0 commit comments