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

Ignore non CRD files in directories used in --local-crds #110

Closed
monotek opened this issue Apr 10, 2024 · 3 comments · Fixed by #118
Closed

Ignore non CRD files in directories used in --local-crds #110

monotek opened this issue Apr 10, 2024 · 3 comments · Fixed by #118
Assignees
Labels
good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. kind/bug Categorizes issue or PR as related to a bug.

Comments

@monotek
Copy link
Member

monotek commented Apr 10, 2024

What happened?

I ran into an issue recently, when the --local-crds directory contains non CRD files.

kubectl-validate --local-crds ./test/ ./test/
Error: no kind "PodDisruptionBudget" is registered for version "policy/v1" in scheme "pkg/runtime/scheme.go:100"

What did you expect to happen?

Non CRD file shout have been ignored and k8s manifest been validated

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

Just place your resource manifests and CRDs in the same directory.

For example place a crd and a pdb in the same directory "test":

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: kialis.kiali.io
spec:
  group: kiali.io
  names:
    kind: Kiali
    listKind: KialiList
    plural: kialis
    singular: kiali
  scope: Namespaced
  versions:
  - name: v1alpha1
    served: true
    storage: true
    subresources:
      status: {}
    schema:
      openAPIV3Schema:
        type: object
        x-kubernetes-preserve-unknown-fields: true
---
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
  name: postgres
  namespace: visual-regression-tracker
spec:
  minAvailable: 1
  selector:
    matchLabels:
      application: spilo
      cluster-name: vrt-postgres-db
      spilo-role: replica

Run kubectl-validate:

kubectl-validate --local-crds ./test/ ./test/
Error: no kind "PodDisruptionBudget" is registered for version "policy/v1" in scheme "pkg/runtime/scheme.go:100"

Anything else we need to know?

No response

Kubernetes version

kubectl-valdiate version: 0.0.3
$ kubectl version
WARNING: This version information is deprecated and will be replaced with the output from kubectl version --short.  Use --output=yaml|json to get the full version.
Client Version: version.Info{Major:"1", Minor:"26", GitVersion:"v1.26.0", GitCommit:"b46a3f887ca979b1a5d14fd39cb1af43e7e5d12d", GitTreeState:"clean", BuildDate:"2022-12-08T19:58:30Z", GoVersion:"go1.19.4", Compiler:"gc", Platform:"linux/amd64"}
Kustomize Version: v4.5.7
Server Version: version.Info{Major:"1", Minor:"28", GitVersion:"v1.28.5", GitCommit:"9cf543f4f17cbc5b74c24880e77590eeb1af683c", GitTreeState:"clean", BuildDate:"2024-01-31T09:07:34Z", GoVersion:"go1.20.12", Compiler:"gc", Platform:"linux/amd64"}
WARNING: version difference between client (1.26) and server (1.28) exceeds the supported minor version skew of +/-1
@monotek monotek added the kind/bug Categorizes issue or PR as related to a bug. label Apr 10, 2024
@alexzielenski
Copy link
Contributor

Definitely a bug we want to fix.

In addition to this I think it also makes sense to default the local CRD source to the user provided yaml files. Especially now that we support multiple CRD file sources.

@alexzielenski alexzielenski added the good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. label Apr 10, 2024
@Schnides123
Copy link

I can take a look at this

@alexzielenski
Copy link
Contributor

/assign
should be fixed by #118

sorry @Schnides123 I ended up fixing this one myself

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. kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants