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

DeleteNamespacedDeployment : com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: #321

Closed
sandeepsingh3 opened this issue Jul 20, 2018 · 1 comment

Comments

@sandeepsingh3
Copy link

sandeepsingh3 commented Jul 20, 2018

Hi,

I am trying to delete a deployment using ExtensionsV1beta1Api. Sample code below
try{
ExtensionsV1beta1Api apiInstance = new ExtensionsV1beta1Api();
String name = valMetaData; // String | name of the Deployment
V1DeleteOptions body = new V1DeleteOptions(); // V1DeleteOptions |
String pretty = "true"; // String | If 'true', then the output is pretty printed.
Integer gracePeriodSeconds = 56; // Integer | The duration in seconds before the object should be deleted. Value must be non-negative integer. The value zero indicates delete immediately. If this value is nil, the default grace period for the specified type will be used. Defaults to a per object value if not specified. zero means delete immediately.
Boolean orphanDependents = false; // Boolean | Deprecated: please use the PropagationPolicy, this field will be deprecated in 1.7. Should the dependent objects be orphaned. If true/false, the "orphan" finalizer will be added to/removed from the object's finalizers list. Either this field or PropagationPolicy may be set, but not both.
String propagationPolicy = "Foreground"; // String | Whether and how garbage collection will be performed. Either this field or OrphanDependents may be set, but not both. The default policy is decided by the existing finalizer set in the metadata.finalizers and the resource-specific default policy. Acceptable values are: 'Orphan' - orphan the dependents; 'Background' - allow the garbage collector to delete the dependents in the background; 'Foreground' - a cascading policy that deletes all dependents in the foreground.
try {
apiInstance.deleteNamespacedDeployment(name, nameSpace, body, null, null, null, null);
System.out.println("delete deployment");
} catch (ApiException e) {
System.err.println("Exception when calling ExtensionsV1beta1Api#deleteNamespacedDeployment");
e.printStackTrace();
}

	}catch(Exception e){
		e.printStackTrace();
	}

However i am getting the below exception

com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected a string but was BEGIN_OBJECT at line 1 column 1611 path $.status
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:220)
at com.google.gson.Gson.fromJson(Gson.java:879)
at com.google.gson.Gson.fromJson(Gson.java:844)
at com.google.gson.Gson.fromJson(Gson.java:793)
at io.kubernetes.client.JSON.deserialize(JSON.java:110)
at io.kubernetes.client.ApiClient.deserialize(ApiClient.java:668)
at io.kubernetes.client.ApiClient.handleResponse(ApiClient.java:871)
at io.kubernetes.client.ApiClient.execute(ApiClient.java:798)
at io.kubernetes.client.apis.ExtensionsV1beta1Api.deleteNamespacedDeploymentWithHttpInfo(ExtensionsV1beta1Api.java:2440)
at io.kubernetes.client.apis.ExtensionsV1beta1Api.deleteNamespacedDeployment(ExtensionsV1beta1Api.java:2420)

Caused by: java.lang.IllegalStateException: Expected a string but was BEGIN_OBJECT at line 1 column 1611 path $.status
at com.google.gson.stream.JsonReader.nextString(JsonReader.java:831)
at com.google.gson.internal.bind.TypeAdapters$16.read(TypeAdapters.java:422)
at com.google.gson.internal.bind.TypeAdapters$16.read(TypeAdapters.java:410)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:116)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:216)
... 12 more

Any idea what is the issue

@brendandburns
Copy link
Contributor

This is a duplicate of #86

That issue has the details, basically Kubernetes can return either Status or Object when deleting something and the Swagger/Java client can't handle multi-type return...

Closing as duplicate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants