java icon indicating copy to clipboard operation
java copied to clipboard

deleteNamespacedService

Open Ljincheng0128 opened this issue 3 years ago • 3 comments
trafficstars

the code is:

        ApiClient client =
                ClientBuilder.kubeconfig(KubeConfig.loadKubeConfig(new FileReader("configaliyun"))).build();

        // set the global default api-client to the in-cluster one from above
        Configuration.setDefaultApiClient(client);

        // the CoreV1Api loads default api-client from global configuration.
        CoreV1Api api = new CoreV1Api();

        try {
            api.deleteNamespacedService("apinetwork-20220710233409-yodgtn","test",null,null,null,null,null,null);
        } catch (ApiException e) {
            e.printStackTrace();

            throw new GuliException(ResultCode.ERROR, ResponseMsg.DELETE_SERVICE_ERROR);
        }

but it throws an exception

Caused by: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 60 path $.status at com.google.gson.stream.JsonReader.beginObject(JsonReader.java:384) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:215) ... 34 more

Can you tell me how I need to find and fix this problem,thanks

Ljincheng0128 avatar Jul 10 '22 15:07 Ljincheng0128

What version of the client are you using? This sounds like:

https://github.com/kubernetes-client/java/issues/86

But it was fixed a while ago.

This can also be caused if your server in the kubeconfig is mis-configured so that you are not actually talking to Kubernetes.

brendandburns avatar Jul 11 '22 15:07 brendandburns

What version of the client are you using? This sounds like:

#86

But it was fixed a while ago.

This can also be caused if your server in the kubeconfig is mis-configured so that you are not actually talking to Kubernetes.

Thank you for your reply!The version of the kubernetes cluster is v1.20.6, and the kubernetes-client's version is 16.0.0 .The service has been deleted, but it throws this exception. So I caught this exception and thought it would not affect my subsequent work.

Ljincheng0128 avatar Jul 12 '22 04:07 Ljincheng0128

Yes, catching this exception should be fine. The basic problem is that delete can sometimes return the object that was deleted, and sometimes return a V1Status.

I thought we had fixed this, but apparently not in all cases.

Catching this exception and ignoring should be ok in this case.

brendandburns avatar Jul 22 '22 04:07 brendandburns

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot avatar Oct 20 '22 04:10 k8s-triage-robot

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

k8s-triage-robot avatar Nov 19 '22 05:11 k8s-triage-robot

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue with /reopen
  • Mark this issue as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close not-planned

k8s-triage-robot avatar Dec 19 '22 05:12 k8s-triage-robot

@k8s-triage-robot: Closing this issue, marking it as "Not Planned".

In response to this:

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue with /reopen
  • Mark this issue as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close not-planned

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

k8s-ci-robot avatar Dec 19 '22 05:12 k8s-ci-robot