@@ -28,7 +28,7 @@ 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 "
31+ "github.com/liqotech/liqo/pkg/ipam "
3232 "github.com/liqotech/liqo/pkg/utils/events"
3333 ipamutils "github.com/liqotech/liqo/pkg/utils/ipam"
3434)
@@ -40,18 +40,17 @@ type ConfigurationReconciler struct {
4040 EventsRecorder record.EventRecorder
4141
4242 localCIDR * networkingv1beta1.ClusterConfigCIDR
43- ipamClient ipam.IpamClient
43+ ipamClient ipam.IPAMClient
4444}
4545
4646// NewConfigurationReconciler returns a new ConfigurationReconciler.
47- func NewConfigurationReconciler (cl client.Client , s * runtime.Scheme , er record.EventRecorder , ipamClient ipam. IpamClient ) * ConfigurationReconciler {
47+ func NewConfigurationReconciler (cl client.Client , s * runtime.Scheme , er record.EventRecorder ) * ConfigurationReconciler {
4848 return & ConfigurationReconciler {
4949 Client : cl ,
5050 Scheme : s ,
5151 EventsRecorder : er ,
5252
53- localCIDR : nil ,
54- ipamClient : ipamClient ,
53+ localCIDR : nil ,
5554 }
5655}
5756
@@ -73,42 +72,31 @@ func (r *ConfigurationReconciler) Reconcile(ctx context.Context, req ctrl.Reques
7372 }
7473
7574 if configuration .Spec .Local == nil {
76- err := r .defaultLocalNetwork (ctx , configuration )
77- if err != nil {
75+ if err := r .defaultLocalNetwork (ctx , configuration ); err != nil {
7876 return ctrl.Result {}, err
7977 }
8078 }
8179
82- events .Event (r .EventsRecorder , configuration , "Processing" )
80+ events .Event (r .EventsRecorder , configuration , "Processing configuration " )
8381
84- err := r .RemapConfiguration (ctx , configuration , r .EventsRecorder )
85- if err != nil {
82+ if err := r .RemapConfiguration (ctx , configuration , r .EventsRecorder ); err != nil {
8683 return ctrl.Result {}, err
8784 }
8885
89- if err = r .UpdateConfigurationStatus (ctx , configuration ); err != nil {
86+ if err : = r .UpdateConfigurationStatus (ctx , configuration ); err != nil {
9087 return ctrl.Result {}, err
9188 }
9289
9390 if ! isConfigurationConfigured (configuration ) {
94- events .Event (r .EventsRecorder , configuration , "Waiting for the network to be ready" )
91+ events .Event (r .EventsRecorder , configuration , "Waiting for all networks to be ready" )
9592 } 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-
10793 events .Event (r .EventsRecorder , configuration , "Configuration remapped" )
108- err = SetConfigurationConfigured (ctx , r .Client , configuration )
94+ if err := SetConfigurationConfigured (ctx , r .Client , configuration ); err != nil {
95+ return ctrl.Result {}, fmt .Errorf ("unable to set configuration %q as configured: %w" , req .NamespacedName , err )
96+ }
10997 }
11098
111- return ctrl.Result {}, err
99+ return ctrl.Result {}, nil
112100}
113101
114102func (r * ConfigurationReconciler ) defaultLocalNetwork (ctx context.Context , cfg * networkingv1beta1.Configuration ) error {
0 commit comments