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

krusty Ignores Resources with "List" Suffix in Kind Name Without Warning #5485

Open
EulerLee opened this issue Dec 12, 2023 · 3 comments
Open
Labels
kind/bug Categorizes issue or PR as related to a bug. lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.

Comments

@EulerLee
Copy link

What happened?

When using krusty from the Kustomize API, I noticed that it ignores resources whose Kind name ends with "List". For example, resources defined as Kind: AccessWhiteList are not included in the output of krusty. This occurs without any errors or warnings.

What did you expect to happen?

I expected all resources listed in the kustomization.yaml file to be processed by krusty, regardless of their Kind name. If certain resources are not compatible or cannot be processed, an error or warning should be provided.

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

  1. Create a set of YAML files defining custom resources, ensuring some have Kind names ending in "List".
# resources.yaml
apiVersion: infra.protonbase.io/v1alpha1
kind: AccessWhiteList
metadata:
  name: wlmls5769f
  namespace: dc7i4hyxzw
spec:
  rules:
  - sourceIps: 0.0.0.0/16
  1. Add these files to a kustomization.yaml under the resources section.
# kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ./resources.yaml
  1. Run krusty to process the directory. dir like:
./
├── kustomization.yaml
└── resources.yaml
  1. Observe that resources with Kind names ending in "List" are not processed.
package main

import (
	"fmt"
	"io/fs"

	securefs "github.com/fluxcd/pkg/kustomize/filesys"
	"sigs.k8s.io/kustomize/api/krusty"
	kustypes "sigs.k8s.io/kustomize/api/types"
)

func main() {
	rootDir := "YOUR_ROOT_DIR"              // for example: /tmp/euler
	subDir := "YOUR_SUB_DIR_UNDER_ROOT_DIR" // for example: /tmp/euler/test

	fst, err := securefs.MakeFsOnDiskSecureBuild(rootDir)
	if err != nil {
		panic(err)
	}

	buildOptions := &krusty.Options{
		LoadRestrictions: kustypes.LoadRestrictionsNone,
		PluginConfig:     kustypes.DisabledPluginConfig(),
	}
	k := krusty.MakeKustomizer(buildOptions)
	m, err := k.Run(fst, subDir)
	if err != nil {
		panic(err)
	}

	fmt.Println("Euler len: ", len(m.Resources()))
	for _, res := range m.Resources() {
		fmt.Printf("euler: resName: %s, resKind: %s, resApiVersion: %s\n", res.GetName(), res.GetKind(), res.GetApiVersion())
	}
}

Expected output

Euler len:  1
euler: resName: wlmls5769f, resKind: AccessWhitelist, resApiVersion: infra.protonbase.io/v1alpha1

or warning/error

Actual output

Euler len:  0

Kustomize version

sigs.k8s.io/kustomize/api@v0.16.0

Operating system

None

@EulerLee EulerLee added the kind/bug Categorizes issue or PR as related to a bug. label Dec 12, 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 Dec 12, 2023
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

SIG CLI takes a lead on issue triage for this repo, but any Kubernetes member can accept issues by applying the triage/accepted label.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

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.

@Bharadwajshivam28
Copy link

I can take on this issue if no one is working. I need some details and steps to get started

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label May 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.
Projects
None yet
Development

No branches or pull requests

4 participants