Skip to content
This repository was archived by the owner on May 6, 2022. It is now read-only.

Commit 880e400

Browse files
authored
Handle panic with nil map on reconcile (#2884)
1 parent 7942106 commit 880e400

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

pkg/controller/controller_instance.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3007,6 +3007,9 @@ func (c *controller) triggerServiceBindingReconciliation(instance *v1beta1.Servi
30073007
}
30083008
klog.V(4).Infof("ServiceBinding %s/%s triggered to reconciliation", binding.Namespace, binding.Name)
30093009
toUpdate := binding.DeepCopy()
3010+
if toUpdate.Annotations == nil {
3011+
toUpdate.Annotations = make(map[string]string, 0)
3012+
}
30103013
toUpdate.ObjectMeta.Annotations["reconciliationTriggered"] = metav1.Now().String()
30113014
if _, err := c.serviceCatalogClient.ServiceBindings(toUpdate.Namespace).Update(context.Background(), toUpdate, metav1.UpdateOptions{}); err != nil {
30123015
klog.Errorf("Couldn't update ServiceBinding %q status for instance %q. Bindings will be triggered after set delay. error: %v", binding.Name, binding.Spec.InstanceRef.Name, err)

pkg/controller/controller_instance_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,8 @@ func TestReconcileServiceInstanceWithParameters(t *testing.T) {
624624
sharedInformers.ClusterServiceBrokers().Informer().GetStore().Add(getTestClusterServiceBroker())
625625
sharedInformers.ClusterServiceClasses().Informer().GetStore().Add(getTestClusterServiceClass())
626626
sharedInformers.ClusterServicePlans().Informer().GetStore().Add(getTestClusterServicePlan())
627+
credentials := getTestServiceBinding()
628+
sharedInformers.ServiceBindings().Informer().GetStore().Add(credentials)
627629

628630
for _, s := range tc.secrets {
629631
fakeKubeClient.PrependReactor("get", "secrets", func(action clientgotesting.Action) (bool, runtime.Object, error) {
@@ -739,7 +741,8 @@ func TestReconcileServiceInstanceWithParameters(t *testing.T) {
739741
})
740742

741743
actions = fakeCatalogClient.Actions()
742-
assertNumberOfActions(t, actions, 1)
744+
assertNumberOfActions(t, actions, 2)
745+
assertUpdate(t, actions[1], credentials)
743746
updatedServiceInstance = assertUpdateStatus(t, actions[0], instance)
744747
assertServiceInstanceOperationSuccessWithParameters(t,
745748
updatedServiceInstance,

0 commit comments

Comments
 (0)