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

🐛 Make topology markers also valid for type definitions #693

Conversation

k8s-infra-cherrypick-robot

This is an automated cherry-pick of #692

/assign alvaroaleman

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jun 27, 2022
@alvaroaleman
Copy link
Member

/retitle 🐛 Make topology markers also valid for type definitions
/lgtm
/approve

@k8s-ci-robot k8s-ci-robot changed the title [release-0.9] 🐛 Make topology markers also valid for type definitions 🐛 Make topology markers also valid for type definitions Jun 27, 2022
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 27, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alvaroaleman, k8s-infra-cherrypick-robot

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 27, 2022
@k8s-ci-robot k8s-ci-robot merged commit 8d80422 into kubernetes-sigs:release-0.9 Jun 27, 2022
@robbie-demuth
Copy link

I took a stab at using the new release with these changes today and am running into an issue with the way my CRD is now being generated. My CRD has fields of type []corev1.EnvVar. Previously, the schema for said fields was generated as follows:

env:
  items:
    properties:
      name:
        type: string
      value:
        type: string
      valueFrom:
        properties:
          configMapKeyRef:
            properties:
              key:
                type: string
              name:
                type: string
              optional:
                type: boolean
            required:
            - key
            type: object
          fieldRef:
            properties:
              apiVersion:
                type: string
              fieldPath:
                type: string
            required:
            - fieldPath
            type: object
          resourceFieldRef:
            properties:
              containerName:
                type: string
              divisor:
                anyOf:
                - type: integer
                - type: string
                pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
                x-kubernetes-int-or-string: true
              resource:
                type: string
            required:
            - resource
            type: object
          secretKeyRef:
            properties:
              key:
                type: string
              name:
                type: string
              optional:
                type: boolean
            required:
            - key
            type: object
        type: object
    required:
    - name
    type: object
  type: array
  x-kubernetes-list-map-keys:
  - name
  x-kubernetes-list-type: map

Now, however, it's generated as

env:
  items:
    properties:
      name:
        type: string
      value:
        type: string
      valueFrom:
        properties:
          configMapKeyRef:
            allOf:
            - x-kubernetes-map-type: atomic
            - x-kubernetes-map-type: atomic
            properties:
              key:
                type: string
              name:
                type: string
              optional:
                type: boolean
            required:
            - key
            type: object
          fieldRef:
            properties:
              apiVersion:
                type: string
              fieldPath:
                type: string
            required:
            - fieldPath
            type: object
            x-kubernetes-map-type: atomic
          resourceFieldRef:
            properties:
              containerName:
                type: string
              divisor:
                anyOf:
                - type: integer
                - type: string
                pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
                x-kubernetes-int-or-string: true
              resource:
                type: string
            required:
            - resource
            type: object
            x-kubernetes-map-type: atomic
          secretKeyRef:
            allOf:
            - x-kubernetes-map-type: atomic
            - x-kubernetes-map-type: atomic
            properties:
              key:
                type: string
              name:
                type: string
              optional:
                type: boolean
            required:
            - key
            type: object
        type: object
    required:
    - name
    type: object
  type: array
  x-kubernetes-list-map-keys:
  - name
  x-kubernetes-list-type: map

Note the addition of

allOf:
- x-kubernetes-map-type: atomic
- x-kubernetes-map-type: atomic

to configMapKeyRef and secretKeyRef. When trying to create the new CRD in a cluster, I get errors like the following:

CustomResourceDefinition.apiextensions.k8s.io \"<CRD>\" is invalid: [spec.versions[0].schema.openAPIV3Schema.properties[spec].properties[env].items.properties[valueFrom].properties[configMapKeyRef].allOf[0].type: Required value: must be object if x-kubernetes-map-type is specified

It looks like the error is coming from here, but I'm not sure what it means. Any ideas? Thanks!

@FillZpp
Copy link
Contributor

FillZpp commented Jun 29, 2022

Note the addition of

allOf:
- x-kubernetes-map-type: atomic
- x-kubernetes-map-type: atomic

Oh, it's so bad. That's what I worried when I commented #692 (comment) . It reminded me of another bug #688 , which generated duplicate x-kubernetes-preserve-unknown-fields in allOf.

@chrischdi
Copy link
Member

chrischdi commented Jun 29, 2022

@robbie-demuth could you please also share the go code which this is generated from? (at least the struct parts and markers for secretKeyRef or configMapKeyRef)?

Edit: nevermind, I see that it is also present in the test data. I'll take a look at it 👍 sorry for the circumstances though 😞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants