diff --git a/config/crds/sources_v1alpha1_containersource.yaml b/config/crds/sources_v1alpha1_containersource.yaml index 256d195be8..74f8b4f8c1 100644 --- a/config/crds/sources_v1alpha1_containersource.yaml +++ b/config/crds/sources_v1alpha1_containersource.yaml @@ -16,6 +16,8 @@ spec: kind: ContainerSource plural: containersources scope: Namespaced + subresources: + status: {} validation: openAPIV3Schema: properties: diff --git a/config/crds/sources_v1alpha1_gcppubsubsource.yaml b/config/crds/sources_v1alpha1_gcppubsubsource.yaml index 067c425537..729299079c 100644 --- a/config/crds/sources_v1alpha1_gcppubsubsource.yaml +++ b/config/crds/sources_v1alpha1_gcppubsubsource.yaml @@ -16,6 +16,8 @@ spec: kind: GcpPubSubSource plural: gcppubsubsources scope: Namespaced + subresources: + status: {} validation: openAPIV3Schema: properties: diff --git a/config/crds/sources_v1alpha1_githubsource.yaml b/config/crds/sources_v1alpha1_githubsource.yaml index 00a370b297..71b7edfc75 100644 --- a/config/crds/sources_v1alpha1_githubsource.yaml +++ b/config/crds/sources_v1alpha1_githubsource.yaml @@ -16,6 +16,8 @@ spec: kind: GitHubSource plural: githubsources scope: Namespaced + subresources: + status: {} validation: openAPIV3Schema: properties: diff --git a/config/crds/sources_v1alpha1_kuberneteseventsource.yaml b/config/crds/sources_v1alpha1_kuberneteseventsource.yaml index 221af060ea..e5be674b29 100644 --- a/config/crds/sources_v1alpha1_kuberneteseventsource.yaml +++ b/config/crds/sources_v1alpha1_kuberneteseventsource.yaml @@ -16,6 +16,8 @@ spec: kind: KubernetesEventSource plural: kuberneteseventsources scope: Namespaced + subresources: + status: {} validation: openAPIV3Schema: properties: diff --git a/config/default-gcppubsub.yaml b/config/default-gcppubsub.yaml index c3f13a7445..f0abfc2737 100644 --- a/config/default-gcppubsub.yaml +++ b/config/default-gcppubsub.yaml @@ -23,6 +23,8 @@ spec: kind: ContainerSource plural: containersources scope: Namespaced + subresources: + status: {} validation: openAPIV3Schema: properties: @@ -100,6 +102,8 @@ spec: kind: GcpPubSubSource plural: gcppubsubsources scope: Namespaced + subresources: + status: {} validation: openAPIV3Schema: properties: @@ -172,6 +176,8 @@ spec: kind: GitHubSource plural: githubsources scope: Namespaced + subresources: + status: {} validation: openAPIV3Schema: properties: @@ -297,6 +303,8 @@ spec: kind: KubernetesEventSource plural: kuberneteseventsources scope: Namespaced + subresources: + status: {} validation: openAPIV3Schema: properties: diff --git a/config/default.yaml b/config/default.yaml index af9448c1c6..5d10d4b304 100644 --- a/config/default.yaml +++ b/config/default.yaml @@ -23,6 +23,8 @@ spec: kind: ContainerSource plural: containersources scope: Namespaced + subresources: + status: {} validation: openAPIV3Schema: properties: @@ -100,6 +102,8 @@ spec: kind: GitHubSource plural: githubsources scope: Namespaced + subresources: + status: {} validation: openAPIV3Schema: properties: @@ -225,6 +229,8 @@ spec: kind: KubernetesEventSource plural: kuberneteseventsources scope: Namespaced + subresources: + status: {} validation: openAPIV3Schema: properties: diff --git a/pkg/apis/sources/v1alpha1/containersource_types.go b/pkg/apis/sources/v1alpha1/containersource_types.go index a04e21e73f..1f98e989e5 100644 --- a/pkg/apis/sources/v1alpha1/containersource_types.go +++ b/pkg/apis/sources/v1alpha1/containersource_types.go @@ -137,6 +137,7 @@ func (s *ContainerSourceStatus) MarkNotDeployed(reason, messageFormat string, me // ContainerSource is the Schema for the containersources API // +k8s:openapi-gen=true +// +kubebuilder:subresource:status // +kubebuilder:categories=all,knative,eventing,sources type ContainerSource struct { metav1.TypeMeta `json:",inline"` diff --git a/pkg/apis/sources/v1alpha1/gcp_pubsub_types.go b/pkg/apis/sources/v1alpha1/gcp_pubsub_types.go index 1a641bd961..b61bd10c5e 100644 --- a/pkg/apis/sources/v1alpha1/gcp_pubsub_types.go +++ b/pkg/apis/sources/v1alpha1/gcp_pubsub_types.go @@ -30,6 +30,7 @@ import ( // GcpPubSubSource is the Schema for the gcppubsubsources API. // +k8s:openapi-gen=true +// +kubebuilder:subresource:status // +kubebuilder:categories=all,knative,eventing,sources type GcpPubSubSource struct { metav1.TypeMeta `json:",inline"` diff --git a/pkg/apis/sources/v1alpha1/githubsource_types.go b/pkg/apis/sources/v1alpha1/githubsource_types.go index 01bc381f97..cc054cf4ac 100644 --- a/pkg/apis/sources/v1alpha1/githubsource_types.go +++ b/pkg/apis/sources/v1alpha1/githubsource_types.go @@ -164,6 +164,7 @@ func (s *GitHubSourceStatus) MarkNoSink(reason, messageFormat string, messageA . // GitHubSource is the Schema for the githubsources API // +k8s:openapi-gen=true +// +kubebuilder:subresource:status // +kubebuilder:categories=all,knative,eventing,sources type GitHubSource struct { metav1.TypeMeta `json:",inline"` diff --git a/pkg/apis/sources/v1alpha1/kuberneteseventsource_types.go b/pkg/apis/sources/v1alpha1/kuberneteseventsource_types.go index 58e272c616..cf93f8e385 100644 --- a/pkg/apis/sources/v1alpha1/kuberneteseventsource_types.go +++ b/pkg/apis/sources/v1alpha1/kuberneteseventsource_types.go @@ -99,6 +99,7 @@ func (s *KubernetesEventSourceStatus) MarkUnready(reason, messageFormat string, // KubernetesEventSource is the Schema for the kuberneteseventsources API // +k8s:openapi-gen=true +// +kubebuilder:subresource:status // +kubebuilder:categories=all,knative,eventing,sources type KubernetesEventSource struct { metav1.TypeMeta `json:",inline"` diff --git a/pkg/controller/kuberneteseventsource/reconcile.go b/pkg/controller/kuberneteseventsource/reconcile.go index 90e76cfbea..351d404018 100644 --- a/pkg/controller/kuberneteseventsource/reconcile.go +++ b/pkg/controller/kuberneteseventsource/reconcile.go @@ -164,11 +164,7 @@ func (r *reconciler) update(ctx context.Context, u *sourcesv1alpha1.KubernetesEv if !equality.Semantic.DeepEqual(current.Status, u.Status) { current.Status = u.Status - // Until #38113 is merged, we must use Update instead of UpdateStatus to - // update the Status block of the Feed resource. UpdateStatus will not - // allow changes to the Spec of the resource, which is ideal for ensuring - // nothing other than resource status has been updated. - return r.Update(ctx, current) + return r.Status().Update(ctx, current) } return nil diff --git a/pkg/controller/sdk/reconciler.go b/pkg/controller/sdk/reconciler.go index eec8ea79d5..45b96e0429 100644 --- a/pkg/controller/sdk/reconciler.go +++ b/pkg/controller/sdk/reconciler.go @@ -174,10 +174,9 @@ func (r *Reconciler) update(ctx context.Context, request reconcile.Request, obje } freshFinalizers.SetFinalizers(orgFinalizers.GetFinalizers()) - // Until #38113 is merged, we must use Update instead of UpdateStatus to - // update the Status block of the Source resource. UpdateStatus will not - // allow changes to the Spec of the resource, which is ideal for ensuring - // nothing other than resource status has been updated. + // We could use the status subresource here, but since there may be an update + // to finalizers also, we have to update the entire object. + //TODO(grantr): use status subresource if finalizers did not change if err := r.client.Update(ctx, freshObj); err != nil { return nil, err }