Giter Site home page Giter Site logo

Comments (8)

alok87 avatar alok87 commented on June 1, 2024

Validation needs to be made better for the CRD

from k8s-worker-pod-autoscaler.

adityabhatia02 avatar adityabhatia02 commented on June 1, 2024

Unable to edit min-replicas in kubernetes v1.18.0; Failing with error:
Invalid value: "": "spec" must validate one and only one schema (oneOf). Found 2 valid alternatives

from k8s-worker-pod-autoscaler.

alok87 avatar alok87 commented on June 1, 2024

Issue is happening because the WPA has got created and the object has both replicasSetName and deploymentName.

spec:
    maxDisruption: null
    maxReplicas: 1
    minReplicas: 0
    queueURI: URI-sample
    replicaSetName: ""
    deploymentName: mailsender
    secondsToProcessOneJob: 0
    targetMessagesPerWorker: 1

cc @matkam

from k8s-worker-pod-autoscaler.

aleclerc-sonrai avatar aleclerc-sonrai commented on June 1, 2024

I have the same issue as @adityabhatia02 with both deploymentName and replicasSetName having been set, however replicasSetName got defaulted to "" when it was never specified in the yaml. I'm using Helm3 and k8s 1.15

from k8s-worker-pod-autoscaler.

matkam avatar matkam commented on June 1, 2024

I'm not too familiar with CRD validation rules. Is it possible to set the validation oneOf to be "not empty/blank" instead of required? Here's the CRD currently: https://github.com/practo/k8s-worker-pod-autoscaler/blob/master/artifacts/crd.yaml#L42

Would it make sense to use anyOf instead of oneOf validation? Or to even remove the oneOf requirement and handle incorrect states in the operator code. If both fields exist, use deploymentName first. If invalid, try replicaSetName next. If both values are invalid, then throw an error.

from k8s-worker-pod-autoscaler.

aleclerc-sonrai avatar aleclerc-sonrai commented on June 1, 2024

To be honest I'm not either, as a temporary measure I did delete the restriction and everything is fine. What I'm trying to figure out and I think is ultimately the problem, is why is replicaName getting defaulted when it's not in my yaml.

from k8s-worker-pod-autoscaler.

alok87 avatar alok87 commented on June 1, 2024

oneOf does work as we expect it to. Here is an example:

$ cat wpa.yaml
apiVersion: k8s.practo.dev/v1
kind: WorkerPodAutoScaler
metadata:
  labels:
    app: voice
  name: testoneof
spec:
    maxDisruption: null
    maxReplicas: 1
    minReplicas: 0
    queueURI: beanstalk://beanstalkd/mail-sender
    replicaSetName: ""
    deploymentName: mailsender
    secondsToProcessOneJob: 0
    targetMessagesPerWorker: 1
$ k create -f wpa.yaml
The WorkerPodAutoScaler "testoneof" is invalid: : Invalid value: "": "spec" must validate one and only one schema (oneOf). Found 2 valid alternatives

oneOf prevents both replicaSetName and deploymetName to get set. As @aleclerc-sonrai we should may be find out how did the value get set? Was the CRD validation updated after the object was created?

from k8s-worker-pod-autoscaler.

aleclerc-sonrai avatar aleclerc-sonrai commented on June 1, 2024

No it wasn't. My current theory is that the operator itself, when it is updating the status, is somehow also updating the spec.replicaSetName to ""...my yaml definitely doesn't have the field specified anywhere.

from k8s-worker-pod-autoscaler.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.