Skip to content

Commit 07d3068

Browse files
n3wscottpmorie
authored andcommitted
Rework the logging for controller_instance. (#1371)
* Rework the logging for controller_instance. * Updating other usages of ClusterServiceClass. * Fixing up unit tests. * Merge with master. * Recover from a bad merge. * use format. * use format. * Fixing tests.
1 parent 5f4ca01 commit 07d3068

7 files changed

+487
-206
lines changed

pkg/controller/controller.go

+51-15
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,14 @@ func worker(queue workqueue.RateLimitingInterface, resourceType string, maxRetri
249249
func (c *controller) getClusterServiceClassPlanAndClusterServiceBroker(instance *v1beta1.ServiceInstance) (*v1beta1.ClusterServiceClass, *v1beta1.ClusterServicePlan, string, osb.Client, error) {
250250
serviceClass, err := c.serviceClassLister.Get(instance.Spec.ClusterServiceClassRef.Name)
251251
if err != nil {
252-
s := fmt.Sprintf("ServiceInstance \"%s/%s\" references a non-existent ClusterServiceClass %q : K8S Name: %q", instance.Namespace, instance.Name, instance.Spec.ExternalClusterServiceClassName, instance.Spec.ClusterServiceClassName)
253-
glog.Info(s)
252+
s := fmt.Sprintf(
253+
"References a non-existent ClusterServiceClass (K8S: %q ExternalName: %q)",
254+
instance.Spec.ClusterServiceClassRef.Name, instance.Spec.ExternalClusterServiceClassName,
255+
)
256+
glog.Infof(
257+
`ServiceInstance "%v/%v": %s`,
258+
instance.Namespace, instance.Name, s,
259+
)
254260
c.updateServiceInstanceCondition(
255261
instance,
256262
v1beta1.ServiceInstanceConditionReady,
@@ -264,8 +270,14 @@ func (c *controller) getClusterServiceClassPlanAndClusterServiceBroker(instance
264270

265271
servicePlan, err := c.servicePlanLister.Get(instance.Spec.ClusterServicePlanRef.Name)
266272
if nil != err {
267-
s := fmt.Sprintf(`ServiceInstance "%v/%v": references a non-existent ClusterServicePlan %q : K8S Name: %q on ClusterServiceClass %q`, instance.Namespace, instance.Name, instance.Spec.ExternalClusterServicePlanName, instance.Spec.ClusterServicePlanName, serviceClass.Spec.ExternalName)
268-
glog.Warning(s)
273+
s := fmt.Sprintf(
274+
"References a non-existent ClusterServicePlan %q on ClusterServiceClass (K8S: %q ExternalName: %q)",
275+
instance.Spec.ExternalClusterServicePlanName, serviceClass.Name, serviceClass.Spec.ExternalName,
276+
)
277+
glog.Warningf(
278+
`ServiceInstance "%s/%s": %s`,
279+
instance.Namespace, instance.Name, s,
280+
)
269281
c.updateServiceInstanceCondition(
270282
instance,
271283
v1beta1.ServiceInstanceConditionReady,
@@ -279,8 +291,11 @@ func (c *controller) getClusterServiceClassPlanAndClusterServiceBroker(instance
279291

280292
broker, err := c.brokerLister.Get(serviceClass.Spec.ClusterServiceBrokerName)
281293
if err != nil {
282-
s := fmt.Sprintf(`ServiceInstance "%v/%v": references a non-existent broker %q`, instance.Namespace, instance.Name, serviceClass.Spec.ClusterServiceBrokerName)
283-
glog.Warning(s)
294+
s := fmt.Sprintf("References a non-existent broker %q", serviceClass.Spec.ClusterServiceBrokerName)
295+
glog.Warningf(
296+
`ServiceInstance "%s/%s": %s`,
297+
instance.Namespace, instance.Name, s,
298+
)
284299
c.updateServiceInstanceCondition(
285300
instance,
286301
v1beta1.ServiceInstanceConditionReady,
@@ -295,7 +310,10 @@ func (c *controller) getClusterServiceClassPlanAndClusterServiceBroker(instance
295310
authConfig, err := getAuthCredentialsFromClusterServiceBroker(c.kubeClient, broker)
296311
if err != nil {
297312
s := fmt.Sprintf("Error getting broker auth credentials for broker %q: %s", broker.Name, err)
298-
glog.Info(s)
313+
glog.Infof(
314+
`ServiceInstance "%v/%v": %s`,
315+
instance.Namespace, instance.Name, s,
316+
)
299317
c.updateServiceInstanceCondition(
300318
instance,
301319
v1beta1.ServiceInstanceConditionReady,
@@ -325,8 +343,14 @@ func (c *controller) getClusterServiceClassPlanAndClusterServiceBroker(instance
325343
func (c *controller) getClusterServiceClassPlanAndClusterServiceBrokerForServiceBinding(instance *v1beta1.ServiceInstance, binding *v1beta1.ServiceBinding) (*v1beta1.ClusterServiceClass, *v1beta1.ClusterServicePlan, string, osb.Client, error) {
326344
serviceClass, err := c.serviceClassLister.Get(instance.Spec.ClusterServiceClassRef.Name)
327345
if err != nil {
328-
s := fmt.Sprintf("ServiceBinding \"%s/%s\" references a non-existent ClusterServiceClass %q : K8S name %q", binding.Namespace, binding.Name, instance.Spec.ExternalClusterServiceClassName, instance.Spec.ClusterServiceClassName)
329-
glog.Warning(s)
346+
s := fmt.Sprintf(
347+
"References a non-existent ClusterServiceClass (K8S: %q ExternalName: %q)",
348+
instance.Spec.ClusterServiceClassRef.Name, instance.Spec.ExternalClusterServiceClassName,
349+
)
350+
glog.Warningf(
351+
`ServiceBinding "%s/%s": %s`,
352+
instance.Namespace, instance.Name, s,
353+
)
330354
c.updateServiceBindingCondition(
331355
binding,
332356
v1beta1.ServiceBindingConditionReady,
@@ -340,8 +364,14 @@ func (c *controller) getClusterServiceClassPlanAndClusterServiceBrokerForService
340364

341365
servicePlan, err := c.servicePlanLister.Get(instance.Spec.ClusterServicePlanRef.Name)
342366
if nil != err {
343-
s := fmt.Sprintf("ServiceInstance \"%s/%s\" references a non-existent ClusterServicePlan %q : K8S name %q on ClusterServiceClass %q", instance.Namespace, instance.Name, instance.Spec.ExternalClusterServicePlanName, instance.Spec.ClusterServicePlanName, serviceClass.Spec.ExternalName)
344-
glog.Warning(s)
367+
s := fmt.Sprintf(
368+
"References a non-existent ClusterServicePlan %q on ClusterServiceClass (K8S: %q ExternalName: %q)",
369+
instance.Spec.ExternalClusterServicePlanName, serviceClass.Name, serviceClass.Spec.ExternalName,
370+
)
371+
glog.Warningf(
372+
`ServiceBinding "%s/%s": %s`,
373+
instance.Namespace, instance.Name, s,
374+
)
345375
c.updateServiceBindingCondition(
346376
binding,
347377
v1beta1.ServiceBindingConditionReady,
@@ -355,8 +385,11 @@ func (c *controller) getClusterServiceClassPlanAndClusterServiceBrokerForService
355385

356386
broker, err := c.brokerLister.Get(serviceClass.Spec.ClusterServiceBrokerName)
357387
if err != nil {
358-
s := fmt.Sprintf("ServiceBinding \"%s/%s\" references a non-existent ClusterServiceBroker %q", binding.Namespace, binding.Name, serviceClass.Spec.ClusterServiceBrokerName)
359-
glog.Warning(s)
388+
s := fmt.Sprintf("References a non-existent ClusterServiceBroker %q", serviceClass.Spec.ClusterServiceBrokerName)
389+
glog.Warningf(
390+
`ServiceBinding "%s/%s": %s`,
391+
instance.Namespace, instance.Name, s,
392+
)
360393
c.updateServiceBindingCondition(
361394
binding,
362395
v1beta1.ServiceBindingConditionReady,
@@ -371,7 +404,10 @@ func (c *controller) getClusterServiceClassPlanAndClusterServiceBrokerForService
371404
authConfig, err := getAuthCredentialsFromClusterServiceBroker(c.kubeClient, broker)
372405
if err != nil {
373406
s := fmt.Sprintf("Error getting broker auth credentials for broker %q: %s", broker.Name, err)
374-
glog.Warning(s)
407+
glog.Warningf(
408+
`ServiceBinding "%s/%s": %s`,
409+
instance.Namespace, instance.Name, s,
410+
)
375411
c.updateServiceBindingCondition(
376412
binding,
377413
v1beta1.ServiceBindingConditionReady,
@@ -518,7 +554,7 @@ func convertCatalog(in *osb.CatalogResponse) ([]*v1beta1.ClusterServiceClass, []
518554

519555
func convertClusterServicePlans(plans []osb.Plan, serviceClassID string) ([]*v1beta1.ClusterServicePlan, error) {
520556
if 0 == len(plans) {
521-
return nil, fmt.Errorf("ClusterServiceClass %q must have at least one plan", serviceClassID)
557+
return nil, fmt.Errorf("ClusterServiceClass (K8S: %q) must have at least one plan", serviceClassID)
522558
}
523559
servicePlans := make([]*v1beta1.ClusterServicePlan, len(plans))
524560
for i, plan := range plans {

0 commit comments

Comments
 (0)