@@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
1414limitations under the License.
1515*/
1616
17+ // Package network implements network controllers for managing BGP configuration and related network resources
1718package network
1819
1920import (
@@ -85,7 +86,7 @@ func (r *BGPConfigurationReconciler) Reconcile(ctx context.Context, req ctrl.Req
8586
8687 // Fetch the BGPConfiguration instance
8788 instance := & networkv1.BGPConfiguration {}
88- err := r .Client . Get (ctx , req .NamespacedName , instance )
89+ err := r .Get (ctx , req .NamespacedName , instance )
8990 if err != nil {
9091 if k8s_errors .IsNotFound (err ) {
9192 // Request object not found, could have been deleted after reconcile request.
@@ -175,7 +176,7 @@ func (r *BGPConfigurationReconciler) SetupWithManager(ctx context.Context, mgr c
175176 listOpts := []client.ListOption {
176177 client .InNamespace (o .GetNamespace ()),
177178 }
178- if err := r .Client . List (ctx , bgpConfigurationList , listOpts ... ); err != nil {
179+ if err := r .List (ctx , bgpConfigurationList , listOpts ... ); err != nil {
179180 Log .Error (err , "Unable to retrieve BGPConfigurationList in namespace %s" , o .GetNamespace ())
180181 return nil
181182 }
@@ -214,7 +215,7 @@ func (r *BGPConfigurationReconciler) SetupWithManager(ctx context.Context, mgr c
214215 listOpts := []client.ListOption {
215216 client .InNamespace (bgpConfigurationNamespace ),
216217 }
217- if err := r .Client . List (ctx , bgpConfigurationList , listOpts ... ); err != nil {
218+ if err := r .List (ctx , bgpConfigurationList , listOpts ... ); err != nil {
218219 Log .Error (err , "Unable to retrieve BGPConfigurationList in namespace %s" , bgpConfigurationNamespace )
219220 return nil
220221 }
@@ -331,7 +332,7 @@ func (r *BGPConfigurationReconciler) reconcileDelete(ctx context.Context, instan
331332
332333 // Delete all FRRConfiguration in the Spec.FRRConfigurationNamespace namespace,
333334 // which have the correct owner and ownernamespace label
334- err := r .Client . DeleteAllOf (
335+ err := r .DeleteAllOf (
335336 ctx ,
336337 & frrk8sv1.FRRConfiguration {},
337338 client .InNamespace (instance .Spec .FRRConfigurationNamespace ),
@@ -341,7 +342,7 @@ func (r *BGPConfigurationReconciler) reconcileDelete(ctx context.Context, instan
341342 },
342343 )
343344 if err != nil && ! k8s_errors .IsNotFound (err ) {
344- return ctrl.Result {}, fmt .Errorf ("Error DeleteAllOf FRRConfiguration: %w" , err )
345+ return ctrl.Result {}, fmt .Errorf ("error DeleteAllOf FRRConfiguration: %w" , err )
345346 }
346347
347348 // Service is deleted so remove the finalizer.
@@ -361,8 +362,8 @@ func (r *BGPConfigurationReconciler) reconcileNormal(ctx context.Context, instan
361362 listOpts := []client.ListOption {
362363 client .InNamespace (instance .Namespace ),
363364 }
364- if err := r .Client . List (ctx , podList , listOpts ... ); err != nil {
365- return ctrl.Result {}, fmt .Errorf ("Unable to retrieve PodList %w" , err )
365+ if err := r .List (ctx , podList , listOpts ... ); err != nil {
366+ return ctrl.Result {}, fmt .Errorf ("unable to retrieve PodList %w" , err )
366367 }
367368
368369 // get podDetail all pods which have additional interfaces configured
@@ -376,8 +377,8 @@ func (r *BGPConfigurationReconciler) reconcileNormal(ctx context.Context, instan
376377 listOpts = []client.ListOption {
377378 client .InNamespace (instance .Spec .FRRConfigurationNamespace ), // defaults to metallb-system
378379 }
379- if err := r .Client . List (ctx , frrConfigList , listOpts ... ); err != nil {
380- return ctrl.Result {}, fmt .Errorf ("Unable to retrieve FRRConfigurationList %w" , err )
380+ if err := r .List (ctx , frrConfigList , listOpts ... ); err != nil {
381+ return ctrl.Result {}, fmt .Errorf ("unable to retrieve FRRConfigurationList %w" , err )
381382 }
382383
383384 // get all frr configs for the nodes pods are scheduled on
@@ -465,7 +466,7 @@ func (r *BGPConfigurationReconciler) deleteStaleFRRConfigurations(ctx context.Co
465466 idx := slices .IndexFunc (podNetworkDetailList , f )
466467 if idx < 0 {
467468 // There is no pod in the namespace corrsponding to the FRRConfiguration, delete it
468- if err := r .Client . Delete (ctx , & cfg ); err != nil && ! k8s_errors .IsNotFound (err ) {
469+ if err := r .Delete (ctx , & cfg ); err != nil && ! k8s_errors .IsNotFound (err ) {
469470 return fmt .Errorf ("unable to delete FRRConfiguration %w" , err )
470471 }
471472 r .GetLogger (ctx ).Info (fmt .Sprintf ("pod with name: %s either in state deleted, completed, failed or unknown, deleted FRRConfiguration %s" , podName , cfg .Name ))
@@ -508,7 +509,7 @@ func getPodNetworkDetails(
508509
509510 // verify the nodeName information is already present in the pod spec, otherwise report an error to reconcile
510511 if pod .Spec .NodeName == "" {
511- return detailList , fmt .Errorf (fmt . Sprintf ( "empty spec.nodeName on pod %s" , pod .Name ) )
512+ return detailList , fmt .Errorf ("empty spec.nodeName on pod %s" , pod .Name )
512513 }
513514
514515 detail := bgp.PodDetail {
@@ -525,11 +526,11 @@ func getPodNetworkDetails(
525526 // reflect all requested networks. return with an error to reconcile if the length
526527 // is <= the status. Note: the status also has the pod network
527528 if len (netsStatus ) <= len (netAttach ) {
528- return detailList , fmt .Errorf (fmt . Sprintf ( "metadata.Annotations['k8s.ovn.org/pod-networks'] %s on pod %s, does not match requested networks %s" ,
529- pod .GetAnnotations ()[k8s_networkv1 .NetworkStatusAnnot ], pod .Name , netAttachString ))
529+ return detailList , fmt .Errorf ("metadata.Annotations['k8s.ovn.org/pod-networks'] %s on pod %s, does not match requested networks %s" ,
530+ pod .GetAnnotations ()[k8s_networkv1 .NetworkStatusAnnot ], pod .Name , netAttachString )
530531 }
531532
532- var netsStatusCopy = make ([]k8s_networkv1.NetworkStatus , len (netsStatus ))
533+ netsStatusCopy : = make ([]k8s_networkv1.NetworkStatus , len (netsStatus ))
533534 copy (netsStatusCopy , netsStatus )
534535 // verify there are IP information for all networks in the status, otherwise report an error to reconcile
535536 for idx , netStat := range netsStatusCopy {
@@ -562,7 +563,7 @@ func getPodNetworkDetails(
562563
563564 // verify there is IP information for the network, otherwise report an error to reconcile
564565 if len (netStat .IPs ) == 0 {
565- return detailList , fmt .Errorf (fmt . Sprintf ( "no IP information for network %s on pod %s" , netStat .Name , pod .Name ) )
566+ return detailList , fmt .Errorf ("no IP information for network %s on pod %s" , netStat .Name , pod .Name )
566567 }
567568 }
568569
0 commit comments