@@ -174,7 +174,7 @@ func (c *controller) reconcileClusterServiceBrokerKey(key string) error {
174
174
// error is returned to indicate that the binding has not been fully
175
175
// processed and should be resubmitted at a later time.
176
176
func (c * controller ) reconcileClusterServiceBroker (broker * v1beta1.ClusterServiceBroker ) error {
177
- glog .V (4 ).Infof ("ClusterServiceBroker %q: processing" , broker .Name )
177
+ glog .V (4 ).Infof ("%s %q: processing" , typeCSB , broker .Name )
178
178
179
179
// * If the broker's ready condition is true and the RelistBehavior has been
180
180
// set to Manual, do not reconcile it.
@@ -187,7 +187,10 @@ func (c *controller) reconcileClusterServiceBroker(broker *v1beta1.ClusterServic
187
187
if broker .DeletionTimestamp == nil { // Add or update
188
188
authConfig , err := getAuthCredentialsFromClusterServiceBroker (c .kubeClient , broker )
189
189
if err != nil {
190
- s := fmt .Sprintf ("ClusterServiceBroker %q: Error getting broker auth credentials: %s" , broker .Name , err )
190
+ s := fmt .Sprintf (
191
+ "%s %q: Error getting broker auth credentials: %s" ,
192
+ typeCSB , broker .Name , err ,
193
+ )
191
194
glog .Info (s )
192
195
c .recorder .Event (broker , corev1 .EventTypeWarning , errorAuthCredentialsReason , s )
193
196
if err := c .updateClusterServiceBrokerCondition (broker , v1beta1 .ServiceBrokerConditionReady , v1beta1 .ConditionFalse , errorFetchingCatalogReason , errorFetchingCatalogMessage + s ); err != nil {
@@ -198,7 +201,10 @@ func (c *controller) reconcileClusterServiceBroker(broker *v1beta1.ClusterServic
198
201
199
202
clientConfig := NewClientConfigurationForBroker (broker , authConfig )
200
203
201
- glog .V (4 ).Infof ("ClusterServiceBroker %q: creating client, URL: %v" , broker .Name , broker .Spec .URL )
204
+ glog .V (4 ).Infof (
205
+ "%s %q: creating client, URL: %v" ,
206
+ typeCSB , broker .Name , broker .Spec .URL ,
207
+ )
202
208
brokerClient , err := c .brokerClientCreateFunc (clientConfig )
203
209
if err != nil {
204
210
s := fmt .Sprintf ("Error creating client for broker %q: %s" , broker .Name , err )
@@ -210,13 +216,19 @@ func (c *controller) reconcileClusterServiceBroker(broker *v1beta1.ClusterServic
210
216
return err
211
217
}
212
218
213
- glog .V (4 ).Infof ("ClusterServiceBroker %q: processing adding/update event" , broker .Name )
219
+ glog .V (4 ).Infof (
220
+ "%s %q: processing adding/update event" ,
221
+ typeCSB , broker .Name ,
222
+ )
214
223
215
224
// get the broker's catalog
216
225
now := metav1 .Now ()
217
226
brokerCatalog , err := brokerClient .GetCatalog ()
218
227
if err != nil {
219
- s := fmt .Sprintf ("ClusterServiceBroker %q: Error getting broker catalog: %s" , broker .Name , err )
228
+ s := fmt .Sprintf (
229
+ "%s %q: Error getting broker catalog: %s" ,
230
+ typeCSB , broker .Name , err ,
231
+ )
220
232
glog .Warning (s )
221
233
c .recorder .Eventf (broker , corev1 .EventTypeWarning , errorFetchingCatalogReason , s )
222
234
if err := c .updateClusterServiceBrokerCondition (broker , v1beta1 .ServiceBrokerConditionReady , v1beta1 .ConditionFalse , errorFetchingCatalogReason , errorFetchingCatalogMessage + s ); err != nil {
@@ -228,12 +240,18 @@ func (c *controller) reconcileClusterServiceBroker(broker *v1beta1.ClusterServic
228
240
toUpdate := clone .(* v1beta1.ClusterServiceBroker )
229
241
toUpdate .Status .OperationStartTime = & now
230
242
if _ , err := c .serviceCatalogClient .ClusterServiceBrokers ().UpdateStatus (toUpdate ); err != nil {
231
- glog .Errorf ("ClusterServiceBroker %q: Error updating operation start time: %v" , broker .Name , err )
243
+ glog .Errorf (
244
+ "%s %q: Error updating operation start time: %v" ,
245
+ typeCSB , broker .Name , err ,
246
+ )
232
247
return err
233
248
}
234
249
}
235
250
} else if ! time .Now ().Before (broker .Status .OperationStartTime .Time .Add (c .reconciliationRetryDuration )) {
236
- s := fmt .Sprintf ("ClusterServiceBroker %q: stopping reconciliation retries because too much time has elapsed" , broker .Name )
251
+ s := fmt .Sprintf (
252
+ "%s %q: stopping reconciliation retries because too much time has elapsed" ,
253
+ typeCSB , broker .Name ,
254
+ )
237
255
glog .Info (s )
238
256
c .recorder .Event (broker , corev1 .EventTypeWarning , errorReconciliationRetryTimeoutReason , s )
239
257
clone , err := api .Scheme .DeepCopy (broker )
@@ -253,7 +271,10 @@ func (c *controller) reconcileClusterServiceBroker(broker *v1beta1.ClusterServic
253
271
}
254
272
return err
255
273
}
256
- glog .V (5 ).Infof ("ClusterServiceBroker %q: successfully fetched %v catalog entries" , broker .Name , len (brokerCatalog .Services ))
274
+ glog .V (5 ).Infof (
275
+ "%s %q: successfully fetched %v catalog entries" ,
276
+ typeCSB , broker .Name , len (brokerCatalog .Services ),
277
+ )
257
278
258
279
// set the operation start time if not already set
259
280
if broker .Status .OperationStartTime != nil {
@@ -264,13 +285,19 @@ func (c *controller) reconcileClusterServiceBroker(broker *v1beta1.ClusterServic
264
285
toUpdate := clone .(* v1beta1.ClusterServiceBroker )
265
286
toUpdate .Status .OperationStartTime = nil
266
287
if _ , err := c .serviceCatalogClient .ClusterServiceBrokers ().UpdateStatus (toUpdate ); err != nil {
267
- glog .Errorf ("ClusterServiceBroker %q: error updating operation start time: %v" , broker .Name , err )
288
+ glog .Errorf (
289
+ "%s %q: error updating operation start time: %v" ,
290
+ typeCSB , broker .Name , err ,
291
+ )
268
292
return err
269
293
}
270
294
}
271
295
272
296
// convert the broker's catalog payload into our API objects
273
- glog .V (4 ).Infof ("ClusterServiceBroker %q: converting catalog response into service-catalog API" , broker .Name )
297
+ glog .V (4 ).Infof (
298
+ "%s %q: converting catalog response into service-catalog API" ,
299
+ typeCSB , broker .Name ,
300
+ )
274
301
payloadServiceClasses , payloadServicePlans , err := convertCatalog (brokerCatalog )
275
302
if err != nil {
276
303
s := fmt .Sprintf ("Error converting catalog payload for broker %q to service-catalog API: %s" , broker .Name , err )
@@ -281,7 +308,10 @@ func (c *controller) reconcileClusterServiceBroker(broker *v1beta1.ClusterServic
281
308
}
282
309
return err
283
310
}
284
- glog .V (5 ).Infof ("ClusterServiceBroker %q: successfully converted catalog payload from to service-catalog API" , broker .Name )
311
+ glog .V (5 ).Infof (
312
+ "%s %q: successfully converted catalog payload from to service-catalog API" ,
313
+ typeCSB , broker .Name ,
314
+ )
285
315
286
316
// brokers must return at least one service; enforce this constraint
287
317
if len (payloadServiceClasses ) == 0 {
@@ -310,22 +340,28 @@ func (c *controller) reconcileClusterServiceBroker(broker *v1beta1.ClusterServic
310
340
existingServicePlan , _ := existingServicePlanMap [payloadServicePlan .Name ]
311
341
delete (existingServicePlanMap , payloadServicePlan .Name )
312
342
313
- glog .V (4 ).Infof ("ClusterServiceBroker %q: reconciling ClusterServicePlan (K8S: %q ExternalName: %q)" , broker .Name , payloadServicePlan .Name , payloadServicePlan .Spec .ExternalName )
343
+ glog .V (4 ).Infof (
344
+ "%s %q: reconciling ClusterServicePlan (K8S: %q ExternalName: %q)" ,
345
+ typeCSB , broker .Name , payloadServicePlan .Name , payloadServicePlan .Spec .ExternalName ,
346
+ )
314
347
if err := c .reconcileClusterServicePlanFromClusterServiceBrokerCatalog (broker , payloadServicePlan , existingServicePlan ); err != nil {
315
348
s := fmt .Sprintf (
316
- "ClusterServiceBroker %q: Error reconciling ClusterServicePlan (K8S: %q ExternalName: %q): %s" ,
317
- broker .Name ,
318
- payloadServicePlan .Name ,
319
- payloadServicePlan .Spec .ExternalName ,
320
- err ,
349
+ "Error reconciling ClusterServicePlan (K8S: %q ExternalName: %q): %s" ,
350
+ payloadServicePlan .Name , payloadServicePlan .Spec .ExternalName , err ,
351
+ )
352
+ glog .Warningf (
353
+ "%s %q: %s" ,
354
+ typeCSB , broker .Name , s ,
321
355
)
322
- glog .Warning (s )
323
356
c .recorder .Eventf (broker , corev1 .EventTypeWarning , errorSyncingCatalogReason , s )
324
357
c .updateClusterServiceBrokerCondition (broker , v1beta1 .ServiceBrokerConditionReady , v1beta1 .ConditionFalse , errorSyncingCatalogReason ,
325
358
errorSyncingCatalogMessage + s )
326
359
return err
327
360
}
328
- glog .V (5 ).Infof ("ClusterServiceBroker %q: Reconciled ClusterServicePlan (K8S: %q ExternalName: %q)" , broker .Name , payloadServicePlan .Name , payloadServicePlan .Spec .ExternalName )
361
+ glog .V (5 ).Infof (
362
+ "%s %q: Reconciled ClusterServicePlan (K8S: %q ExternalName: %q)" ,
363
+ typeCSB , broker .Name , payloadServicePlan .Name , payloadServicePlan .Spec .ExternalName ,
364
+ )
329
365
}
330
366
331
367
// handle the servicePlans that were not in the broker's payload;
@@ -335,8 +371,8 @@ func (c *controller) reconcileClusterServiceBroker(broker *v1beta1.ClusterServic
335
371
continue
336
372
}
337
373
glog .V (4 ).Infof (
338
- "ClusterServiceBroker %q: ClusterServicePlan (K8S: %q ExternalName: %q) has been removed from broker's catalog; marking" ,
339
- broker .Name , existingServicePlan .Name , existingServicePlan .Spec .ExternalName ,
374
+ "%s %q: ClusterServicePlan (K8S: %q ExternalName: %q) has been removed from broker's catalog; marking" ,
375
+ typeCSB , broker .Name , existingServicePlan .Name , existingServicePlan .Spec .ExternalName ,
340
376
)
341
377
existingServicePlan .Status .RemovedFromBrokerCatalog = true
342
378
_ , err := c .serviceCatalogClient .ClusterServicePlans ().UpdateStatus (existingServicePlan )
@@ -441,24 +477,31 @@ func (c *controller) reconcileClusterServiceBroker(broker *v1beta1.ClusterServic
441
477
// and returned early. If we reach this point, we're dealing with an update
442
478
// that's actually a soft delete-- i.e. we have some finalization to do.
443
479
if finalizers := sets .NewString (broker .Finalizers ... ); finalizers .Has (v1beta1 .FinalizerServiceCatalog ) {
444
- glog .V (4 ).Infof ("ClusterServiceBroker %q: finalizing" , broker .Name )
480
+ glog .V (4 ).Infof (
481
+ "%s %q: finalizing" ,
482
+ typeCSB , broker .Name ,
483
+ )
445
484
446
485
existingServiceClasses , existingServicePlans , err := c .getCurrentServiceClassesAndPlansForBroker (broker )
447
486
if err != nil {
448
487
return err
449
488
}
450
489
451
- glog .V (4 ).Infof ("ClusterServiceBroker %q: found %d ClusterServiceClasses to delete" , broker .Name , len (existingServiceClasses ))
452
- glog .V (4 ).Infof ("ClusterServiceBroker %q: found %d ClusterServicePlans to delete" , broker .Name , len (existingServicePlans ))
490
+ glog .V (4 ).Infof (
491
+ "%s %q: found %d ClusterServiceClasses and %d ClusterServicePlans to delete" ,
492
+ typeCSB , broker .Name , len (existingServiceClasses ), len (existingServicePlans ),
493
+ )
453
494
454
495
for _ , plan := range existingServicePlans {
455
- glog .V (4 ).Infof ("ClusterServiceBroker %q: deleting ClusterServicePlan (K8S: %q ExternalName: %q)" , broker .Name , plan .Name , plan .Spec .ExternalName )
496
+ glog .V (4 ).Infof (
497
+ "%s %q: deleting ClusterServicePlan (K8S: %q ExternalName: %q)" ,
498
+ typeCSB , broker .Name , plan .Name , plan .Spec .ExternalName ,
499
+ )
456
500
err := c .serviceCatalogClient .ClusterServicePlans ().Delete (plan .Name , & metav1.DeleteOptions {})
457
501
if err != nil && ! errors .IsNotFound (err ) {
458
502
s := fmt .Sprintf (
459
- "Error deleting ClusterServicePlan %q: %s" ,
460
- plan .Name ,
461
- err ,
503
+ "Error deleting ClusterServicePlan (K8S: %q ExternalName: %q): %s" ,
504
+ plan .Name , plan .Spec .ExternalName , err ,
462
505
)
463
506
glog .Warningf (
464
507
"%s %q: %s" ,
@@ -484,8 +527,8 @@ func (c *controller) reconcileClusterServiceBroker(broker *v1beta1.ClusterServic
484
527
err = c .serviceCatalogClient .ClusterServiceClasses ().Delete (svcClass .Name , & metav1.DeleteOptions {})
485
528
if err != nil && ! errors .IsNotFound (err ) {
486
529
s := fmt .Sprintf (
487
- "Error deleting ClusterServiceClass (K8S: %q ExternalName: %q) (ClusterServiceBroker %q) : %s" ,
488
- svcClass .Name , svcClass .Spec .ExternalName , broker . Name , err ,
530
+ "Error deleting ClusterServiceClass (K8S: %q ExternalName: %q): %s" ,
531
+ svcClass .Name , svcClass .Spec .ExternalName , err ,
489
532
)
490
533
glog .Warningf (
491
534
"%s %q: %s" ,
@@ -519,7 +562,7 @@ func (c *controller) reconcileClusterServiceBroker(broker *v1beta1.ClusterServic
519
562
c .updateClusterServiceBrokerFinalizers (broker , finalizers .List ())
520
563
521
564
c .recorder .Eventf (broker , corev1 .EventTypeNormal , successClusterServiceBrokerDeletedReason , successClusterServiceBrokerDeletedMessage , broker .Name )
522
- glog .V (5 ).Infof ("ClusterServiceBroker %q: Successfully deleted" , broker .Name )
565
+ glog .V (5 ).Infof ("%s %q: Successfully deleted" , typeCSB , broker .Name )
523
566
return nil
524
567
}
525
568
@@ -630,29 +673,47 @@ func (c *controller) reconcileClusterServicePlanFromClusterServiceBrokerCatalog(
630
673
// not already passed one; the following if statement will almost
631
674
// certainly evaluate to true.
632
675
if otherServicePlan .Spec .ClusterServiceBrokerName != broker .Name {
633
- errMsg := fmt .Sprintf ("ClusterServiceBroker %q: ClusterServicePlan %q already exists for Broker %q" , broker .Name , servicePlan .Spec .ExternalName , otherServicePlan .Spec .ClusterServiceBrokerName )
634
- glog .Error (errMsg )
676
+ errMsg := fmt .Sprintf (
677
+ "ClusterServicePlan (K8S: %q ExternalName: %q) already exists for Broker %q" ,
678
+ servicePlan .Name , servicePlan .Spec .ExternalName , otherServicePlan .Spec .ClusterServiceBrokerName ,
679
+ )
680
+ glog .Errorf (
681
+ `%s %q: %s` ,
682
+ typeCSB , broker .Name , errMsg ,
683
+ )
635
684
return fmt .Errorf (errMsg )
636
685
}
637
686
}
638
687
639
688
// An error returned from a lister Get call means that the object does
640
689
// not exist. Create a new ClusterServicePlan.
641
690
if _ , err := c .serviceCatalogClient .ClusterServicePlans ().Create (servicePlan ); err != nil {
642
- glog .Errorf ("ClusterServiceBroker %q: Error creating ClusterServicePlan %q: %v" , broker .Name , servicePlan .Name , err )
691
+ glog .Errorf (
692
+ "%s %q: Error creating ClusterServicePlan (K8S: %q, ExternalName: %q): %v" ,
693
+ typeCSB , broker .Name , servicePlan .Name , servicePlan .Spec .ExternalName , err ,
694
+ )
643
695
return err
644
696
}
645
697
646
698
return nil
647
699
}
648
700
649
701
if existingServicePlan .Spec .ExternalID != servicePlan .Spec .ExternalID {
650
- errMsg := fmt .Sprintf ("ClusterServiceBroker %q: ClusterServicePlan %q already exists with OSB guid %q, received different guid %q" , broker .Name , servicePlan .Name , existingServicePlan .Spec .ExternalID , servicePlan .Spec .ExternalID )
651
- glog .Error (errMsg )
702
+ errMsg := fmt .Sprintf (
703
+ "ClusterServicePlan (K8S: %q ExternalName: %q) already exists with OSB guid %q, received different guid %q" ,
704
+ servicePlan .Name , servicePlan .Spec .ExternalName , existingServicePlan .Spec .ExternalID , servicePlan .Spec .ExternalID ,
705
+ )
706
+ glog .Error (
707
+ "%s %q: %s" ,
708
+ typeCSB , broker .Name , errMsg ,
709
+ )
652
710
return fmt .Errorf (errMsg )
653
711
}
654
712
655
- glog .V (5 ).Infof ("ClusterServiceBroker %q: Found existing ClusterServicePlan %q; updating" , broker .Name , servicePlan .Name )
713
+ glog .V (5 ).Infof (
714
+ "%s %q: Found existing ClusterServicePlan (K8S: %q ExternalName: %q); updating" ,
715
+ typeCSB , broker .Name , servicePlan .Name , servicePlan .Spec .ExternalName ,
716
+ )
656
717
657
718
// There was an existing service plan -- project the update onto it and
658
719
// update it.
@@ -672,7 +733,10 @@ func (c *controller) reconcileClusterServicePlanFromClusterServiceBrokerCatalog(
672
733
toUpdate .Spec .ServiceBindingCreateParameterSchema = servicePlan .Spec .ServiceBindingCreateParameterSchema
673
734
674
735
if _ , err := c .serviceCatalogClient .ClusterServicePlans ().Update (toUpdate ); err != nil {
675
- glog .Errorf ("ClusterServiceBroker %q: Error updating ClusterServicePlan %q: %v" , broker .Name , servicePlan .Name , err )
736
+ glog .Errorf (
737
+ "%s %q: Error updating ClusterServicePlan (K8S: %q ExternalName: %q): %v" ,
738
+ typeCSB , broker .Name , servicePlan .Name , servicePlan .Spec .ExternalName , err ,
739
+ )
676
740
return err
677
741
}
678
742
@@ -697,14 +761,20 @@ func (c *controller) updateClusterServiceBrokerCondition(broker *v1beta1.Cluster
697
761
t := time .Now ()
698
762
699
763
if len (broker .Status .Conditions ) == 0 {
700
- glog .Infof ("ClusterServiceBroker %q: Setting lastTransitionTime for condition %q to %v" , broker .Name , conditionType , t )
764
+ glog .Infof (
765
+ "%s %q: Setting lastTransitionTime for condition %q to %v" ,
766
+ typeCSB , broker .Name , conditionType , t ,
767
+ )
701
768
newCondition .LastTransitionTime = metav1 .NewTime (t )
702
769
toUpdate .Status .Conditions = []v1beta1.ServiceBrokerCondition {newCondition }
703
770
} else {
704
771
for i , cond := range broker .Status .Conditions {
705
772
if cond .Type == conditionType {
706
773
if cond .Status != newCondition .Status {
707
- glog .Infof ("ClusterServiceBroker %q: Found status change for condition %q: %q -> %q; setting lastTransitionTime to %v" , broker .Name , conditionType , cond .Status , status , t )
774
+ glog .Infof (
775
+ "%s %q: Found status change for condition %q: %q -> %q; setting lastTransitionTime to %v" ,
776
+ typeCSB , broker .Name , conditionType , cond .Status , status , t ,
777
+ )
708
778
newCondition .LastTransitionTime = metav1 .NewTime (t )
709
779
} else {
710
780
newCondition .LastTransitionTime = cond .LastTransitionTime
@@ -722,12 +792,20 @@ func (c *controller) updateClusterServiceBrokerCondition(broker *v1beta1.Cluster
722
792
toUpdate .Status .ReconciledGeneration = toUpdate .Generation
723
793
}
724
794
725
- glog .V (4 ).Infof ("ClusterServiceBroker %q: Updating ready condition to %v" , broker .Name , status )
795
+ glog .V (4 ).Infof ("%s %q: Updating ready condition to %v" ,
796
+ typeCSB , broker .Name , status ,
797
+ )
726
798
_ , err = c .serviceCatalogClient .ClusterServiceBrokers ().UpdateStatus (toUpdate )
727
799
if err != nil {
728
- glog .Errorf ("ClusterServiceBroker %q: Error updating ready condition: %v" , broker .Name , err )
800
+ glog .Errorf (
801
+ "%s %q: Error updating ready condition: %v" ,
802
+ typeCSB , broker .Name , err ,
803
+ )
729
804
} else {
730
- glog .V (5 ).Infof ("ClusterServiceBroker %q: Updated ready condition to %v" , broker .Name , status )
805
+ glog .V (5 ).Infof (
806
+ "%s %q: Updated ready condition to %v" ,
807
+ typeCSB , broker .Name , status ,
808
+ )
731
809
}
732
810
733
811
return err
@@ -743,7 +821,10 @@ func (c *controller) updateClusterServiceBrokerFinalizers(
743
821
// now removing the last finalizer).
744
822
broker , err := c .serviceCatalogClient .ClusterServiceBrokers ().Get (broker .Name , metav1.GetOptions {})
745
823
if err != nil {
746
- glog .Errorf ("ClusterServiceBroker %q: Error finalizing: %v" , broker .Name , err )
824
+ glog .Errorf (
825
+ "%s %q: Error finalizing: %v" ,
826
+ typeCSB , broker .Name , err ,
827
+ )
747
828
}
748
829
749
830
clone , err := api .Scheme .DeepCopy (broker )
@@ -754,8 +835,10 @@ func (c *controller) updateClusterServiceBrokerFinalizers(
754
835
755
836
toUpdate .Finalizers = finalizers
756
837
757
- logContext := fmt .Sprintf ("ClusterServiceBroker %q: updating finalizers to %v" ,
758
- broker .Name , finalizers )
838
+ logContext := fmt .Sprintf (
839
+ "%s %q: updating finalizers to %v" ,
840
+ typeCSB , broker .Name , finalizers ,
841
+ )
759
842
760
843
glog .V (4 ).Infof ("Updating %v" , logContext )
761
844
_ , err = c .serviceCatalogClient .ClusterServiceBrokers ().UpdateStatus (toUpdate )
0 commit comments