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

volumesnapshots CRD has invalid property: anyOf #288

Closed
ialidzhikov opened this issue Apr 8, 2020 · 15 comments
Closed

volumesnapshots CRD has invalid property: anyOf #288

ialidzhikov opened this issue Apr 8, 2020 · 15 comments
Assignees
Labels
lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.

Comments

@ialidzhikov
Copy link
Contributor

What happened:
volumesnapshots CRD has invalid property: anyOf

How to reproduce it (as minimally and precisely as possible):

  1. Apply the volumesnapshots.snapshot.storage.k8s.io CRD.
$ k apply -f https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/master/config/crd/snapshot.storage.k8s.io_volumesnapshots.yaml
  1. Ensure the following log entry in the kube-apiserver logs:
$ k -n kube-system logs kube-apiserver-m01

E0408 10:21:28.449071       1 customresource_handler.go:655] error building openapi models for volumesnapshots.snapshot.storage.k8s.io: ERROR $root.definitions.io.k8s.storage.snapshot.v1beta1.VolumeSnapshot.properties.status.properties.restoreSize has invalid property: anyOf

Environment:

  • Kubernetes version (use kubectl version): v1.16.8
@xing-yang
Copy link
Collaborator

This is automatically generated by controller-gen. Maybe because it does not know how to interpret resource.Quantity.

            restoreSize:
              anyOf:
              - type: integer
              - type: string

@yuxiangqian should we manually remove a type after it is generated automatically?
https://github.com/kubernetes-csi/external-snapshotter/blob/master/config/crd/snapshot.storage.k8s.io_volumesnapshots.yaml#L160

@humblec
Copy link
Contributor

humblec commented May 3, 2020

Yeah.. looks like that. we could add resource.Quantity . Let me give a try.

@humblec
Copy link
Contributor

humblec commented May 5, 2020

Yeah.. looks like that. we could add resource.Quantity . Let me give a try.

@xing-yang @yuxiangqian this kubernetes-sigs/controller-tools#328 has some details on what we are facing. for now, adjusting the CRD looks to be the way. I can send a PR for the same if we are in agreement.

@yuxiangqian
Copy link
Contributor

c3beea5#diff-f816aba0495ad43b0e3b8b097e94a8d2
this is the PR which introduced the breakage. we should NOT use anyof according to (details)

@xing-yang
Copy link
Collaborator

The existing code was generated automatically by controller-gen. @yuxiangqian did you have to manually set this to "type: string" in 2.0? Otherwise, this is a change in behavior in controller-gen.

This is what we have in release-2.0:
https://github.com/kubernetes-csi/external-snapshotter/blob/release-2.0/config/crd/snapshot.storage.k8s.io_volumesnapshots.yaml#L133

Should we just manually modify this and set to "type: string" instead?

@yuxiangqian
Copy link
Contributor

@humblec did you follow the instructions here?
I saw this field has been removed from that PR: preserveUnknownFields: false
which likely will cause problem.

@humblec
Copy link
Contributor

humblec commented May 6, 2020

/assign humblec

@humblec
Copy link
Contributor

humblec commented May 11, 2020

@humblec did you follow the instructions here?
I saw this field has been removed from that PR: preserveUnknownFields: false
which likely will cause problem.

@yuxiangqian Yes, I did and once I have a commit to update the controller gen to v0.3.0, if I run update-crd.sh, below is the only change:

[root@localhost external-snapshotter]# git diff
diff --git a/config/crd/snapshot.storage.k8s.io_volumesnapshotclasses.yaml b/config/crd/snapshot.storage.k8s.io_volumesnapshotclasses.yaml
index 4aa980cc..984ce42b 100644
--- a/config/crd/snapshot.storage.k8s.io_volumesnapshotclasses.yaml
+++ b/config/crd/snapshot.storage.k8s.io_volumesnapshotclasses.yaml
@@ -5,7 +5,6 @@ kind: CustomResourceDefinition
 metadata:
   annotations:
     controller-gen.kubebuilder.io/version: v0.2.5
-    api-approved.kubernetes.io: "https://github.com/kubernetes-csi/external-snapshotter/pull/260"
   creationTimestamp: null
   name: volumesnapshotclasses.snapshot.storage.k8s.io
 spec:
@@ -62,6 +61,9 @@ spec:
             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:
+          description: 'Standard object''s metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata'
+          type: object
         parameters:
           additionalProperties:
             type: string
diff --git a/config/crd/snapshot.storage.k8s.io_volumesnapshotcontents.yaml b/config/crd/snapshot.storage.k8s.io_volumesnapshotcontents.yaml
index 34c51ad6..a8c56e24 100644
--- a/config/crd/snapshot.storage.k8s.io_volumesnapshotcontents.yaml
+++ b/config/crd/snapshot.storage.k8s.io_volumesnapshotcontents.yaml
@@ -5,7 +5,6 @@ kind: CustomResourceDefinition
 metadata:
   annotations:
     controller-gen.kubebuilder.io/version: v0.2.5
-    api-approved.kubernetes.io: "https://github.com/kubernetes-csi/external-snapshotter/pull/260"
   creationTimestamp: null
   name: volumesnapshotcontents.snapshot.storage.k8s.io
 spec:
@@ -66,6 +65,9 @@ spec:
             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:
+          description: 'Standard object''s metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata'
+          type: object
         spec:
           description: spec defines properties of a VolumeSnapshotContent created
             by the underlying storage system. Required.
diff --git a/config/crd/snapshot.storage.k8s.io_volumesnapshots.yaml b/config/crd/snapshot.storage.k8s.io_volumesnapshots.yaml
index 483706f1..74d31ae9 100644
--- a/config/crd/snapshot.storage.k8s.io_volumesnapshots.yaml
+++ b/config/crd/snapshot.storage.k8s.io_volumesnapshots.yaml
@@ -5,7 +5,6 @@ kind: CustomResourceDefinition
 metadata:
   annotations:
     controller-gen.kubebuilder.io/version: v0.2.5
-    api-approved.kubernetes.io: "https://github.com/kubernetes-csi/external-snapshotter/pull/260"
   creationTimestamp: null
   name: volumesnapshots.snapshot.storage.k8s.io
 spec:
@@ -70,6 +69,9 @@ spec:
             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:
+          description: 'Standard object''s metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata'
+          type: object
         spec:
           description: 'spec defines the desired characteristics of a snapshot requested

The document says about, removing the newly added metadata section, so we can ignore that part. Second thing what the current document says is replacing the api-approved.kubernetes.io which actually got removed once we ran the script. but I can bring back . I dont see the preserveUnknownFields: false in my git diff at all. Are you sure thats happening with update-crd.sh ?

@ialidzhikov
Copy link
Contributor Author

Ping, is there any update?

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/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 Sep 23, 2020
@fejta-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Oct 23, 2020
@vishutrilio
Copy link

Hi @xing-yang , can you tell how did you fix it? I just wanted to understand how resource.Quantity resulted in string in CRD. Thanks

@xing-yang
Copy link
Collaborator

We made a manual change to remove "integer" and keep "string". It is documented in the README:
https://github.com/kubernetes-csi/external-snapshotter/tree/master/client/hack#update-crdsh

@vishutrilio
Copy link

Thank you @xing-yang

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.
Projects
None yet
Development

No branches or pull requests

7 participants