Skip to content

Allow valid object references for Subscription's channel#1283

Merged
knative-prow-robot merged 22 commits into
knative:masterfrom
nachocano:subscription-channel
May 29, 2019
Merged

Allow valid object references for Subscription's channel#1283
knative-prow-robot merged 22 commits into
knative:masterfrom
nachocano:subscription-channel

Conversation

@nachocano
Copy link
Copy Markdown
Contributor

@nachocano nachocano commented May 28, 2019

Fixes #1283
Helps with #1216

Proposed Changes

  • Allow to create subscriptions where their spec.channel does not just allow the Channel kind (^Channel$), but also other kind of channels. Similarly with spec.reply.channel. Also removed the check for apiVersion equals to eventing.knative.dev/v1alpha1.
  • This is needed for the different channels CRDs. E.g., InMemoryChannel, KafkaChannel, NATSSChannel, etc.
  • We just validate the channel configured is a valid object reference in the webhook, and perform more checks in the subscription controller. There, we check whether the channel CRD has the messaging.knative.dev/subscribable label set to true. If no, then we return an error.
  • If this is approved, we should add the label to the Channel spec.

Release Note

Subscriptions can now have different Channel kinds as part of their spec.channel. E.g., "InMemoryChannel", "KafkaChannel", etc.

@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label May 28, 2019
@knative-prow-robot knative-prow-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label May 28, 2019
@nachocano
Copy link
Copy Markdown
Contributor Author

/assign @Harwayne @vaikas-google @grantr

Comment thread pkg/apis/eventing/v1alpha1/subscription_types.go
Copy link
Copy Markdown
Contributor

@Harwayne Harwayne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if the spec.channel is not a subscribable? For example, a ClusterRole. What error is seen by the user?

@nachocano
Copy link
Copy Markdown
Contributor Author

What happens if the spec.channel is not a subscribable? For example, a ClusterRole. What error is seen by the user?

Current version does not shown an error. I was planning on doing it in a follow up PR, but I think I should do it here before this is merged. As we cannot check for Subscribable, I'll add the label check with the CRD informer/lister in the controller, instead of the webhook. If you guys have a strong opinion of doing it in the webhook, please do let me know.
Marking this as WIP to avoid any preliminary merge

@nachocano nachocano changed the title Allow valid object references for Subscription's channel [WIP] Allow valid object references for Subscription's channel May 28, 2019
@knative-prow-robot knative-prow-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 28, 2019
@knative-metrics-robot
Copy link
Copy Markdown

The following is the coverage report on pkg/.
Say /test pull-knative-eventing-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/eventing/v1alpha1/subscription_validation.go 100.0% 96.6% -3.4
pkg/reconciler/subscription/subscription.go Do not exist 78.5%

@Harwayne
Copy link
Copy Markdown
Contributor

What happens if the spec.channel is not a subscribable? For example, a ClusterRole. What error is seen by the user?

Current version does not shown an error. I was planning on doing it in a follow up PR, but I think I should do it here before this is merged. As we cannot check for Subscribable, I'll add the label check with the CRD informer/lister in the controller, instead of the webhook. If you guys have a strong opinion of doing it in the webhook, please do let me know.
Marking this as WIP to avoid any preliminary merge

The easier thing may be to add a status condition, and mark it as failing if r.syncPhysicalChannel returns an error. I think this will be necessary in the long run, whereas the CRD with a label is a nice-to-have.

@nachocano
Copy link
Copy Markdown
Contributor Author

The easier thing may be to add a status condition, and mark it as failing if r.syncPhysicalChannel returns an error. I think this will be necessary in the long run, whereas the CRD with a label is a nice-to-have.

The code already does that. See here. I think I added those in a previous PR.
It seems that r.syncPhysicalChannel is not returning an error in this case. Will debug it further.

@knative-metrics-robot
Copy link
Copy Markdown

The following is the coverage report on pkg/.
Say /test pull-knative-eventing-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/eventing/v1alpha1/subscription_validation.go 100.0% 96.6% -3.4
pkg/reconciler/subscription/subscription.go Do not exist 78.5%

@knative-metrics-robot
Copy link
Copy Markdown

The following is the coverage report on pkg/.
Say /test pull-knative-eventing-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/eventing/v1alpha1/subscription_validation.go 100.0% 96.6% -3.4
pkg/reconciler/reconciler.go Do not exist 3.6%
pkg/reconciler/subscription/subscription.go Do not exist 74.7%

@knative-metrics-robot
Copy link
Copy Markdown

The following is the coverage report on pkg/.
Say /test pull-knative-eventing-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/eventing/v1alpha1/subscription_validation.go 100.0% 96.6% -3.4
pkg/reconciler/reconciler.go Do not exist 3.6%
pkg/reconciler/subscription/subscription.go Do not exist 74.7%

@knative-metrics-robot
Copy link
Copy Markdown

The following is the coverage report on pkg/.
Say /test pull-knative-eventing-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/eventing/v1alpha1/subscription_validation.go 100.0% 96.6% -3.4
pkg/reconciler/reconciler.go Do not exist 3.6%
pkg/reconciler/subscription/subscription.go Do not exist 74.3%

@knative-metrics-robot
Copy link
Copy Markdown

The following is the coverage report on pkg/.
Say /test pull-knative-eventing-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/eventing/v1alpha1/subscription_validation.go 100.0% 96.6% -3.4
pkg/reconciler/reconciler.go Do not exist 3.6%
pkg/reconciler/subscription/subscription.go Do not exist 79.7%

@nachocano nachocano changed the title [WIP] Allow valid object references for Subscription's channel Allow valid object references for Subscription's channel May 29, 2019
@knative-prow-robot knative-prow-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 29, 2019
@nachocano
Copy link
Copy Markdown
Contributor Author

@vaikas-google @Harwayne ready for a second pass.

@knative-metrics-robot
Copy link
Copy Markdown

The following is the coverage report on pkg/.
Say /test pull-knative-eventing-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/eventing/v1alpha1/subscription_validation.go 100.0% 96.6% -3.4
pkg/reconciler/reconciler.go Do not exist 3.6%
pkg/reconciler/subscription/subscription.go Do not exist 79.8%

Subscribers []ChannelSubscriberSpec `json:"subscribers,omitempty" patchStrategy:"merge" patchMergeKey:"uid"`
}

// Subscribable is an Implementable "duck type".
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should create a new Duck Type that looks something like this:

type Channelable struct {
metav1.TypeMeta ...
metav1.ObjectMeta ...
Spec ChannelSpec ...
Status Addressable ...

}

So that we have one Duck type that allows us to create Subscriptions to it as well get the Addressable part, since a Channel is both so rather than muck with addressable and subscribable, we have a proper Channelable type that handles spec / status. I think Addressable might not be enough, since we might also need some kind of Subscriptions statuses wired through. If you think this is reasonable, let's create an issue to track this, unless we think this change might be useful to do now.
@Harwayne @n3wscott

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree we need this to make things cleaner.
IMO we can track it and do it in a follow up, but waiting to hear thoughts from the guys...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fine with an issue, we need to relax this constraint to be able to use new channels, please generate an issue to track this work and I'm good.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@knative-metrics-robot
Copy link
Copy Markdown

The following is the coverage report on pkg/.
Say /test pull-knative-eventing-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/eventing/v1alpha1/subscription_validation.go 100.0% 96.6% -3.4
pkg/reconciler/reconciler.go Do not exist 3.6%
pkg/reconciler/subscription/subscription.go Do not exist 79.8%

@vaikas
Copy link
Copy Markdown
Contributor

vaikas commented May 29, 2019

/lgtm
/approve

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label May 29, 2019
@knative-prow-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: nachocano, vaikas-google

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 29, 2019
@knative-prow-robot knative-prow-robot merged commit 06e0227 into knative:master May 29, 2019
matzew added a commit to matzew/eventing that referenced this pull request Jun 4, 2021
Co-authored-by: Markus Thömmes <markusthoemmes@me.com>
matzew added a commit to matzew/eventing that referenced this pull request Sep 3, 2021
Co-authored-by: Markus Thömmes <markusthoemmes@me.com>
devguyio pushed a commit to devguyio/eventing that referenced this pull request Sep 3, 2021
* Rollback certificate algorithm changes (knative#1281) (knative#1283)

Co-authored-by: Markus Thömmes <markusthoemmes@me.com>

* mute noisy metrics

* [SRVKS-790] Patch subresource to unblock webhooks on 4.9 (knative#1361)

Co-authored-by: Markus Thömmes <markusthoemmes@me.com>
Co-authored-by: Stavros Kontopoulos <skontopo@redhat.com>
devguyio added a commit to devguyio/eventing that referenced this pull request Sep 17, 2021
* add patch of missing versions

Signed-off-by: Ahmed Abdalla <aabdelre@redhat.com>

* Patch 0.23 with missing API versions

Signed-off-by: Ahmed Abdalla <aabdelre@redhat.com>

* remove the patch, it's not needed in other versions

Signed-off-by: Ahmed Abdalla <aabdelre@redhat.com>

* Using pre-built image from OCP registry (#2)

Signed-off-by: Matthias Wessendorf <mwessend@redhat.com>

* Apply ko publish patch to here ... (#3)

Signed-off-by: Matthias Wessendorf <mwessend@redhat.com>

* One more thing.... (#4)

Signed-off-by: Matthias Wessendorf <mwessend@redhat.com>

* Add logs to understand rekt progress

Signed-off-by: Ahmed Abdalla <aabdelre@redhat.com>

* Adding back vendor patches (#5)

* Rollback certificate algorithm changes (knative#1281) (knative#1283)

Co-authored-by: Markus Thömmes <markusthoemmes@me.com>

* mute noisy metrics

* [SRVKS-790] Patch subresource to unblock webhooks on 4.9 (knative#1361)

Co-authored-by: Markus Thömmes <markusthoemmes@me.com>
Co-authored-by: Stavros Kontopoulos <skontopo@redhat.com>

Co-authored-by: Matthias Wessendorf <mwessend@redhat.com>
Co-authored-by: Markus Thömmes <markusthoemmes@me.com>
Co-authored-by: Stavros Kontopoulos <skontopo@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cla: yes Indicates the PR's author has signed the CLA. lgtm Indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants