Skip to content

Commit

Permalink
Revert subscription controller changes for knative 0.7 (#5536)
Browse files Browse the repository at this point in the history
* Revert "uncomment event-bus subscription-controller tests (#5418)"

This reverts commit f153bb3.

* Revert "updated k8s libs to 1.15.2 (#5356)"

This reverts commit ca911a6.
  • Loading branch information
sayanh authored Sep 4, 2019
1 parent 354691a commit 4ae04fa
Show file tree
Hide file tree
Showing 10 changed files with 445 additions and 898 deletions.
1,238 changes: 387 additions & 851 deletions components/event-bus/Gopkg.lock

Large diffs are not rendered by default.

49 changes: 35 additions & 14 deletions components/event-bus/Gopkg.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,34 @@
required = [
"k8s.io/code-generator/cmd/defaulter-gen",
"k8s.io/code-generator/cmd/deepcopy-gen",
"k8s.io/code-generator/cmd/conversion-gen",
"k8s.io/code-generator/cmd/client-gen",
"k8s.io/code-generator/cmd/lister-gen",
"k8s.io/code-generator/cmd/informer-gen",
"k8s.io/code-generator/cmd/openapi-gen",
"k8s.io/gengo/args",
"github.com/emicklei/go-restful",
"github.com/onsi/ginkgo", # for test framework
"github.com/onsi/gomega", # for test matchers
"sigs.k8s.io/controller-tools/cmd/controller-gen", # for crd/rbac generation
"sigs.k8s.io/testing_frameworks/integration", # for integration testing
"k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1",
"golang.org/x/lint/golint",
"golang.org/x/tools/cmd/goimports",
]

[[constraint]]
name = "github.com/nats-io/go-nats"
version = "1.6.0"

[[constraint]]
name = "github.com/nats-io/go-nats-streaming"
version = "0.4.0"

[[constraint]]
name = "github.com/nats-io/nats-streaming-server"
version = "0.11.0"

[[constraint]]
name = "github.com/opentracing/opentracing-go"
version = "1.0.2"
Expand All @@ -27,7 +47,8 @@ required = [

[[constraint]]
name = "sigs.k8s.io/controller-runtime"
version = "=0.1.9"
# HEAD as of 2018-09-19
revision = "5373e8e1f3188ff4266902a6fc86372bc14b3815"

[[override]]
name = "gopkg.in/fsnotify.v1"
Expand All @@ -36,41 +57,41 @@ required = [

[[override]]
name = "k8s.io/apimachinery"
version = "kubernetes-1.12.6"
version = "kubernetes-1.11.3"

[[override]]
name = "k8s.io/client-go"
version = "kubernetes-1.12.6"
version = "kubernetes-1.11.3"

[[override]]
name = "k8s.io/api"
version = "kubernetes-1.12.6"
name = "k8s.io/code-generator"
version = "kubernetes-1.11.3"

[[override]]
name = "k8s.io/apiextensions-apiserver"
version = "kubernetes-1.12.6"
name = "k8s.io/api"
version = "kubernetes-1.11.3"

[[override]]
branch = "master"
name = "github.com/apache/thrift"

[[override]]
name = "github.com/knative/pkg"
branch = "release-0.7"
# HEAD as of 2019-02-14
revision = "0183bf9cdc7349e3c76c26e51f84689b411fccea"

[[override]]
name = "github.com/knative/eventing"
version = "v0.7.1"
version = "v0.4.1"

[prune]
non-go = true
go-tests = true
unused-packages = true

[[override]]
name = "contrib.go.opencensus.io/resource"
revision = "d49915945c0f6d4b2f04a34cdf043182e04c443a"
[[prune.project]]
name = "k8s.io/code-generator"
unused-packages = false

[[constraint]]
name = "github.com/prometheus/client_golang"
version = "0.9.2"
version = "0.9.2"
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package v1alpha1

import (
eventingkymaio "github.com/kyma-project/kyma/components/event-bus/api/push/eventing.kyma-project.io"
"github.com/kyma-project/kyma/components/event-bus/api/push/eventing.kyma-project.io"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package handlers
import (
"encoding/json"

publishv1 "github.com/kyma-project/kyma/components/event-bus/api/publish/v1"
"github.com/kyma-project/kyma/components/event-bus/api/publish/v1"
publishv2 "github.com/kyma-project/kyma/components/event-bus/api/publish/v2"

"log"
Expand Down Expand Up @@ -124,7 +124,7 @@ func handleKnativePublishRequestV1(w http.ResponseWriter, r *http.Request, knati
}

// validate the publish request
if err = publishv1.ValidatePublish(publishRequest, opts.EventOptions); err != nil {
if err = v1.ValidatePublish(publishRequest, opts.EventOptions); err != nil {
log.Printf("validate publish failed: %v", err)
_ = sendJSONError(w, err)
return nil, nil, nil, err, publisher.FAILED
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ func (r *reconciler) reconcile(ctx context.Context, subscription *eventingv1alph
log.Info("Knative Subscription is created", "Subscription", knativeSubsName)
} else {
// In case there is a change in Channel name or URI, delete and re-create Knative Subscription because update does not work.
if knativeChannelName != sub.Spec.Channel.Name || knativeSubsURI != *sub.Spec.Subscriber.URI {
if knativeChannelName != sub.Spec.Channel.Name || knativeSubsURI != *sub.Spec.Subscriber.DNSName {
err = r.knativeLib.DeleteSubscription(knativeSubsName, knativeSubsNamespace)
if err != nil {
return false, err
Expand Down Expand Up @@ -297,7 +297,7 @@ func (r *reconciler) deleteExternalDependency(ctx context.Context, knativeSubsNa
return err
} else if err == nil {
if knativeChannel.Spec.Subscribable == nil || (len(knativeChannel.Spec.Subscribable.Subscribers) == 1 && knativeSubs != nil &&
knativeChannel.Spec.Subscribable.Subscribers[0].SubscriberURI == *knativeSubs.Spec.Subscriber.URI) {
knativeChannel.Spec.Subscribable.Subscribers[0].SubscriberURI == *knativeSubs.Spec.Subscriber.DNSName) {
err = r.knativeLib.DeleteChannel(channelName, namespace)
if err != nil {
return err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ import (
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/knative/pkg/apis"
"sigs.k8s.io/controller-runtime/pkg/reconcile"

"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/reconcile"

evapisv1alpha1 "github.com/knative/eventing/pkg/apis/eventing/v1alpha1"
eventingclientset "github.com/knative/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1"
controllertesting "github.com/knative/eventing/pkg/reconciler/testing"
duckv1beta1 "github.com/knative/pkg/apis/duck/v1beta1"
duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1"
eventingv1alpha1 "github.com/kyma-project/kyma/components/event-bus/api/push/eventing.kyma-project.io/v1alpha1"
"github.com/kyma-project/kyma/components/event-bus/internal/knative/subscription/opts"
"github.com/kyma-project/kyma/components/event-bus/internal/knative/util"
Expand Down Expand Up @@ -348,7 +348,6 @@ func (k *MockKnativeLib) GetChannel(name string, namespace string) (*evapisv1alp
}
return channel, nil
}

func (k *MockKnativeLib) CreateChannel(provisioner string, name string, namespace string, labels *map[string]string, timeout time.Duration) (*evapisv1alpha1.Channel, error) {
channel := makeKnChannel(provisioner, namespace, name, labels)
knChannels[channel.Name] = channel
Expand All @@ -363,7 +362,6 @@ func (k *MockKnativeLib) CreateSubscription(name string, namespace string, chann
knSubscriptions[knSub.Name] = knSub
return nil
}

func (k *MockKnativeLib) DeleteSubscription(name string, namespace string) error {
delete(knSubscriptions, name)
return nil
Expand All @@ -382,7 +380,6 @@ func (k *MockKnativeLib) UpdateSubscription(sub *evapisv1alpha1.Subscription) (*
func (k *MockKnativeLib) SendMessage(channel *evapisv1alpha1.Channel, headers *map[string][]string, message *string) error {
return nil
}

func (k *MockKnativeLib) InjectClient(c eventingclientset.EventingV1alpha1Interface) error {
return nil
}
Expand All @@ -408,12 +405,10 @@ func makeKnChannel(provisioner string, namespace string, name string, labels *ma
},
},
Status: evapisv1alpha1.ChannelStatus{
Status: duckv1beta1.Status{
Conditions: duckv1beta1.Conditions{
apis.Condition{
Type: apis.ConditionReady,
Status: corev1.ConditionTrue,
},
Conditions: []duckv1alpha1.Condition{
{
Type: evapisv1alpha1.ChannelConditionReady,
Status: corev1.ConditionTrue,
},
},
},
Expand Down
21 changes: 8 additions & 13 deletions components/event-bus/internal/knative/util/kn-eventing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
evapisv1alpha1 "github.com/knative/eventing/pkg/apis/eventing/v1alpha1"
evclientsetfake "github.com/knative/eventing/pkg/client/clientset/versioned/fake"
"github.com/knative/pkg/apis"
duckv1beta1 "github.com/knative/pkg/apis/duck/v1beta1"
duckv1alpha1 "github.com/knative/pkg/apis/duck/v1alpha1"
"github.com/stretchr/testify/assert"
corev1 "k8s.io/api/core/v1"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
Expand Down Expand Up @@ -46,12 +46,10 @@ var (
},
},
Status: evapisv1alpha1.ChannelStatus{
Status: duckv1beta1.Status{
Conditions: duckv1beta1.Conditions{
apis.Condition{
Type: apis.ConditionReady,
Status: corev1.ConditionTrue,
},
Conditions: []duckv1alpha1.Condition{
{
Type: evapisv1alpha1.ChannelConditionReady,
Status: corev1.ConditionTrue,
},
},
},
Expand Down Expand Up @@ -121,10 +119,8 @@ func Test_CreateChannelTimeout(t *testing.T) {
client.Fake.ReactionChain = nil
client.Fake.AddReactor("create", "channels", func(action k8stesting.Action) (handled bool,
ret runtime.Object, err error) {
notReadyCondition := apis.Condition{
Type: apis.ConditionReady,
Status: corev1.ConditionFalse,
}
notReadyCondition := duckv1alpha1.Condition{
Type: evapisv1alpha1.ChannelConditionReady, Status: corev1.ConditionFalse}
tc := testChannel.DeepCopy()
tc.Status.Conditions[0] = notReadyCondition
return true, tc, nil
Expand Down Expand Up @@ -167,8 +163,7 @@ func Test_SendMessage(t *testing.T) {
assert.Nil(t, err)
u, err := url.Parse(srv.URL)
assert.Nil(t, err)
url := &apis.URL{Scheme: "http", Host: fmt.Sprintf("%s:%s", u.Hostname(), u.Port())}
ch.Status.SetAddress(url)
ch.Status.SetAddress(u.Hostname() + ":" + u.Port())

// send a message to the channel
p := "message 1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (s *SubscriptionBuilder) ToKNService(knServiceName string) *SubscriptionBui
// ToURI sets the SubscriptionBuilder Subscriber URI.
func (s *SubscriptionBuilder) ToURI(uri *string) *SubscriptionBuilder {
s.Spec.Subscriber = &eventingv1alpha1.SubscriberSpec{
URI: uri,
DNSName: uri,
}
return s
}
Expand Down Expand Up @@ -92,7 +92,7 @@ func Subscription(name string, namespace string) *SubscriptionBuilder {
Kind: "Service",
APIVersion: "serving.knative.dev/v1alpha1",
},
URI: &emptyString,
DNSName: &emptyString,
},
Reply: &eventingv1alpha1.ReplyStrategy{
Channel: &corev1.ObjectReference{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: apps/v1
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: {{ template "event-publish-service.fullname" . }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: apps/v1
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: {{ template "subscription-controller.fullname" . }}
Expand Down

0 comments on commit 4ae04fa

Please sign in to comment.