@@ -118,7 +118,7 @@ func (r *FabricMainChannelReconciler) Reconcile(ctx context.Context, req ctrl.Re
118
118
119
119
options , _ := r .setupResmgmtOptions (fabricMainChannel )
120
120
121
- blockBytes , err := r .fetchConfigBlock (resClient , fabricMainChannel , options )
121
+ blockBytes , err := r .fetchConfigBlock (resClient , fabricMainChannel )
122
122
if err != nil {
123
123
return r .handleReconcileError (ctx , fabricMainChannel , err )
124
124
}
@@ -127,11 +127,11 @@ func (r *FabricMainChannelReconciler) Reconcile(ctx context.Context, req ctrl.Re
127
127
return r .handleReconcileError (ctx , fabricMainChannel , err )
128
128
}
129
129
130
- if err := r .updateChannelConfig (ctx , fabricMainChannel , resClient , options , blockBytes , sdk , clientSet ); err != nil {
130
+ if err := r .updateChannelConfig (ctx , fabricMainChannel , resClient , options , sdk , clientSet ); err != nil {
131
131
return r .handleReconcileError (ctx , fabricMainChannel , err )
132
132
}
133
133
time .Sleep (3 * time .Second )
134
- if err := r .saveChannelConfig (ctx , fabricMainChannel , resClient , options ); err != nil {
134
+ if err := r .saveChannelConfig (ctx , fabricMainChannel , resClient ); err != nil {
135
135
return r .handleReconcileError (ctx , fabricMainChannel , err )
136
136
}
137
137
@@ -414,9 +414,7 @@ func (r *FabricMainChannelReconciler) queryConfigBlockFromOrdererWithRoundRobin(
414
414
}
415
415
416
416
// Add any other options that were passed in (except orderer endpoints)
417
- for _ , opt := range resmgmtOptions {
418
- ordererOpts = append (ordererOpts , opt )
419
- }
417
+ ordererOpts = append (ordererOpts , resmgmtOptions ... )
420
418
421
419
log .Infof ("Attempting to query config block from orderer %s" , endpoint )
422
420
block , err := resClient .QueryConfigBlockFromOrderer (channelID , ordererOpts ... )
@@ -432,14 +430,9 @@ func (r *FabricMainChannelReconciler) queryConfigBlockFromOrdererWithRoundRobin(
432
430
return nil , fmt .Errorf ("failed to query config block from all orderers, last error: %v" , lastErr )
433
431
}
434
432
435
- func (r * FabricMainChannelReconciler ) fetchOrdererChannelBlock (resClient * resmgmt.Client , fabricMainChannel * hlfv1alpha1.FabricMainChannel , resmgmtOptions []resmgmt. RequestOption ) (* common.Block , error ) {
433
+ func (r * FabricMainChannelReconciler ) fetchOrdererChannelBlock (resClient * resmgmt.Client , fabricMainChannel * hlfv1alpha1.FabricMainChannel ) (* common.Block , error ) {
436
434
var ordererChannelBlock * common.Block
437
435
var err error
438
- resmgmtOptions = append (resmgmtOptions , resmgmt .WithRetry (retry.Opts {
439
- Attempts : 5 ,
440
- InitialBackoff : 1000 * time .Millisecond ,
441
- MaxBackoff : 10 * time .Second ,
442
- }))
443
436
444
437
options , endpoints := r .setupResmgmtOptions (fabricMainChannel )
445
438
ordererChannelBlock , err = r .queryConfigBlockFromOrdererWithRoundRobin (resClient , fabricMainChannel .Spec .Name , endpoints , options )
@@ -529,23 +522,15 @@ func (r *FabricMainChannelReconciler) setupResmgmtOptions(fabricMainChannel *hlf
529
522
530
523
var ordererEndpoints []string
531
524
for _ , ordOrg := range fabricMainChannel .Spec .OrdererOrganizations {
532
- for _ , endpoint := range ordOrg .OrdererEndpoints {
533
- ordererEndpoints = append (ordererEndpoints , endpoint )
534
- // resmgmtOptions = append(resmgmtOptions)
535
- }
525
+ ordererEndpoints = append (ordererEndpoints , ordOrg .OrdererEndpoints ... )
536
526
}
537
527
538
528
return resmgmtOptions , ordererEndpoints
539
529
}
540
530
541
- func (r * FabricMainChannelReconciler ) fetchConfigBlock (resClient * resmgmt.Client , fabricMainChannel * hlfv1alpha1.FabricMainChannel , resmgmtOptions []resmgmt. RequestOption ) ([]byte , error ) {
531
+ func (r * FabricMainChannelReconciler ) fetchConfigBlock (resClient * resmgmt.Client , fabricMainChannel * hlfv1alpha1.FabricMainChannel ) ([]byte , error ) {
542
532
var channelBlock * cb.Block
543
533
var err error
544
- resmgmtOptions = append (resmgmtOptions , resmgmt .WithRetry (retry.Opts {
545
- Attempts : 5 ,
546
- InitialBackoff : 1000 * time .Millisecond ,
547
- MaxBackoff : 10 * time .Second ,
548
- }))
549
534
550
535
options , endpoints := r .setupResmgmtOptions (fabricMainChannel )
551
536
channelBlock , err = r .queryConfigBlockFromOrdererWithRoundRobin (resClient , fabricMainChannel .Spec .Name , endpoints , options )
@@ -596,8 +581,8 @@ func (r *FabricMainChannelReconciler) joinOrderers(ctx context.Context, fabricMa
596
581
return nil
597
582
}
598
583
599
- func (r * FabricMainChannelReconciler ) updateChannelConfig (ctx context.Context , fabricMainChannel * hlfv1alpha1.FabricMainChannel , resClient * resmgmt.Client , resmgmtOptions []resmgmt.RequestOption , blockBytes [] byte , sdk * fabsdk.FabricSDK , clientSet * kubernetes.Clientset ) error {
600
- ordererChannelBlock , err := r .fetchOrdererChannelBlock (resClient , fabricMainChannel , resmgmtOptions )
584
+ func (r * FabricMainChannelReconciler ) updateChannelConfig (ctx context.Context , fabricMainChannel * hlfv1alpha1.FabricMainChannel , resClient * resmgmt.Client , resmgmtOptions []resmgmt.RequestOption , sdk * fabsdk.FabricSDK , clientSet * kubernetes.Clientset ) error {
585
+ ordererChannelBlock , err := r .fetchOrdererChannelBlock (resClient , fabricMainChannel )
601
586
if err != nil {
602
587
return err
603
588
}
@@ -680,8 +665,8 @@ func (r *FabricMainChannelReconciler) updateChannelConfig(ctx context.Context, f
680
665
return nil
681
666
}
682
667
683
- func (r * FabricMainChannelReconciler ) saveChannelConfig (ctx context.Context , fabricMainChannel * hlfv1alpha1.FabricMainChannel , resClient * resmgmt.Client , resmgmtOptions []resmgmt. RequestOption ) error {
684
- ordererChannelBlock , err := r .fetchOrdererChannelBlock (resClient , fabricMainChannel , resmgmtOptions )
668
+ func (r * FabricMainChannelReconciler ) saveChannelConfig (ctx context.Context , fabricMainChannel * hlfv1alpha1.FabricMainChannel , resClient * resmgmt.Client ) error {
669
+ ordererChannelBlock , err := r .fetchOrdererChannelBlock (resClient , fabricMainChannel )
685
670
if err != nil {
686
671
return err
687
672
}
0 commit comments