Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cmd/webhook/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ func main() {
Options: options,
Handlers: map[schema.GroupVersionKind]webhook.GenericCRD{
// For group eventing.knative.dev,
eventingv1alpha1.SchemeGroupVersion.WithKind("Channel"): &eventingv1alpha1.Channel{},
eventingv1alpha1.SchemeGroupVersion.WithKind("ClusterProvisioner"): &eventingv1alpha1.ClusterProvisioner{},
eventingv1alpha1.SchemeGroupVersion.WithKind("Subscription"): &eventingv1alpha1.Subscription{},
eventingv1alpha1.SchemeGroupVersion.WithKind("Channel"): &eventingv1alpha1.Channel{},
eventingv1alpha1.SchemeGroupVersion.WithKind("ClusterChannelProvisioner"): &eventingv1alpha1.ClusterChannelProvisioner{},
eventingv1alpha1.SchemeGroupVersion.WithKind("Subscription"): &eventingv1alpha1.Subscription{},

// For group channels.knative.dev,
channelsv1alpha1.SchemeGroupVersion.WithKind("Bus"): &channelsv1alpha1.Bus{},
Expand Down
8 changes: 4 additions & 4 deletions config/300-clusterprovisioner.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: clusterprovisioners.eventing.knative.dev
name: clusterchannelprovisioners.eventing.knative.dev
spec:
group: eventing.knative.dev
version: v1alpha1
names:
kind: ClusterProvisioner
plural: clusterprovisioners
singular: clusterprovisioner
kind: ClusterChannelProvisioner
plural: clusterchannelprovisioners
singular: clusterchannelprovisioner
categories:
- all
- knative
Expand Down
8 changes: 4 additions & 4 deletions config/provisioners/in-memory-channel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ They differ from most Channels in that they have:
### Deployment steps:

1. Setup [Knative Eventing](../../../DEVELOPMENT.md).
1. Apply the 'in-memory-channel' ClusterProvisioner, Controller, and Dispatcher.
1. Apply the 'in-memory-channel' ClusterChannelProvisioner, Controller, and Dispatcher.
```shell
ko apply -f config/providers/in-memory-channel/in-memory-channel.yaml
````
Expand All @@ -33,19 +33,19 @@ They differ from most Channels in that they have:
provisioner:
ref:
apiVersion: eventing.knative.dev/v1alpha1
kind: ClusterProvisioner
kind: ClusterChannelProvisioner
name: in-memory-channel
```

### Components

The major components are:
* ClusterProvisioner Controller
* ClusterChannelProvisioner Controller
* Channel Controller
* Channel Dispatcher
* Channel Dispatcher Config Map.

The ClusterProvisioner Controller and the Channel Controller are colocated in one Pod.
The ClusterChannelProvisioner Controller and the Channel Controller are colocated in one Pod.
```shell
kubectl get deployment -n knative-eventing in-memory-channel-controller
```
Expand Down
8 changes: 4 additions & 4 deletions config/provisioners/in-memory-channel/in-memory-channel.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

apiVersion: eventing.knative.dev/v1alpha1
kind: ClusterProvisioner
kind: ClusterChannelProvisioner
metadata:
name: in-memory-channel
spec:
Expand All @@ -40,7 +40,7 @@ rules:
- eventing.knative.dev
resources:
- channels
- clusterprovisioners
- clusterchannelprovisioners
verbs:
- get
- list
Expand Down Expand Up @@ -101,7 +101,7 @@ spec:
replicas: 1
selector:
matchLabels: &labels
clusterProvisioner: in-memory-channel
clusterChannelProvisioner: in-memory-channel
role: controller
template:
metadata:
Expand Down Expand Up @@ -164,7 +164,7 @@ spec:
replicas: 1
selector:
matchLabels: &labels
clusterProvisioner: in-memory-channel
clusterChannelProvisioner: in-memory-channel
role: dispatcher
template:
metadata:
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/eventing/logkey/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ package logkey
const (
kNative = "knative.dev/"

// ClusterProvisioner is the key used for cluster provisioner names in structured logs
ClusterProvisioner = kNative + "clusterprovisioner"
// ClusterChannelProvisioner is the key used for cluster provisioner names in structured logs
ClusterChannelProvisioner = kNative + "clusterchannelprovisioner"
)
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ limitations under the License.
package v1alpha1

// SetDefaults defaults
func (p *ClusterProvisioner) SetDefaults() {
func (p *ClusterChannelProvisioner) SetDefaults() {
p.Spec.SetDefaults()
}

// SetDefaults defaults the ClusterProvisioner spec.
func (ps *ClusterProvisionerSpec) SetDefaults() {
// SetDefaults defaults the ClusterChannelProvisioner spec.
func (ps *ClusterChannelProvisionerSpec) SetDefaults() {
// no defaults
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package v1alpha1
import "testing"

// No-op test because method does nothing.
func TestClusterProvisionerSetDefaults(t *testing.T) {
p := ClusterProvisioner{}
func TestClusterChannelProvisionerSetDefaults(t *testing.T) {
p := ClusterChannelProvisioner{}
p.SetDefaults()
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,93 +30,88 @@ import (
// +genclient:nonNamespaced
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// ClusterProvisioner encapsulates a provisioning strategy for the backing
// resources required to realize a particular resource type.
type ClusterProvisioner struct {
// ClusterChannelProvisioner encapsulates a provisioning strategy for the
// backing resources required to realize a particular resource type.
type ClusterChannelProvisioner struct {
metav1.TypeMeta `json:",inline"`
// +optional
metav1.ObjectMeta `json:"metadata,omitempty"`

// Spec defines the Types provisioned by this Provisioner.
Spec ClusterProvisionerSpec `json:"spec"`
Spec ClusterChannelProvisionerSpec `json:"spec"`

// Status is the current status of the Provisioner.
// +optional
Status ClusterProvisionerStatus `json:"status,omitempty"`
Status ClusterChannelProvisionerStatus `json:"status,omitempty"`
}

// Check that ClusterProvisioner can be validated and can be defaulted.
var _ apis.Validatable = (*ClusterProvisioner)(nil)
var _ apis.Defaultable = (*ClusterProvisioner)(nil)
var _ runtime.Object = (*ClusterProvisioner)(nil)
var _ webhook.GenericCRD = (*ClusterProvisioner)(nil)
// Check that ClusterChannelProvisioner can be validated and can be defaulted.
var _ apis.Validatable = (*ClusterChannelProvisioner)(nil)
var _ apis.Defaultable = (*ClusterChannelProvisioner)(nil)
var _ runtime.Object = (*ClusterChannelProvisioner)(nil)
var _ webhook.GenericCRD = (*ClusterChannelProvisioner)(nil)

// ClusterProvisionerSpec is the spec for a ClusterProvisioner resource.
type ClusterProvisionerSpec struct {
// ClusterChannelProvisionerSpec is the spec for a ClusterChannelProvisioner resource.
type ClusterChannelProvisionerSpec struct {
// TODO: Generation does not work correctly with CRD. They are scrubbed
// by the APIserver (https://github.com/kubernetes/kubernetes/issues/58778)
// So, we add Generation here. Once that gets fixed, remove this and use
// ObjectMeta.Generation instead.
// +optional
Generation int64 `json:"generation,omitempty"`

// Reconciles is the kind of the resource the provisioner controller watches to
// produce required backing resources.
// +required
Reconciles metav1.GroupKind `json:"reconciles"`
}

var cProvCondSet = duckv1alpha1.NewLivingConditionSet()
var ccProvCondSet = duckv1alpha1.NewLivingConditionSet()

// ClusterProvisionerStatus is the status for a ClusterProvisioner resource
type ClusterProvisionerStatus struct {
// ClusterChannelProvisionerStatus is the status for a ClusterChannelProvisioner resource
type ClusterChannelProvisionerStatus struct {
// Conditions holds the state of a cluster provisioner at a point in time.
// +optional
// +patchMergeKey=type
// +patchStrategy=merge
Conditions duckv1alpha1.Conditions `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"`

// ObservedGeneration is the 'Generation' of the ClusterProvisioner that
// ObservedGeneration is the 'Generation' of the ClusterChannelProvisioner that
// was last reconciled by the controller.
// +optional
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
}

const (
// ClusterProvisionerConditionReady has status True when the Controller reconciling objects
// ClusterChannelProvisionerConditionReady has status True when the Controller reconciling objects
// controlled by it is ready to control them.
ClusterProvisionerConditionReady = duckv1alpha1.ConditionReady
ClusterChannelProvisionerConditionReady = duckv1alpha1.ConditionReady
)

// GetCondition returns the condition currently associated with the given type, or nil.
func (ps *ClusterProvisionerStatus) GetCondition(t duckv1alpha1.ConditionType) *duckv1alpha1.Condition {
return cProvCondSet.Manage(ps).GetCondition(t)
func (ps *ClusterChannelProvisionerStatus) GetCondition(t duckv1alpha1.ConditionType) *duckv1alpha1.Condition {
return ccProvCondSet.Manage(ps).GetCondition(t)
}

// IsReady returns true if the resource is ready overall.
func (ps *ClusterProvisionerStatus) IsReady() bool {
return cProvCondSet.Manage(ps).IsHappy()
func (ps *ClusterChannelProvisionerStatus) IsReady() bool {
return ccProvCondSet.Manage(ps).IsHappy()
}

// InitializeConditions sets relevant unset conditions to Unknown state.
func (ps *ClusterProvisionerStatus) InitializeConditions() {
cProvCondSet.Manage(ps).InitializeConditions()
func (ps *ClusterChannelProvisionerStatus) InitializeConditions() {
ccProvCondSet.Manage(ps).InitializeConditions()
}

// MarkReady marks this ClusterProvisioner as Ready=true.
// MarkReady marks this ClusterChannelProvisioner as Ready=true.
//
// Note that this is not the normal pattern for duck conditions, but because there is (currently)
// no other condition on ClusterProvisioners, the normal IsReady() logic doesn't work well.
func (ps *ClusterProvisionerStatus) MarkReady() {
cProvCondSet.Manage(ps).MarkTrue(ClusterProvisionerConditionReady)
// no other condition on ClusterChannelProvisioners, the normal IsReady() logic doesn't work well.
func (ps *ClusterChannelProvisionerStatus) MarkReady() {
ccProvCondSet.Manage(ps).MarkTrue(ClusterChannelProvisionerConditionReady)
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// ClusterProvisionerList is a list of ClusterProvisioner resources
type ClusterProvisionerList struct {
// ClusterChannelProvisionerList is a list of ClusterChannelProvisioner resources
type ClusterChannelProvisionerList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`

Items []ClusterProvisioner `json:"items"`
Items []ClusterChannelProvisioner `json:"items"`
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,26 @@ import (
corev1 "k8s.io/api/core/v1"
)

func TestClusterProvisionerStatusIsReady(t *testing.T) {
func TestClusterChannelProvisionerStatusIsReady(t *testing.T) {
tests := []struct {
name string
ps *ClusterProvisionerStatus
ps *ClusterChannelProvisionerStatus
want bool
}{{
name: "uninitialized",
ps: &ClusterProvisionerStatus{},
ps: &ClusterChannelProvisionerStatus{},
want: false,
}, {
name: "initialized",
ps: func() *ClusterProvisionerStatus {
ps := &ClusterProvisionerStatus{}
ps: func() *ClusterChannelProvisionerStatus {
ps := &ClusterChannelProvisionerStatus{}
ps.InitializeConditions()
return ps
}(),
want: false,
}, {
name: "ready true condition",
ps: &ClusterProvisionerStatus{
ps: &ClusterChannelProvisionerStatus{
Conditions: []duckv1alpha1.Condition{{
Type: ChannelConditionReady,
Status: corev1.ConditionTrue,
Expand All @@ -52,7 +52,7 @@ func TestClusterProvisionerStatusIsReady(t *testing.T) {
want: true,
}, {
name: "ready false condition",
ps: &ClusterProvisionerStatus{
ps: &ClusterChannelProvisionerStatus{
Conditions: []duckv1alpha1.Condition{{
Type: ChannelConditionReady,
Status: corev1.ConditionFalse,
Expand All @@ -61,7 +61,7 @@ func TestClusterProvisionerStatusIsReady(t *testing.T) {
want: false,
}, {
name: "unknown condition",
ps: &ClusterProvisionerStatus{
ps: &ClusterChannelProvisionerStatus{
Conditions: []duckv1alpha1.Condition{{
Type: "foo",
Status: corev1.ConditionTrue,
Expand All @@ -80,15 +80,15 @@ func TestClusterProvisionerStatusIsReady(t *testing.T) {
}
}

func TestClusterProvisionerStatusGetCondition(t *testing.T) {
func TestClusterChannelProvisionerStatusGetCondition(t *testing.T) {
tests := []struct {
name string
ps *ClusterProvisionerStatus
ps *ClusterChannelProvisionerStatus
condQuery duckv1alpha1.ConditionType
want *duckv1alpha1.Condition
}{{
name: "single condition",
ps: &ClusterProvisionerStatus{
ps: &ClusterChannelProvisionerStatus{
Conditions: []duckv1alpha1.Condition{
condReady,
},
Expand All @@ -97,7 +97,7 @@ func TestClusterProvisionerStatusGetCondition(t *testing.T) {
want: &condReady,
}, {
name: "unknown condition",
ps: &ClusterProvisionerStatus{
ps: &ClusterChannelProvisionerStatus{
Conditions: []duckv1alpha1.Condition{
condReady,
condUnprovisioned,
Expand All @@ -117,8 +117,8 @@ func TestClusterProvisionerStatusGetCondition(t *testing.T) {
}
}

func TestClusterProvisionerStatus_MarkReady(t *testing.T) {
ps := ClusterProvisionerStatus{}
func TestClusterChannelProvisionerStatus_MarkReady(t *testing.T) {
ps := ClusterChannelProvisionerStatus{}
ps.InitializeConditions()
if ps.IsReady() {
t.Errorf("Should not be ready when initialized.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,16 @@ package v1alpha1

import (
"github.com/knative/pkg/apis"
"k8s.io/apimachinery/pkg/api/equality"
)

// Validate validates the ClusterProvisioner resource.
func (p *ClusterProvisioner) Validate() *apis.FieldError {
// Validate validates the ClusterChannelProvisioner resource.
func (p *ClusterChannelProvisioner) Validate() *apis.FieldError {
return p.Spec.Validate().ViaField("spec")
}

// Validate validates the ClusterProvisioner spec
func (ps *ClusterProvisionerSpec) Validate() *apis.FieldError {
if equality.Semantic.DeepEqual(ps, &ClusterProvisionerSpec{}) {
return apis.ErrMissingField("reconciles")
}
// Validate validates the ClusterChannelProvisioner spec
func (ps *ClusterChannelProvisionerSpec) Validate() *apis.FieldError {
var errs *apis.FieldError
if ps.Reconciles.Kind == "" {
errs = errs.Also(apis.ErrMissingField("kind").ViaField("reconciles"))
}
if ps.Reconciles.Group == "" {
errs = errs.Also(apis.ErrMissingField("group").ViaField("reconciles"))
}

return errs
}
Loading