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

Exception when deleting namespaced pod #190

Closed
pires opened this issue Feb 16, 2018 · 5 comments
Closed

Exception when deleting namespaced pod #190

pires opened this issue Feb 16, 2018 · 5 comments

Comments

@pires
Copy link

pires commented Feb 16, 2018

Running Kubernetes 1.9.1 and a snapshot build of this repo as of 505a812, I get this when deleting a namespace pod:

Exception in thread "main" com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected a string but was BEGIN_OBJECT at line 1 column 4559 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:106)
	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.CoreV1Api.deleteNamespacedPodWithHttpInfo(CoreV1Api.java:13152)
	at io.kubernetes.client.apis.CoreV1Api.deleteNamespacedPod(CoreV1Api.java:13132)
	at pires.kubernetes.scheduler.KubernetesPlanCustomizer.drain(KubernetesPlanCustomizer.java:137)
	at pires.kubernetes.scheduler.KubernetesPlanCustomizer.drainKubeNode(KubernetesPlanCustomizer.java:78)
	at java.util.ArrayList.forEach(ArrayList.java:1257)
	at pires.kubernetes.scheduler.KubernetesPlanCustomizer.customizeDecommission(KubernetesPlanCustomizer.java:70)
	at pires.kubernetes.scheduler.KubernetesPlanCustomizer.updatePlan(KubernetesPlanCustomizer.java:48)
	at pires.scheduler.AbstractScheduler.start(AbstractScheduler.java:97)
	at pires.scheduler.SchedulerRunner.run(SchedulerRunner.java:118)
	at pires.kubernetes.scheduler.Main.main(Main.java:108)
Caused by: java.lang.IllegalStateException: Expected a string but was BEGIN_OBJECT at line 1 column 4559 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)
	... 17 more
@karthikkondapally
Copy link
Contributor

This is know issue #86 (comment)
This error may arise for all delete K8 objects.
as said in comment, you may wrap it in try catch.

@pires
Copy link
Author

pires commented Feb 16, 2018

Thank you!

@pires
Copy link
Author

pires commented Feb 16, 2018

Another option may be:

final Response response = apiClient.deleteNamespacedPodCall(pod.getMetadata().getName(), pod.getMetadata().getNamespace(), new V1DeleteOptions().gracePeriodSeconds(0L).propagationPolicy("Foreground"), null, null, null, null, null, null).execute();

if (!response.isSuccessful()) {
    LOGGER.warn("Couldn't delete pod [{}] with reason: {}", pod.getMetadata().getName(), response.message());
}

@brendandburns
Copy link
Contributor

Closing as a dup of #86

@icehehehe
Copy link

Another option may be:

final Response response = apiClient.deleteNamespacedPodCall(pod.getMetadata().getName(), pod.getMetadata().getNamespace(), new V1DeleteOptions().gracePeriodSeconds(0L).propagationPolicy("Foreground"), null, null, null, null, null, null).execute();

if (!response.isSuccessful()) {
    LOGGER.warn("Couldn't delete pod [{}] with reason: {}", pod.getMetadata().getName(), response.message());
}

This is very useful.I use the newest java-client with the parameter modified.Thank you! ! !

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

4 participants