Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions config/provisioners/in-memory-channel/in-memory-channel.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,22 @@ rules:
- list
- watch
- create
- apiGroups:
- "" # Core API group.
resources:
- services
resourceNames:
- in-memory-channel-clusterbus
verbs:
- delete
- apiGroups:
- "" # Core API group.
resources:
- services
resourceNames:
- in-memory-channel-dispatcher
verbs:
- update
- apiGroups:
- "" # Core API Group.
resources:
Expand All @@ -76,6 +92,7 @@ rules:
- list
- watch
- create
- update

---

Expand Down
9 changes: 9 additions & 0 deletions config/provisioners/kafka/kafka.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ rules:
- list
- watch
- create
- apiGroups:
- "" # Core API group.
resources:
- services
resourceNames:
- kafka-dispatcher
verbs:
- update
- apiGroups:
- "" # Core API Group.
resources:
Expand All @@ -68,6 +76,7 @@ rules:
- list
- watch
- create
- update
---

apiVersion: rbac.authorization.k8s.io/v1beta1
Expand Down
65 changes: 0 additions & 65 deletions pkg/buses/logger.go

This file was deleted.

95 changes: 0 additions & 95 deletions pkg/buses/references_test.go

This file was deleted.

2 changes: 1 addition & 1 deletion pkg/controller/eventing/inmemory/channel/reconcile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ func makeVirtualService() *istiov1alpha3.VirtualService {
},
Route: []istiov1alpha3.DestinationWeight{{
Destination: istiov1alpha3.Destination{
Host: "in-memory-channel-clusterbus.knative-eventing.svc.cluster.local",
Host: "in-memory-channel-dispatcher.knative-eventing.svc.cluster.local",
Port: istiov1alpha3.PortSelector{
Number: util.PortNumber,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,20 @@ package clusterchannelprovisioner

import (
"context"
"fmt"

"go.uber.org/zap"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/tools/record"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/reconcile"

eventingv1alpha1 "github.com/knative/eventing/pkg/apis/eventing/v1alpha1"
util "github.com/knative/eventing/pkg/provisioners"
"github.com/knative/eventing/pkg/system"
)

const (
Expand Down Expand Up @@ -139,6 +142,32 @@ func (r *reconciler) reconcile(ctx context.Context, ccp *eventingv1alpha1.Cluste
logger.Warn("ClusterChannelProvisioner's K8s Service is not owned by the ClusterChannelProvisioner", zap.Any("clusterChannelProvisioner", ccp), zap.Any("service", svc))
}

// The name of the svc has changed since version 0.2.1. Hence, delete old dispatcher service (in-memory-channel-clusterbus)
// that was created previously in version 0.2.0 to ensure backwards compatibility.
err = r.deleteOldDispatcherService(ctx, ccp)
if err != nil {
logger.Info("Error deleting the old ClusterChannelProvisioner's K8s Service", zap.Error(err))
return err
}

ccp.Status.MarkReady()
return nil
}

func (r *reconciler) deleteOldDispatcherService(ctx context.Context, ccp *eventingv1alpha1.ClusterChannelProvisioner) error {
svcName := fmt.Sprintf("%s-clusterbus", ccp.Name)
svcKey := types.NamespacedName{
Namespace: system.Namespace,
Name: svcName,
}
svc := &corev1.Service{}
err := r.client.Get(ctx, svcKey, svc)
if err != nil {
if errors.IsNotFound(err) {
return nil
}
return err
}

return r.client.Delete(ctx, svc)
}
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,20 @@ func TestReconcile(t *testing.T) {
makeReadyClusterChannelProvisioner(),
},
},
{
Name: "Delete old dispatcher",
InitialState: []runtime.Object{
makeClusterChannelProvisioner(),
makeOldK8sService(),
},
WantPresent: []runtime.Object{
makeReadyClusterChannelProvisioner(),
makeK8sService(),
},
WantAbsent: []runtime.Object{
makeOldK8sService(),
},
},
{
Name: "Create dispatcher - not owned by CCP",
InitialState: []runtime.Object{
Expand Down Expand Up @@ -279,7 +293,7 @@ func makeK8sService() *corev1.Service {
},
ObjectMeta: metav1.ObjectMeta{
Namespace: system.Namespace,
Name: fmt.Sprintf("%s-clusterbus", Name),
Name: fmt.Sprintf("%s-dispatcher", Name),
OwnerReferences: []metav1.OwnerReference{
{
APIVersion: eventingv1alpha1.SchemeGroupVersion.String(),
Expand All @@ -305,6 +319,12 @@ func makeK8sService() *corev1.Service {
}
}

func makeOldK8sService() *corev1.Service {
svc := makeK8sService()
svc.ObjectMeta.Name = fmt.Sprintf("%s-clusterbus", Name)
return svc
}

func makeK8sServiceNotOwnedByClusterChannelProvisioner() *corev1.Service {
svc := makeK8sService()
svc.OwnerReferences = nil
Expand Down
6 changes: 3 additions & 3 deletions pkg/controller/eventing/inmemory/controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import (
"flag"

eventingv1alpha1 "github.com/knative/eventing/pkg/apis/eventing/v1alpha1"
"github.com/knative/eventing/pkg/buses"
"github.com/knative/eventing/pkg/controller/eventing/inmemory/channel"
"github.com/knative/eventing/pkg/controller/eventing/inmemory/clusterchannelprovisioner"
"github.com/knative/eventing/pkg/provisioners"
istiov1alpha3 "github.com/knative/pkg/apis/istio/v1alpha3"
"github.com/knative/pkg/signals"
"go.uber.org/zap"
Expand All @@ -31,8 +31,8 @@ import (
)

func main() {
logConfig := buses.NewLoggingConfig()
logger := buses.NewBusLoggerFromConfig(logConfig)
logConfig := provisioners.NewLoggingConfig()
logger := provisioners.NewProvisionerLoggerFromConfig(logConfig)
defer logger.Sync()
logger = logger.With(
zap.String("eventing.knative.dev/clusterChannelProvisioner", clusterchannelprovisioner.Name),
Expand Down
16 changes: 0 additions & 16 deletions pkg/controller/names.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,6 @@ package controller

import "fmt"

func ClusterBusDispatcherServiceName(clusterBusName string) string {
return fmt.Sprintf("%s-clusterbus", clusterBusName)
}

func ChannelVirtualServiceName(channelName string) string {
return fmt.Sprintf("%s-channel", channelName)
}

func ChannelServiceName(channelName string) string {
return fmt.Sprintf("%s-channel", channelName)
}

func ChannelHostName(channelName, namespace string) string {
return fmt.Sprintf("%s.%s.channels.cluster.local", channelName, namespace)
}

func ServiceHostName(serviceName, namespace string) string {
return fmt.Sprintf("%s.%s.svc.cluster.local", serviceName, namespace)
}
24 changes: 0 additions & 24 deletions pkg/controller/names_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,30 +26,6 @@ func TestNames(t *testing.T) {
F func() string
Want string
}{{
Name: "ClusterBusDispatcherServiceName",
F: func() string {
return ClusterBusDispatcherServiceName("foo")
},
Want: "foo-clusterbus",
}, {
Name: "ChannelVirtualServiceName",
F: func() string {
return ChannelVirtualServiceName("foo")
},
Want: "foo-channel",
}, {
Name: "ChannelServiceName",
F: func() string {
return ChannelServiceName("foo")
},
Want: "foo-channel",
}, {
Name: "ChannelHostName",
F: func() string {
return ChannelHostName("foo", "namespace")
},
Want: "foo.namespace.channels.cluster.local",
}, {
Name: "ServiceHostName",
F: func() string {
return ServiceHostName("foo", "namespace")
Expand Down
Loading