Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Defaulting for Channel should resolve the namespace from context, not the resource #4514

Open
aliok opened this issue Nov 12, 2020 · 14 comments
Assignees
Labels
area/channels kind/bug Categorizes issue or PR as related to a bug. kind/good-first-issue Denotes an issue ready for a new contributor. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. triage/accepted Issues which should be fixed (post-triage)
Milestone

Comments

@aliok
Copy link
Member

aliok commented Nov 12, 2020

Describe the bug
When I use Kube REST api in the way kn uses it, I can see behavior differences when I post these 2:

  • {"kind":"Channel","apiVersion":"messaging.knative.dev/v1beta1","metadata":{"name":"my-channel"}}
  • {"kind":"Channel","apiVersion":"messaging.knative.dev/v1beta1","metadata":{"name":"my-channel", "namespace":"knativetutorial"}}

URL posted is same: apis/messaging.knative.dev/v1beta1/namespaces/knativetutorial/channels

This problem makes eventing webhook pick the wrong default channel for namespace.

See following.

Make IMC cluster default and KafkaChannel knativetutorial namespace default:

$ cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: ConfigMap
metadata:
  name: default-ch-webhook
  namespace: knative-eventing
data:
  default-ch-config: |
    clusterDefault:
      apiVersion: messaging.knative.dev/v1beta1
      kind: InMemoryChannel
    namespaceDefaults:
      knativetutorial:
        apiVersion: messaging.knative.dev/v1alpha1
        kind: KafkaChannel
        spec:
          numPartitions: 2
          replicationFactor: 1
EOF

Start proxy:

$ kubectl proxy --port=8080 &

Post 2 channel requests to the same namespace URL; 1 with namespace in metadata, other not:

$ curl -XPOST  \
    -d '{"kind":"Channel","apiVersion":"messaging.knative.dev/v1beta1","metadata":{"name":"my-channel-1", "namespace":"knativetutorial"}}' \
    -H "Content-Type: application/json" \
    'http://localhost:8080/apis/messaging.knative.dev/v1beta1/namespaces/knativetutorial/channels'

$ curl -XPOST  \
    -d '{"kind":"Channel","apiVersion":"messaging.knative.dev/v1beta1","metadata":{"name":"my-channel-2"}}' \
    -H "Content-Type: application/json" \
    'http://localhost:8080/apis/messaging.knative.dev/v1beta1/namespaces/knativetutorial/channels'

First channel is created with KafkaChannel, the 2nd created with IMC.

$ k get channels -A
NAMESPACE         NAME           URL                                                                AGE   READY   REASON
knativetutorial   my-channel-1   http://my-channel-1-kn-channel.knativetutorial.svc.cluster.local   6s    True    
knativetutorial   my-channel-2   http://my-channel-2-kn-channel.knativetutorial.svc.cluster.local   5s    True    

$ k get kafkachannels -A
NAMESPACE         NAME           READY   REASON   URL                                                                AGE
knativetutorial   my-channel-1   True             http://my-channel-1-kn-channel.knativetutorial.svc.cluster.local   15s

$ k get imc -A
NAMESPACE         NAME           URL                                                                AGE   READY   REASON
knativetutorial   my-channel-2   http://my-channel-2-kn-channel.knativetutorial.svc.cluster.local   11s   True    

Expected behavior
Defaulting to use the context namespace.

To Reproduce
Steps are above.

Knative release version
0.17, 0.18, 0.19

Additional context
Add any other context about the problem here such as proposed priority

@aliok aliok added the kind/bug Categorizes issue or PR as related to a bug. label Nov 12, 2020
@aliok
Copy link
Member Author

aliok commented Nov 12, 2020

This doesn't happen when you apply YAML with kubectl since kubectl embeds the namespace in the request body.

@navidshaikh
Copy link
Contributor

This doesn't happen when you apply YAML with kubectl since kubectl embeds the namespace in the request body.

kn could carry this as workaround for now, it'll embed the namespace in the request body.

@aliok
Copy link
Member Author

aliok commented Nov 12, 2020

sounds good!

@aliok
Copy link
Member Author

aliok commented Nov 12, 2020

so,

  • this problem doesn't happen with kubectl
  • kn is adding a workaround, that should also be fine
  • all the other usecases where people are creating Channels programmatically with namespace defaults: just embed the namespace in the request as a workaround

navidshaikh added a commit to navidshaikh/client that referenced this issue Nov 12, 2020
 since on the eventing side, defaulting for channel isnt picking
 the namespace from the context (see knative/eventing#4514)

 workaround for knative#1100
 this changeset should be reverted when eventing#4514 is resolved
knative-prow-robot pushed a commit to knative/client that referenced this issue Nov 12, 2020
* Embed the namespace in request body while creating channels

 since on the eventing side, defaulting for channel isnt picking
 the namespace from the context (see knative/eventing#4514)

 workaround for #1100
 this changeset should be reverted when eventing#4514 is resolved

* Add CHANGELOG
@grantr grantr added priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. area/channels kind/good-first-issue Denotes an issue ready for a new contributor. labels Nov 16, 2020
@grantr grantr added this to the Backlog milestone Nov 16, 2020
@grantr
Copy link
Contributor

grantr commented Nov 16, 2020

This might also affect broker class defaulting by namespace (if we even have that feature, I can't remember)

navidshaikh added a commit to navidshaikh/client that referenced this issue Nov 23, 2020
…1117)

* Embed the namespace in request body while creating channels

 since on the eventing side, defaulting for channel isnt picking
 the namespace from the context (see knative/eventing#4514)

 workaround for knative#1100
 this changeset should be reverted when eventing#4514 is resolved

* Add CHANGELOG
navidshaikh added a commit to navidshaikh/client that referenced this issue Nov 24, 2020
…1117)

* Embed the namespace in request body while creating channels

 since on the eventing side, defaulting for channel isnt picking
 the namespace from the context (see knative/eventing#4514)

 workaround for knative#1100
 this changeset should be reverted when eventing#4514 is resolved

* Add CHANGELOG
knative-prow-robot pushed a commit to knative/client that referenced this issue Nov 24, 2020
* Embed the namespace in request body while creating channels (#1117)

* Embed the namespace in request body while creating channels

 since on the eventing side, defaulting for channel isnt picking
 the namespace from the context (see knative/eventing#4514)

 workaround for #1100
 this changeset should be reverted when eventing#4514 is resolved

* Add CHANGELOG

* Update changelog for v0.18.3
knative-prow-robot pushed a commit to knative/client that referenced this issue Nov 24, 2020
* Embed the namespace in request body while creating channels (#1117)

* Embed the namespace in request body while creating channels

 since on the eventing side, defaulting for channel isnt picking
 the namespace from the context (see knative/eventing#4514)

 workaround for #1100
 this changeset should be reverted when eventing#4514 is resolved

* Add CHANGELOG

* Update CHANGELOG for v0.17.4
navidshaikh added a commit to navidshaikh/client that referenced this issue Nov 24, 2020
…1117)

* Embed the namespace in request body while creating channels

 since on the eventing side, defaulting for channel isnt picking
 the namespace from the context (see knative/eventing#4514)

 workaround for knative#1100
 this changeset should be reverted when eventing#4514 is resolved

* Add CHANGELOG
knative-prow-robot pushed a commit to knative/client that referenced this issue Nov 25, 2020
* Embed the namespace in request body while creating channels (#1117)

* Embed the namespace in request body while creating channels

 since on the eventing side, defaulting for channel isnt picking
 the namespace from the context (see knative/eventing#4514)

 workaround for #1100
 this changeset should be reverted when eventing#4514 is resolved

* Add CHANGELOG

* Update CHANGELOG for v0.19.1

* Cross-compile the kn binary for linux/s390x (#1083)

* Update CHANGELOG for v0.19.1

* Fix date in changelog

* Fix race conditions when creating watches (#1113)

* Fix a race condition between creating a watch and initiating the action that emits the event it is watching for

* update changelog

* add PR ID to changelog entry

* Fix merge in Changelog

* Fix table format in Changelog
@slinkydeveloper
Copy link
Contributor

Since the kn workaround seems like was merged, can we close this one @aliok ?

@aliok
Copy link
Member Author

aliok commented Feb 15, 2021

Let's keep this open since this is a good-first-issue? At least until the bot marks it stale?

@github-actions
Copy link

This issue is stale because it has been open for 90 days with no
activity. It will automatically close after 30 more days of
inactivity. Reopen the issue with /reopen. Mark the issue as
fresh by adding the comment /remove-lifecycle stale.

@github-actions github-actions bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label May 17, 2021
@aliok
Copy link
Member Author

aliok commented May 24, 2021

/remove-lifecycle stale

@knative-prow-robot knative-prow-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label May 24, 2021
@rhuss
Copy link
Contributor

rhuss commented Jul 5, 2021

Since the kn workaround seems like was merged, can we close this one @aliok ?

I still think that the issue described here is more than just helping kn to run the e2e tests and is a general issue with other clients as well that do not add the namespace to the request (which IMO is totally legit)

@github-actions
Copy link

github-actions bot commented Oct 7, 2021

This issue is stale because it has been open for 90 days with no
activity. It will automatically close after 30 more days of
inactivity. Reopen the issue with /reopen. Mark the issue as
fresh by adding the comment /remove-lifecycle stale.

@github-actions github-actions bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Oct 7, 2021
@pierDipi pierDipi added triage/accepted Issues which should be fixed (post-triage) and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Oct 7, 2021
@rhuss
Copy link
Contributor

rhuss commented Oct 11, 2021

/remove-lifecycle stale

@gab-satchi
Copy link
Contributor

/assign

@vishal-chdhry
Copy link
Member

/assign

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/channels kind/bug Categorizes issue or PR as related to a bug. kind/good-first-issue Denotes an issue ready for a new contributor. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. triage/accepted Issues which should be fixed (post-triage)
Projects
None yet
Development

No branches or pull requests

9 participants