Skip to content

Commit d1e6cb4

Browse files
Use v2 specific label to avoid matching previous deployment-based dispatchers (#4105)
This ensures that our `consumergroup` controller as well as replication controller only match v2-specific pods and won't try to reconcile pods that belong to the previous deployment. Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com> Co-authored-by: Pierangelo Di Pilato <pierdipi@redhat.com>
1 parent ea10ce6 commit d1e6cb4

File tree

6 files changed

+21
-10
lines changed

6 files changed

+21
-10
lines changed

control-plane/pkg/reconciler/consumergroup/consumergroup.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,10 @@ func (r *Reconciler) reconcileSecret(ctx context.Context, expectedSecret *corev1
766766
}
767767

768768
func (r *Reconciler) ensureContractConfigmapsExist(ctx context.Context, scheduler Scheduler) error {
769-
selector := labels.SelectorFromSet(map[string]string{"app": scheduler.StatefulSetName})
769+
selector := labels.SelectorFromSet(map[string]string{
770+
"app": scheduler.StatefulSetName,
771+
"app.kubernetes.io/kind": "kafka-dispatcher",
772+
})
770773
pods, err := r.PodLister.
771774
Pods(r.SystemNamespace).
772775
List(selector)

control-plane/pkg/reconciler/consumergroup/consumergroup_test.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ func TestReconcileKind(t *testing.T) {
167167
Name: "Consumers in multiple pods, with pods pending and unknown phase",
168168
Objects: []runtime.Object{
169169
NewService(),
170-
NewDispatcherPod("p1", PodLabel(kafkainternals.SourceStatefulSetName), PodPending()),
171-
NewDispatcherPod("p2", PodLabel(kafkainternals.SourceStatefulSetName)),
170+
NewDispatcherPod("p1", PodLabel("app", kafkainternals.SourceStatefulSetName), DispatcherLabel(), PodPending()),
171+
NewDispatcherPod("p2", PodLabel("app", kafkainternals.SourceStatefulSetName), DispatcherLabel()),
172172
NewConsumerGroup(
173173
ConsumerGroupConsumerSpec(NewConsumerSpec(
174174
ConsumerTopics("t1", "t2"),
@@ -1717,6 +1717,10 @@ func TestReconcileKind(t *testing.T) {
17171717

17181718
}
17191719

1720+
func DispatcherLabel() PodOption {
1721+
return PodLabel("app.kubernetes.io/kind", "kafka-dispatcher")
1722+
}
1723+
17201724
func TestReconcileKindNoAutoscaler(t *testing.T) {
17211725

17221726
tt := TableTest{

control-plane/pkg/reconciler/testing/objects_broker.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,8 @@ func BrokerDispatcherPod(namespace string, annotations map[string]string) runtim
424424
Namespace: namespace,
425425
Annotations: annotations,
426426
Labels: map[string]string{
427-
"app": base.BrokerDispatcherLabel,
427+
"app": base.BrokerDispatcherLabel,
428+
"app.kubernetes.io/kind": "kafka-dispatcher",
428429
},
429430
},
430431
Status: corev1.PodStatus{

control-plane/pkg/reconciler/testing/objects_channel.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,8 @@ func ChannelDispatcherPod(namespace string, annotations map[string]string) runti
191191
Namespace: namespace,
192192
Annotations: annotations,
193193
Labels: map[string]string{
194-
"app": base.ChannelDispatcherLabel,
194+
"app": base.ChannelDispatcherLabel,
195+
"app.kubernetes.io/kind": "kafka-dispatcher",
195196
},
196197
},
197198
Status: corev1.PodStatus{

control-plane/pkg/reconciler/testing/objects_common.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -616,12 +616,12 @@ func NewDispatcherPod(name string, options ...PodOption) *corev1.Pod {
616616
return p
617617
}
618618

619-
func PodLabel(value string) PodOption {
619+
func PodLabel(key, value string) PodOption {
620620
return func(pod *corev1.Pod) {
621621
if pod.Labels == nil {
622622
pod.Labels = make(map[string]string, 2)
623623
}
624-
pod.Labels["app"] = value
624+
pod.Labels[key] = value
625625
}
626626
}
627627

control-plane/pkg/reconciler/testing/objects_source.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,15 @@ import (
2323
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2424
"k8s.io/apimachinery/pkg/runtime"
2525
"k8s.io/utils/pointer"
26-
"knative.dev/eventing-kafka-broker/control-plane/pkg/apis/bindings/v1beta1"
27-
sources "knative.dev/eventing-kafka-broker/control-plane/pkg/apis/sources/v1beta1"
2826
eventingduck "knative.dev/eventing/pkg/apis/duck/v1"
2927
"knative.dev/eventing/pkg/apis/feature"
3028
"knative.dev/eventing/pkg/eventingtls/eventingtlstesting"
3129
"knative.dev/pkg/apis"
3230
duckv1 "knative.dev/pkg/apis/duck/v1"
3331

32+
"knative.dev/eventing-kafka-broker/control-plane/pkg/apis/bindings/v1beta1"
33+
sources "knative.dev/eventing-kafka-broker/control-plane/pkg/apis/sources/v1beta1"
34+
3435
"knative.dev/eventing-kafka-broker/control-plane/pkg/contract"
3536
"knative.dev/eventing-kafka-broker/control-plane/pkg/reconciler/base"
3637
)
@@ -215,7 +216,8 @@ func SourceDispatcherPod(namespace string, annotations map[string]string) runtim
215216
Namespace: namespace,
216217
Annotations: annotations,
217218
Labels: map[string]string{
218-
"app": base.SourceDispatcherLabel,
219+
"app": base.SourceDispatcherLabel,
220+
"app.kubernetes.io/kind": "kafka-dispatcher",
219221
},
220222
},
221223
Status: corev1.PodStatus{

0 commit comments

Comments
 (0)