Skip to content

Default Channel support for Channel CRDs#1560

Merged
knative-prow-robot merged 38 commits into
knative:masterfrom
nachocano:default-channel
Jul 25, 2019
Merged

Default Channel support for Channel CRDs#1560
knative-prow-robot merged 38 commits into
knative:masterfrom
nachocano:default-channel

Conversation

@nachocano
Copy link
Copy Markdown
Contributor

@nachocano nachocano commented Jul 24, 2019

Helps with #1343
A separate documentation PR plus defaulting Sequence's channels should fix it.

Proposed Changes

  • Introducing a new ConfigMap with cluster and namespace defaults for being able to set default Channel CRDs. This is similar to the current defaulting behavior for Channel provisioners.
  • Created a new Channel type, within messaging.knative.dev API group, that proxies an underlying Channel CRD implementation, as per @Harwayne's design. If a user just wants a Channel without caring about the actual implementation, she will create such object and some ConfigMap defaults will be used to determine the underlying implementation (e.g., InMemoryChannel, KafkaChannel, etc).
  • The underlying impl is set in the admission mutating webhook in channel.spec.channelTemplate, in case such value hasn't been set, which we assume will be the typical case. In other words, if the user knows she wants an InMemoryChannel, she will directly instantiate it, instead of through this proxy Channel object.
  • Setting defaults to Broker in the webhook to populate broker.spec.channelTemplateSpec if it hasn't been set, in order to enable default channel CRDs when using the namespace injection.
  • There were some not so nice renamings due to naming clashes, but all should be back to normal once we remove the old Channel provisioners stuff.

Release Note

A new Channel object in messaging.knative.dev API group has been introduced to be used in case you want a Channel but are not interested in its actual implementation (e.g., whether it is an InMemoryChannel, KafkaChannel, NatssChannel, etc.). Such implementation will be determined using a new Channel CRD defaulter, which can be configured in the newly introduced ConfigMap `default-ch-webhook`, mimicking the soon to be deprecated `default-channel-webhook`. Furthermore, Brokers injected with the namespace eventing annotation now leverage this new Channel CRD defaulter mechanism, to be able to configure their underlying channels implementations.
Note that the old Channel in eventing.knative.dev that uses the Provisioner model will be deprecated in 0.9, so we recommend moving to CRDs asap.

@vaikas
Copy link
Copy Markdown
Contributor

vaikas commented Jul 25, 2019

Just a quick question, regarding the proposed changes:
Last but not least, changing the ConfigMap at runtime won't have an impact on existing Channels nor Brokers that have been created with this default mechanism, as we have already set their channelTemplate to certain value. Example, if we change the ConfigMap from InMemoryChannel to KafkaChannel, and remove a Broker injected through a namespace annotation that used the previous ConfigMap configuration, such Broker will be recreated with the previous InMemoryChannel default, instead of KafkaChannel.

I find this interesting. I would expect no changes to existing channels or brokers, but what you seem to describe in your example. Changing the configmap, then deleting a broker I find interesting. I think I would expect the behaviour to be that if you change the configmap, then recreate the broker, the new defaults would be applied.

@nachocano
Copy link
Copy Markdown
Contributor Author

I find this interesting. I would expect no changes to existing channels or brokers, but what you seem to describe in your example. Changing the configmap, then deleting a broker I find interesting. I think I would expect the behaviour to be that if you change the configmap, then recreate the broker, the new defaults would be applied.

Good catch. My previous impl did that, not the current one. If you change the defaults and delete a broker, it will get re-created with the new config. Sorry for the confusion. Let me remove that from the PR description...

Copy link
Copy Markdown
Contributor

@vaikas vaikas left a comment

Choose a reason for hiding this comment

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

Awesome sauce, thanks for doing this, will definitely help with usability. Just a couple of minor things, mainly around documentation, tracking bugs, etc.

Comment thread config/300-channel-eventing.yaml Outdated
Comment thread config/300-channel-eventing.yaml
Comment thread config/400-default-ch-config.yaml
Comment thread pkg/apis/duck/v1alpha1/channel_defaulter.go
Comment thread config/400-default-ch-config.yaml
Comment thread pkg/apis/messaging/v1alpha1/channel_defaults_test.go Outdated
Comment thread pkg/apis/duck/v1alpha1/channel_template_types.go
@vaikas
Copy link
Copy Markdown
Contributor

vaikas commented Jul 25, 2019

Looks like the channel_types.go not having any test coverage is causing the test failure?

Comment thread config/300-channel.yaml Outdated
Comment thread config/400-default-ch-config.yaml Outdated
Comment thread config/400-default-ch-config.yaml Outdated
Comment thread pkg/apis/duck/v1alpha1/channel_template_types.go Outdated
Comment thread pkg/apis/duck/v1alpha1/channel_template_types.go
Comment thread pkg/apis/messaging/v1alpha1/channel_defaults_test.go Outdated
cs.Address = &v1alpha1.Addressable{}
}
if address != nil && address.URL != nil {
cs.Address.Hostname = address.URL.Host
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.

This looks dangerous. We can only set Hostname if nothing in the URL is needed (i.e. path, query string, etc. are both empty).

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.

copy/paste from Matt's changes when he migrated to the new Addressable. We are doing this all over...
You'd rather not set anything in the hostname? I'm more inclined to leave it as is, and maybe then revisit how we are doing it everywhere...

Comment thread pkg/apis/messaging/v1alpha1/channel_types.go Outdated
Comment thread pkg/apis/messaging/v1alpha1/channel_types.go
Comment thread pkg/apis/messaging/v1alpha1/channel_validation.go
@lionelvillard
Copy link
Copy Markdown
Contributor

code coverage must be at least 50% for each file to pass the test.

Comment thread pkg/defaultchannel/channel_defaulter.go Outdated
Comment thread pkg/reconciler/channel/channel.go Outdated
Comment thread pkg/reconciler/channel/channel.go Outdated
Comment thread pkg/reconciler/channel/channel.go Outdated
Comment thread pkg/reconciler/channel/channel.go Outdated
Comment thread pkg/reconciler/channel/channel.go Outdated
Comment thread pkg/reconciler/channel/channel.go Outdated
Comment thread pkg/reconciler/channel/channel.go Outdated
Comment thread pkg/reconciler/channel/channel.go Outdated
Comment thread pkg/reconciler/channel/channel.go Outdated
@nachocano
Copy link
Copy Markdown
Contributor Author

Looks like the channel_types.go not having any test coverage is causing the test failure?

Added it, and a couple others. Let's see now.

@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/messaging/v1alpha1/channel_defaults.go Do not exist 100.0%
pkg/apis/messaging/v1alpha1/channel_lifecycle.go Do not exist 100.0%
pkg/apis/messaging/v1alpha1/channel_types.go Do not exist 100.0%
pkg/apis/messaging/v1alpha1/channel_validation.go Do not exist 93.3%
pkg/apis/messaging/v1alpha1/in_memory_channel_types.go 0.0% 100.0% 100.0
pkg/apis/messaging/v1alpha1/sequence_types.go 0.0% 100.0% 100.0
pkg/defaultchannel/channel_defaulter.go Do not exist 91.7%
pkg/reconciler/channel/channel.go 83.3% 81.9% -1.4
pkg/reconciler/eventingchannel/channel.go Do not exist 83.3%
pkg/reconciler/eventingchannel/controller.go Do not exist 100.0%

@nachocano
Copy link
Copy Markdown
Contributor Author

code coverage must be at least 50% for each file to pass the test.

Thanks @lionelvillard, wasn't aware of that!

@vaikas
Copy link
Copy Markdown
Contributor

vaikas commented Jul 25, 2019

/approve
Leaving lgtm to @Harwayne since there were some comments.

@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 Jul 25, 2019
@nachocano
Copy link
Copy Markdown
Contributor Author

fyi initial documentation in this PR

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.

/lgtm

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. area/test-and-release Test infrastructure, tests or release 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