@@ -28,7 +28,6 @@ import (
2828 ipamv1alpha1 "github.com/liqotech/liqo/apis/ipam/v1alpha1"
2929 networkingv1beta1 "github.com/liqotech/liqo/apis/networking/v1beta1"
3030 "github.com/liqotech/liqo/pkg/consts"
31- ipam "github.com/liqotech/liqo/pkg/ipamold"
3231 "github.com/liqotech/liqo/pkg/utils/events"
3332 ipamutils "github.com/liqotech/liqo/pkg/utils/ipam"
3433)
@@ -39,19 +38,17 @@ type ConfigurationReconciler struct {
3938 Scheme * runtime.Scheme
4039 EventsRecorder record.EventRecorder
4140
42- localCIDR * networkingv1beta1.ClusterConfigCIDR
43- ipamClient ipam.IpamClient
41+ localCIDR * networkingv1beta1.ClusterConfigCIDR
4442}
4543
4644// NewConfigurationReconciler returns a new ConfigurationReconciler.
47- func NewConfigurationReconciler (cl client.Client , s * runtime.Scheme , er record.EventRecorder , ipamClient ipam. IpamClient ) * ConfigurationReconciler {
45+ func NewConfigurationReconciler (cl client.Client , s * runtime.Scheme , er record.EventRecorder ) * ConfigurationReconciler {
4846 return & ConfigurationReconciler {
4947 Client : cl ,
5048 Scheme : s ,
5149 EventsRecorder : er ,
5250
53- localCIDR : nil ,
54- ipamClient : ipamClient ,
51+ localCIDR : nil ,
5552 }
5653}
5754
@@ -73,42 +70,31 @@ func (r *ConfigurationReconciler) Reconcile(ctx context.Context, req ctrl.Reques
7370 }
7471
7572 if configuration .Spec .Local == nil {
76- err := r .defaultLocalNetwork (ctx , configuration )
77- if err != nil {
73+ if err := r .defaultLocalNetwork (ctx , configuration ); err != nil {
7874 return ctrl.Result {}, err
7975 }
8076 }
8177
82- events .Event (r .EventsRecorder , configuration , "Processing" )
78+ events .Event (r .EventsRecorder , configuration , "Processing configuration " )
8379
84- err := r .RemapConfiguration (ctx , configuration , r .EventsRecorder )
85- if err != nil {
80+ if err := r .RemapConfiguration (ctx , configuration , r .EventsRecorder ); err != nil {
8681 return ctrl.Result {}, err
8782 }
8883
89- if err = r .UpdateConfigurationStatus (ctx , configuration ); err != nil {
84+ if err : = r .UpdateConfigurationStatus (ctx , configuration ); err != nil {
9085 return ctrl.Result {}, err
9186 }
9287
9388 if ! isConfigurationConfigured (configuration ) {
94- events .Event (r .EventsRecorder , configuration , "Waiting for the network to be ready" )
89+ events .Event (r .EventsRecorder , configuration , "Waiting for all networks to be ready" )
9590 } else {
96- // Set the subnets for the remote cluster.
97- if configuration .Labels != nil && configuration .Labels [consts .RemoteClusterID ] != "" {
98- if _ , err := r .ipamClient .SetSubnetsPerCluster (ctx , & ipam.SetSubnetsPerClusterRequest {
99- RemappedPodCIDR : configuration .Status .Remote .CIDR .Pod .String (),
100- RemappedExternalCIDR : configuration .Status .Remote .CIDR .External .String (),
101- ClusterID : configuration .Labels [consts .RemoteClusterID ],
102- }); err != nil {
103- return ctrl.Result {}, fmt .Errorf ("unable to set subnets per cluster: %w" , err )
104- }
105- }
106-
10791 events .Event (r .EventsRecorder , configuration , "Configuration remapped" )
108- err = SetConfigurationConfigured (ctx , r .Client , configuration )
92+ if err := SetConfigurationConfigured (ctx , r .Client , configuration ); err != nil {
93+ return ctrl.Result {}, fmt .Errorf ("unable to set configuration %q as configured: %w" , req .NamespacedName , err )
94+ }
10995 }
11096
111- return ctrl.Result {}, err
97+ return ctrl.Result {}, nil
11298}
11399
114100func (r * ConfigurationReconciler ) defaultLocalNetwork (ctx context.Context , cfg * networkingv1beta1.Configuration ) error {
0 commit comments