Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Resources with a Kind Ending in "List" are Silently Ignored #5042

Open
GuyPaddock opened this issue Feb 9, 2023 · 11 comments
Open

Custom Resources with a Kind Ending in "List" are Silently Ignored #5042

GuyPaddock opened this issue Feb 9, 2023 · 11 comments
Assignees
Labels
good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/bug Categorizes issue or PR as related to a bug. triage/accepted Indicates an issue or PR is ready to be actively worked on.

Comments

@GuyPaddock
Copy link

What happened?

If you include a custom resource in an overlay, and the Kind of the custom resource ends with the word List, it will be ignored from the output when running kustomize build. This behavior is undocumented and unexpected.

What did you expect to happen?

Custom resources should not be ignored based on the suffix of their Kind.

How can we reproduce it (as minimally and precisely as possible)?

# kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- resources.yaml
# resources.yaml - Based on https://github.com/kubernetes-sigs/kustomize/blob/master/examples/customOpenAPIschema.md.
apiVersion: example.com/v1alpha1
kind: MyResource
metadata:
  name: service
spec:
  template:
    spec:
      containers:
        - name: server
          image: server
          command: example
          ports:
            - name: grpc
              protocol: TCP
              containerPort: 8080
---
apiVersion: example.com/v1alpha1
kind: MyResourceList
metadata:
  name: service
spec:
  template:
    spec:
      containers:
        - name: server
          image: server
          command: example
          ports:
            - name: grpc
              protocol: TCP
              containerPort: 8080

Expected output

apiVersion: example.com/v1alpha1
kind: MyResource
metadata:
  name: service
  namespace: cloud-shell-dev
spec:
  template:
    spec:
      containers:
      - command: example
        image: server
        name: server
        ports:
        - containerPort: 8080
          name: grpc
          protocol: TCP
---
apiVersion: example.com/v1alpha1
kind: MyResourceList
metadata:
  name: service
  namespace: cloud-shell-dev
spec:
  template:
    spec:
      containers:
      - command: example
        image: server
        name: server
        ports:
        - containerPort: 8080
          name: grpc
          protocol: TCP

Actual output

apiVersion: example.com/v1alpha1
kind: MyResource
metadata:
  name: service
  namespace: cloud-shell-dev
spec:
  template:
    spec:
      containers:
      - command: example
        image: server
        name: server
        ports:
        - containerPort: 8080
          name: grpc
          protocol: TCP

Kustomize version

5.0.0

Operating system

Linux

@GuyPaddock GuyPaddock added the kind/bug Categorizes issue or PR as related to a bug. label Feb 9, 2023
@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Feb 9, 2023
@natasha41575
Copy link
Contributor

natasha41575 commented Feb 9, 2023

I can reproduce this issue and can also confirm that just changing "MyResourceList" to something that doesn't end in "List" results in the resource being correctly rendered in the output. I find this very odd because AFAIK, we don't do any explicit filtering by resource kind 🤔

/triage accepted
/help

@k8s-ci-robot
Copy link
Contributor

@natasha41575:
This request has been marked as needing help from a contributor.

Guidelines

Please ensure that the issue body includes answers to the following questions:

  • Why are we solving this issue?
  • To address this issue, are there any code changes? If there are code changes, what needs to be done in the code and what places can the assignee treat as reference points?
  • Does this issue have zero to low barrier of entry?
  • How can the assignee reach out to you for help?

For more details on the requirements of such an issue, please see here and ensure that they are met.

If this request no longer meets these requirements, the label can be removed
by commenting with the /remove-help command.

In response to this:

I can reproduce this issue and can also confirm that just changing "MyResourceList" to something that doesn't end in "List" results in the resource being correctly rendered in the output. I find this very odd because AFAIK, we don't do any explicit filtering by resource kind? 🤔

/triage accepted
/help

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Feb 9, 2023
@natasha41575 natasha41575 added the good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. label Feb 9, 2023
@cailyn-codes
Copy link
Contributor

/assign

@cailyn-codes
Copy link
Contributor

Hello @GuyPaddock!

After looking into this issue we have discovered that this is a result of the api-conventions, specifically they state:

Lists are collections of resources of one (usually) or more (occasionally) kinds.
The name of a list kind must end with "List". Lists have a limited set of common metadata. All lists use the required "items" field to contain the array of objects they return. Any kind that has the "items" field must be a list kind.
Most objects defined in the system should have an endpoint that returns the full set of resources, as well as zero or more endpoints that return subsets of the full list. Some objects may be singletons (the current user, the system defaults) and may not have lists.

So when kustomize is parsing the resource it will unwrap the resources in the items field. When the name of the object ends in List and there are no items it is treated an empty list.

If this does not satisfy your use case could you please provide more context about why you would like to have an object with name *List that does not have the items field?

We will add a warning when the list is empty to make this more obvious.

@haarchri
Copy link

haarchri commented Mar 2, 2023

@cailynse we running provider-kafka from crossplane eco-system and we have a resource called "AccessControlList" which is silently Ignored

@GuyPaddock
Copy link
Author

@cailynse I believe that there is some confusion in the way that the API conventions are being interpreted. Saying that all lists must have names ending in "List" is not the same thing as saying that all things who have names ending in "List" are lists.

Similar to @cailynse, we had defined a new config entity that had a name ending in List. Ours was called an "CidrAddressList" that was a JSON object listing the CIDR addresses/ranges that were allowed to access a certain application through ingress. (It had to be an object with two properties, cidrList and cidrString rather than just a list because we needed to expose the addresses as both a comma-delimited string of values and a list of values because there's no way in Kustomize to join a list of values together with a delimiter).

As a workaround I had to change the name to CidrAddresses but that didn't have the same grokability.

@chetak123
Copy link
Member

Hey @cailynse are you currently working on this issue ?

@cailyn-codes
Copy link
Contributor

@chetak123 - I am not at the moment, there was some discussion around what the correct solution would be and then I was pulled away. Feel free to jump on it if you are interested!

@cailyn-codes
Copy link
Contributor

/unassign

@meghanajangi
Copy link
Member

I would like to work on this.
/assign

@isarns
Copy link
Contributor

isarns commented Jul 1, 2024

Any updates?
Crossplane has few resources that end with "list" that we can't deploy with kustomise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/bug Categorizes issue or PR as related to a bug. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants