operator-framework / operator-registry

Operator Registry runs in a Kubernetes or OpenShift cluster to provide operator catalog data to Operator Lifecycle Manager.
Apache License 2.0
212 stars 247 forks source link

bundle validate fails w/ openapi field minimum set #263

Open JohnStrunk opened 4 years ago

JohnStrunk commented 4 years ago

opm alpha bundle validate fails if the CRD contains field validation.

Error:

opm alpha bundle validate --tag quay.io/johnstrunk/snapscheduler.v1.1.0:latest
INFO[0000] Create a temp directory at /tmp/bundle-248706423  container-tool=docker
DEBU[0000] Pulling and unpacking container image         container-tool=docker
INFO[0000] running docker pull                           container-tool=docker
DEBU[0000] [docker pull quay.io/johnstrunk/snapscheduler.v1.1.0:latest]  container-tool=docker
INFO[0001] running docker save                           container-tool=docker
DEBU[0001] [docker save quay.io/johnstrunk/snapscheduler.v1.1.0:latest -o bundle_staging_059888746/bundle.tar]  container-tool=docker
INFO[0001] Unpacked image layers, validating bundle image format & contents  container-tool=docker
DEBU[0001] Found manifests directory                     container-tool=docker
DEBU[0001] Found metadata directory                      container-tool=docker
DEBU[0001] Getting mediaType info from manifests directory  container-tool=docker
DEBU[0001] Validating annotations.yaml                   container-tool=docker
DEBU[0001] Found annotation "operators.operatorframework.io.bundle.mediatype.v1" with value "registry+v1"  container-tool=docker
DEBU[0001] Found annotation "operators.operatorframework.io.bundle.manifests.v1" with value "manifests/"  container-tool=docker
DEBU[0001] Found annotation "operators.operatorframework.io.bundle.metadata.v1" with value "metadata/"  container-tool=docker
DEBU[0001] Found annotation "operators.operatorframework.io.bundle.package.v1" with value "snapscheduler"  container-tool=docker
DEBU[0001] Found annotation "operators.operatorframework.io.bundle.channels.v1" with value "stable"  container-tool=docker
DEBU[0001] Found annotation "operators.operatorframework.io.bundle.channel.default.v1" with value "stable"  container-tool=docker
DEBU[0001] Validating bundle contents                    container-tool=docker
DEBU[0001] Validating "operators.coreos.com/v1alpha1, Kind=ClusterServiceVersion" from file "snapscheduler.v1.1.0.clusterserviceversion.yaml"  container-tool=docker
DEBU[0001] Validating "apiextensions.k8s.io/v1beta1, Kind=CustomResourceDefinition" from file "snapshotschedules.snapscheduler.backube.crd.yaml"  container-tool=docker
Error: Bundle validation errors: cannot convert int64 to float64

The offending portion of CRD seems to be the "minimum" line in the below snip. If minimum: 1 is removed from the CRD validation passes.

                maxCount:
                  format: int32
                  minimum: 1
                  type: integer

Full CRD:

apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
  name: snapshotschedules.snapscheduler.backube
spec:
  additionalPrinterColumns:
    - JSONPath: .spec.schedule
      name: Schedule
      type: string
    - JSONPath: .spec.retention.expires
      name: Max age
      type: string
    - JSONPath: .spec.retention.maxCount
      name: Max num
      type: integer
    - JSONPath: .spec.disabled
      name: Disabled
      type: boolean
    - JSONPath: .status.nextSnapshotTime
      name: Next snapshot
      type: string
  group: snapscheduler.backube
  names:
    kind: SnapshotSchedule
    listKind: SnapshotScheduleList
    plural: snapshotschedules
    singular: snapshotschedule
  scope: Namespaced
  subresources:
    status: {}
  validation:
    openAPIV3Schema:
      description: SnapshotSchedule is the Schema for the snapshotschedules API
      properties:
        apiVersion:
          description: >-
            APIVersion defines the versioned schema of this representation of an
            object. Servers should convert recognized schemas to the latest
            internal value, and may reject unrecognized values. More info:
            https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
          type: string
        kind:
          description: >-
            Kind is a string value representing the REST resource this object
            represents. Servers may infer this from the endpoint the client
            submits requests to. Cannot be updated. In CamelCase. More info:
            https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
          type: string
        metadata:
          type: object
        spec:
          description: SnapshotScheduleSpec defines the desired state of SnapshotSchedule
          properties:
            claimSelector:
              description: >-
                ClaimSelector selects which PVCs will be snapshotted according
                to this schedule.
              properties:
                matchExpressions:
                  description: >-
                    matchExpressions is a list of label selector requirements.
                    The requirements are ANDed.
                  items:
                    description: >-
                      A label selector requirement is a selector that contains
                      values, a key, and an operator that relates the key and
                      values.
                    properties:
                      key:
                        description: key is the label key that the selector applies to.
                        type: string
                      operator:
                        description: >-
                          operator represents a key's relationship to a set of
                          values. Valid operators are In, NotIn, Exists and
                          DoesNotExist.
                        type: string
                      values:
                        description: >-
                          values is an array of string values. If the operator
                          is In or NotIn, the values array must be non-empty. If
                          the operator is Exists or DoesNotExist, the values
                          array must be empty. This array is replaced during a
                          strategic merge patch.
                        items:
                          type: string
                        type: array
                    required:
                      - key
                      - operator
                    type: object
                  type: array
                matchLabels:
                  additionalProperties:
                    type: string
                  description: >-
                    matchLabels is a map of {key,value} pairs. A single
                    {key,value} in the matchLabels map is equivalent to an
                    element of matchExpressions, whose key field is "key", the
                    operator is "In", and the values array contains only
                    "value". The requirements are ANDed.
                  type: object
              type: object
            disabled:
              description: Disabled determines whether this schedule is currently disabled.
              type: boolean
            retention:
              description: >-
                Retention determines how long this schedule's snapshots will be
                kept.
              properties:
                expires:
                  description: >-
                    Expires is the length of time (time.Duration) after which a
                    given Snapshot will be deleted.
                  type: string
                maxCount:
                  format: int32
                  minimum: 1
                  type: integer
              type: object
            schedule:
              description: >-
                Schedule is a Cronspec specifying when snapshots should be
                taken. See https://en.wikipedia.org/wiki/Cron for a description
                of the format.
              type: string
            snapshotTemplate:
              description: >-
                SnapshotTemplate is a template description of the Snapshots to
                be created.
              properties:
                labels:
                  additionalProperties:
                    type: string
                  description: >-
                    Labels is a list of labels that should be added to each
                    Snapshot created by this schedule.
                  type: object
                snapshotClassName:
                  description: >-
                    SnapshotClassName is the name of the VSC to be used when
                    creating Snapshots.
                  type: string
              type: object
          type: object
        status:
          description: >-
            SnapshotScheduleStatus defines the observed state of
            SnapshotSchedule
          properties:
            conditions:
              description: >-
                Conditions is a list of conditions related to operator
                reconciliation.
              items:
                description: >-
                  Condition represents the state of the operator's
                  reconciliation functionality.
                properties:
                  lastHeartbeatTime:
                    format: date-time
                    type: string
                  lastTransitionTime:
                    format: date-time
                    type: string
                  message:
                    type: string
                  reason:
                    type: string
                  status:
                    type: string
                  type:
                    description: >-
                      ConditionType is the state of the operator's
                      reconciliation functionality.
                    type: string
                required:
                  - status
                  - type
                type: object
              type: array
            lastSnapshotTime:
              description: >-
                LastSnapshotTime is the time of the most recent set of snapshots
                generated by this schedule.
              type: string
            nextSnapshotTime:
              description: >-
                NextSnapshotTime is the time when this schedule should create
                the next set of snapshots.
              type: string
          type: object
      type: object
  version: v1
  versions:
    - name: v1
      served: true
      storage: true
stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.