knative / eventing

Event-driven application platform for Kubernetes
https://knative.dev/docs/eventing
Apache License 2.0
1.42k stars 595 forks source link

Subscription/Trigger spec doesn't honor namespace in subscriber.ref #4633

Closed antoineco closed 3 years ago

antoineco commented 3 years ago

Describe the bug

When a Subscription or Trigger is created with a spec.subscriber.ref which references an object in a different namespace, it ignores that namespace and defaults to its own.

Expected behavior

The namespace is taken into account when assembling the subscriber URI:

To Reproduce

apiVersion: v1
kind: Namespace
metadata:
  name: my-ns
---
apiVersion: v1
kind: Service
metadata:
  name: my-svc
  namespace: my-ns
spec:
  ports:
  - port: 80
---
apiVersion: eventing.knative.dev/v1
kind: Broker
metadata:
  name: default
  namespace: default
---
apiVersion: messaging.knative.dev/v1
kind: Subscription
metadata:
  name: my-sub
  namespace: default
spec:
  channel:
    apiVersion: messaging.knative.dev/v1
    kind: InMemoryChannel
    name: default-kne-trigger
  subscriber:
    ref:
      apiVersion: v1
      kind: Service
      name: my-svc
      namespace: my-ns
---
apiVersion: eventing.knative.dev/v1
kind: Trigger
metadata:
  name: my-trg
  namespace: default
spec:
  broker: default
  subscriber:
    ref:
      apiVersion: v1
      kind: Service
      name: my-svc
      namespace: my-ns
$ kubectl -n default get subscriptions.messaging.knative.dev my-sub -o yaml
...
spec:
  ...
  subscriber:
    ref:
      apiVersion: v1
      kind: Service
      name: my-svc
      namespace: my-ns
status:
  ...
  physicalSubscription:
    subscriberUri: http://my-svc.default.svc.cluster.local/
$ kubectl -n default get triggers.eventing.knative.dev my-trg -o yaml
...
spec:
  broker: default
  subscriber:
    ref:
      apiVersion: v1
      kind: Service
      name: my-svc
      namespace: my-ns
status:
  ...
  subscriberUri: http://my-svc.default.svc.cluster.local/

Knative release version

Eventing v0.19.2

Additional context

-

lberk commented 3 years ago

This looks similar to #4628 (though specific to channels instead of broker/triggers)

antoineco commented 3 years ago

@lberk Issue confirmed with a Trigger. I updated the issue description, including the repro.

slinkydeveloper commented 3 years ago

Closed as this is duplicated of #4628