-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
JsonSyntaxException while parsing response for listPersistentVolume, and listPVC #324
Comments
I can't reproduce this at head, can you retry at head? I'm performing a 3.0.0-beta1 release soon. |
I just pushed the 3.0.0-beta1 release, can you try that and see if it fixes things? |
Hi @brendandburns, I checked again with 3.0.0-beta1 and see the same issue. Do we have to regenerate the model package from Swagger codegen ? |
Seeing error related to Storage capacity while attempting for StatefulSet app (with PVC) creation:
|
Are you sure you're using the latest version of the library? This looks like what would have happened before we introduced the Do you have a cached dependency somewhere in your Alternately, can you attach a gist with a reproduction of this and I will attempt to reproduce and debug? |
I'm going to close this as can not reproduce. Please re-open with code that reproduces it (a complete sample would be great) if it is still occuring. |
hello Brenden.. apologies for late reply. |
@brendandburns, Pls reopen the issue if you are able to repro. I do not have reopen permissions. |
@brendandburns , here is a easier repro:
The JSON which works, is with storage specified as a String: Here is the Persistent Volume JSON which works fine:
I tested the java client libraries after changing capacity in V1PersistentVolumeSpec from
to,
@brendandburns, I am yet to figure out changing swagger.json and regenerate all the Models needing change. Could you please verify the change suggested ? |
I'll work on reproducing this. Quantity should be getting parsed via a GSON parser so replacing it with |
How are you generating the JSON? Are you calling When I call |
I tried to reproduce this following your steps, your code doesn't compile because there are missing base classes, but I can't reproduce the error. Here's what I'm trying:
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package io.kubernetes.client.examples;
import io.kubernetes.client.ApiClient;
import io.kubernetes.client.ApiException;
import io.kubernetes.client.Configuration;
import io.kubernetes.client.apis.CoreV1Api;
import io.kubernetes.client.models.V1PersistentVolume;
import io.kubernetes.client.models.V1PersistentVolumeList;
import io.kubernetes.client.util.Config;
import java.io.IOException;
/**
* A simple example of how to use the Java API
*
* <p>Easiest way to run this: mvn exec:java
* -Dexec.mainClass="io.kubernetes.client.examples.Example"
*
* <p>From inside $REPO_DIR/examples
*/
public class Example {
public static void main(String[] args) throws IOException, ApiException {
ApiClient client = Config.defaultClient();
Configuration.setDefaultApiClient(client);
CoreV1Api api = new CoreV1Api();
V1PersistentVolumeList list =
api.listPersistentVolume(null, null, null, null, null, null, null, null, null);
for (V1PersistentVolume item : list.getItems()) {
System.out.println(item.getMetadata().getName());
}
}
} This works correctly and as expected with no parse errors. Somehow, you aren't loading the contents of the 'custom' directory here: Into your java classpath, specifically the annotation here registers the Quantity class with Gson. Somehow that's not happening, you might try: apiClient.getJSON().getGson().getAdapter(Quantity.class) And see what the output is... I'm going to closes this as cannot reproduce. Please re-open if you have a clean environment that I can compile and test against head. |
@brendandburns thanks for adding the ParseExample. It helped narrow down the issue in my workspace. My classpath had gson v2.2.4 instead of the v2.6.2 used by kubernetes client. Fixing this maven dependency solved the Yaml parse errors. |
Kubernetes client version: v1.10.4
Kubernetes server version: v1.10.4
kubernetes java client version: 2.0.0
Encountering JsonSyntaxException while parsing response of GET PersistentVolumes and PersistentVolumeClaims while trying to parse storage capacity -> "...."storage":"1Gi"},....." as a JSONObject.
The capacity is of type Map<String, Quantity> whereas "1Gi" is the value.
Looking forward for suggestions on how to fix this.
API response JSON:
{"kind":"PersistentVolumeList","apiVersion":"v1","metadata":{"selfLink":"/api/v1/persistentvolumes","resourceVersion":"340886"},"items":[{"metadata":{"name":"pvc-a8bb7fbc-8ce2-11e8-a11a-005056acd71d","selfLink":"/api/v1/persistentvolumes/pvc-a8bb7fbc-8ce2-11e8-a11a-005056acd71d","uid":"aa0e4179-8ce2-11e8-a11a-005056acd71d","resourceVersion":"3157","creationTimestamp":"2018-07-21T12:36:17Z","annotations":{"kubernetes.io/createdby":"vsphere-volume-dynamic-provisioner","pv.kubernetes.io/bound-by-controller":"yes","pv.kubernetes.io/provisioned-by":"kubernetes.io/vsphere-volume"},"finalizers":["kubernetes.io/pv-protection"]},"spec":{"capacity":{"storage":"1Gi"},"vsphereVolume":{"volumePath":"[vsanDatastore] c928535b-25c3-b1fb-12d0-f8bc12068db0/kubernetes-dynamic-pvc-a8bb7fbc-8ce2-11e8-a11a-005056acd71d.vmdk","fsType":"ext4"},"accessModes":["ReadWriteOnce"],"claimRef":{"kind":"PersistentVolumeClaim","namespace":"default","name":"www-web-0","uid":"a8bb7fbc-8ce2-11e8-a11a-005056acd71d","apiVersion":"v1","resourceVersion":"3146"},"persistentVolumeReclaimPolicy":"Delete","storageClassName":"thin-disk"},"status":{"phase":"Bound"}},{"metadata":{"name":"pvc-c11986e8-8ce2-11e8-a11a-005056acd71d","selfLink":"/api/v1/persistentvolumes/pvc-c11986e8-8ce2-11e8-a11a-005056acd71d","uid":"c13b00ab-8ce2-11e8-a11a-005056acd71d","resourceVersion":"3234","creationTimestamp":"2018-07-21T12:36:56Z","annotations":{"kubernetes.io/createdby":"vsphere-volume-dynamic-provisioner","pv.kubernetes.io/bound-by-controller":"yes","pv.kubernetes.io/provisioned-by":"kubernetes.io/vsphere-volume"},"finalizers":["kubernetes.io/pv-protection"]},"spec":{"capacity":{"storage":"1Gi"},"vsphereVolume":{"volumePath":"[vsanDatastore] c928535b-25c3-b1fb-12d0-f8bc12068db0/kubernetes-dynamic-pvc-c11986e8-8ce2-11e8-a11a-005056acd71d.vmdk","fsType":"ext4"},"accessModes":["ReadWriteOnce"],"claimRef":{"kind":"PersistentVolumeClaim","namespace":"default","name":"www-web-1","uid":"c11986e8-8ce2-11e8-a11a-005056acd71d","apiVersion":"v1","resourceVersion":"3220"},"persistentVolumeReclaimPolicy":"Delete","storageClassName":"thin-disk"},"status":{"phase":"Bound"}}]}
The text was updated successfully, but these errors were encountered: