From facd00db077a343538cf3a71c312910fefa21022 Mon Sep 17 00:00:00 2001 From: Scott Andrews Date: Tue, 31 Jul 2018 17:59:49 -0400 Subject: [PATCH] Avoid replacing the monitor's bus with the wrong bus For a namespaces bus, if there is a cluster bus installed with the same name, the cluster bus will be captured in the monitor and used to check if a channel is for that bus. This effectively causes channels to be provisioned by the wrong bus, or not at all. Before replacing the bus reference for the monitor, we need to check the kind, name and namespace. Previously, only the name and namespace where checked. --- pkg/buses/monitor.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/pkg/buses/monitor.go b/pkg/buses/monitor.go index 343deea5bbc..144a3c801e8 100644 --- a/pkg/buses/monitor.go +++ b/pkg/buses/monitor.go @@ -543,14 +543,14 @@ func (m *Monitor) Run(busNamespace, busName string, threadiness int, stopCh <-ch if err != nil { glog.Fatalf("Unknown clusterbus %q", busName) } - m.bus = clusterBus + m.bus = clusterBus.DeepCopy() } else { // monitor is for a namespaced Bus bus, err := m.busesLister.Buses(busNamespace).Get(busName) if err != nil { glog.Fatalf("Unknown bus '%s/%s'", busNamespace, busName) } - m.bus = bus + m.bus = bus.DeepCopy() } glog.Info("Starting workers") @@ -787,14 +787,15 @@ func (m *Monitor) getOrCreateChannelSummary(key channelKey) *channelSummary { } func (m *Monitor) createOrUpdateBus(bus *channelsv1alpha1.Bus) error { - if bus.Namespace != m.bus.GetObjectMeta().GetNamespace() || + if m.bus.GetObjectKind().GroupVersionKind().Kind != bus.Kind || + bus.Namespace != m.bus.GetObjectMeta().GetNamespace() || bus.Name != m.bus.GetObjectMeta().GetName() { // this is not our bus return nil } if !reflect.DeepEqual(m.bus.GetSpec(), bus.Spec) { - m.bus = bus + m.bus = bus.DeepCopy() err := m.handler.onBus(bus, m) if err != nil { return err @@ -805,13 +806,14 @@ func (m *Monitor) createOrUpdateBus(bus *channelsv1alpha1.Bus) error { } func (m *Monitor) createOrUpdateClusterBus(clusterBus *channelsv1alpha1.ClusterBus) error { - if clusterBus.Name != m.bus.GetObjectMeta().GetName() { + if m.bus.GetObjectKind().GroupVersionKind().Kind != clusterBus.Kind || + clusterBus.Name != m.bus.GetObjectMeta().GetName() { // this is not our clusterbus return nil } if !reflect.DeepEqual(m.bus.GetSpec(), clusterBus.Spec) { - m.bus = clusterBus + m.bus = clusterBus.DeepCopy() err := m.handler.onBus(clusterBus, m) if err != nil { return err