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

Deleting pods fails because the server returns a Pod object instead of a Status object #145

Closed
qmfrederik opened this issue Apr 25, 2018 · 15 comments
Labels
lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.

Comments

@qmfrederik
Copy link
Contributor

When you delete a Pod, the server responds with a Pod object instead of a Status object.
The C# client tries to parse the Pod object as a Status object and fails.

This seems to be a general issue with the Swagger/OpenAPI definition of the Kubernetes API, see kubernetes/kubernetes#59501, kubernetes-client/java#86, kubernetes/kubernetes#25716, kubernetes/kubernetes#30537

Opening an issue here mainly to make it discoverable for others.

@qmfrederik
Copy link
Contributor Author

qmfrederik commented Apr 25, 2018

OK - so it took me some digging to find out that was discussed before in #44 and an attempt to mitigate this has been made in #46 & #47.

I don't think the API is very intuitive but you can do something like this:

public static async Task<object> SafeDeleteNamespacedPodAsync(this IKubernetes client, V1DeleteOptions body, string name, string namespaceParameter, int? gracePeriodSeconds = null, bool? orphanDependents = null, string propagationPolicy = null, string pretty = null, CancellationToken cancellationToken = default)
{
   var result = await client.DeleteNamespacedPodAsync(body, name, namespaceParameter, gracePeriodSeconds, orphanDependents, propagationPolicy, pretty, cancellationToken).ConfigureAwait(false);

    if (result.ApiVersion != null || !result.HasObject)
    {
        return result;
    }
    else
    {
        return result.ObjectView<V1Pod>();
    }
}

@tg123
Copy link
Member

tg123 commented Apr 25, 2018

the design wants to avoid returning an untyped object type.
I don't have any better idea,

@tintoy
Copy link
Contributor

tintoy commented Apr 25, 2018

@qmfrederik
Copy link
Contributor Author

@tintoy That makes sense, so the API could look like this:

Task<KubeObjectV1> DeleteNamespacedPodAsync(this IKubernetes client, V1DeleteOptions body, string name, string namespaceParameter, int? gracePeriodSeconds = null, bool? orphanDependents = null, string propagationPolicy = null, string pretty = null, CancellationToken cancellationToken = default)

And calling code would be something like:

var result = await DeleteNamespacedPodAsync(...);
if(result.Kind == "Pod")
{
    ...
}
else if(result.Kind == "Status")
{
    ...
}

The advantage of this over the current implementation is that the caller can use the Kind property to determine what object is being returned, and make a decision based on that.

@tintoy
Copy link
Contributor

tintoy commented Apr 26, 2018

Yep! Or if you're using newer C# versions you can use pattern matching :)

@hossambarakat
Copy link
Contributor

Should we close this issue since the pull request has been merged?

@brendandburns
Copy link
Contributor

I don't think that the Delete* code has been updated to return the parent type?

@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 Apr 24, 2019
@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 May 24, 2019
@fejta-bot
Copy link

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

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

@k8s-ci-robot
Copy link
Contributor

@fejta-bot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

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

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.

@qmfrederik
Copy link
Contributor Author

I don't think that the Delete* code has been updated to return the parent type?

Correct, this issue still persists.

@tg123 tg123 reopened this Jan 25, 2021
@tg123
Copy link
Member

tg123 commented Jan 25, 2021

reopen for investigation

@fejta-bot
Copy link

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-contributor-experience at kubernetes/community.
/close

@k8s-ci-robot
Copy link
Contributor

@fejta-bot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-contributor-experience at kubernetes/community.
/close

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.

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