eventing icon indicating copy to clipboard operation
eventing copied to clipboard

ApiServerSource spec.namespaces field bug

Open ElGaleon opened this issue 4 months ago • 3 comments

Expected behavior

Based on this example, this step would not come to an error.

Describe the bug

I'm trying to create an ApiServerSource for my Knative project. Following the guide Create An ApiServerSource Object, in the last step I'm facing a warning related to spec.namespaceSelector. See the following code blocks.

# api-server-source.yml
apiVersion: sources.knative.dev/v1
kind: ApiServerSource
metadata:
 name: api-server-source
 namespace: api-server-source-example
spec:
 serviceAccountName: api-server-source-sa
 mode: Resource
 resources:
   - apiVersion: v1
     kind: Event
 namespaceSelector: {}
 sink:
   ref:
     apiVersion: v1
     kind: Broker
     name: broker-sink
$ kubectl describe apiserversource api-server-source -n api-server-source-example
Name:         api-server-source
Namespace:    api-server-source-example
Labels:       <none>
Annotations:  sources.knative.dev/creator: system:admin
              sources.knative.dev/lastModifier: system:admin
API Version:  sources.knative.dev/v1
Kind:         ApiServerSource
Metadata:
  Creation Timestamp:  2025-08-20T08:54:17Z
  Finalizers:
    apiserversources.sources.knative.dev
  Generation:        1
  Resource Version:  986689
  UID:               6d90c81a-cd2c-4906-9af6-2de8d834b415
Spec:
  Mode:  Resource
  Namespace Selector:
  Resources:
    API Version:         v1
    Kind:                Event
  Service Account Name:  api-server-source-sa
  Sink:
    Ref:
      API Version:  v1
      Kind:         Broker
      Name:         broker-sink
Events:
  Type     Reason           Age               From                        Message
  ----     ------           ----              ----                        -------
  Normal   FinalizerUpdate  4s                apiserversource-controller  Updated "api-server-source" finalizers
  Warning  UpdateFailed     2s (x10 over 4s)  apiserversource-controller  Failed to update status for "api-server-source": ApiServerSource.sources.knative.dev "api-server-source" is invalid: status.namespaces: Invalid value: "null": namespaces in body must be of type array: "null"

Even if I don't explicit spec.namespaceSelector field, it leads to the same error.

To Reproduce

Steps to reproduce the behavior.

  1. Follow the guide in the link
  2. Create an ApiServerSource
  3. run the command kubectl describe apiserversource <api-server-source-name> -n <namespace>

Knative release version

 $ kubectl get namespace knative-serving -o 'go-template={{index .metadata.labels "app.kubernetes.io/version"}}'
1.19.0
$ kn version
Version:      v20250819-local-a920115f
Build Date:   2025-08-19 08:35:49
Git Revision: a920115f
Supported APIs:
* Serving
  - serving.knative.dev/v1 (knative-serving v0.46.1-0.20250818182249-23f988f3671a)
* Eventing
  - sources.knative.dev/v1 (knative-eventing v0.46.1-0.20250818152648-b8caa635621e)
  - eventing.knative.dev/v1 (knative-eventing v0.46.1-0.20250818152648-b8caa635621e)

Additional context

Local cluster with K3s.

Kubernetes version

$ kubectl version
Client Version: v1.33.3
Kustomize Version: v5.6.0
Server Version: v1.33.3+k3s1

ElGaleon avatar Aug 20 '25 09:08 ElGaleon

@Cali0707 any news? This behavior seems a little bit random: sometimes it works, but most of the time it doesn't. I didn't figure out what is the thing that makes the apiServerSource work

ElGaleon avatar Nov 07 '25 11:11 ElGaleon

@Cali0707 I figured out what is the real issue: it display the wrong reason. In my case it was some problem with the broker (I reinstalled the cluster and I forgot to download the default channel). So the real thing to solve it's error log!

ElGaleon avatar Nov 14 '25 15:11 ElGaleon

Hey @ElGaleon is this resolved? Or do we need to do other work around clarifying the error log?

If so, can you specify steps to recreate this issue as well as what you'd expect the error to show you?

Cali0707 avatar Nov 17 '25 14:11 Cali0707