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

Cannot delete pod forcibly with CoreV1API_deleteNamespacedPod API #158

Closed
privmc opened this issue Nov 10, 2022 · 3 comments · Fixed by #160
Closed

Cannot delete pod forcibly with CoreV1API_deleteNamespacedPod API #158

privmc opened this issue Nov 10, 2022 · 3 comments · Fixed by #160

Comments

@privmc
Copy link

privmc commented Nov 10, 2022

To delete a pod forcibly you need to set gracePeriodSeconds to zero. zero means delete immediately.

Example:

DELETE /api/v1/namespaces/{namespace}/pods/{name}?gracePeriodSeconds=0

However, if calling CoreV1API_deleteNamespacedPod with the gracePeriodSeconds parameter set to 0 the gracePeriodSeconds query parameter is not created in the HTTP request.

@ityuhui
Copy link
Member

ityuhui commented Nov 11, 2022

Yes. it's a problem. Now, can you set a small value such as gracePeriodSeconds=1 to walkaround this ?

Later, I want to fix this issue by introducing a magic number for the undefined integer parameter in openapi-generator.

e.g.

#define INT_UNDEFINED -9997
or
#define INT_UNDEFINED INT_MIN // INT_MIN is defined in <limits.h>

...
    if (gracePeriodSeconds != INT_UNDEFINED)  // the current code is `if (gracePeriodSeconds)`
    {
        keyQuery_gracePeriodSeconds = strdup("gracePeriodSeconds");
        valueQuery_gracePeriodSeconds = calloc(1,MAX_NUMBER_LENGTH);
        snprintf(valueQuery_gracePeriodSeconds, MAX_NUMBER_LENGTH, "%d", gracePeriodSeconds);
        keyPairQuery_gracePeriodSeconds = keyValuePair_create(keyQuery_gracePeriodSeconds, valueQuery_gracePeriodSeconds);
        list_addElement(localVarQueryParameters,keyPairQuery_gracePeriodSeconds);
    }
...

cc @brendandburns @wing328 @zhemant @michelealbano

@privmc
Copy link
Author

privmc commented Nov 11, 2022

Ok, thanks for the confirmation.

gracePeriodSeconds=1 does not work in my test.

If I do "kubectl delete pod " when the pod is in Running phase the kubectl commands hangs until the pod is forcibly deleted by sending a Pod delete with gracePeriodSeconds=0.

@ityuhui
Copy link
Member

ityuhui commented Nov 14, 2022

Got it.

If you need a fix now, apply the patch below and build yourself please.

diff --git a/kubernetes/api/CoreV1API.c b/kubernetes/api/CoreV1API.c
index 0dff85d..cb0ce55 100644
--- a/kubernetes/api/CoreV1API.c
+++ b/kubernetes/api/CoreV1API.c
@@ -16088,7 +16088,6 @@ CoreV1API_deleteNamespacedPod(apiClient_t *apiClient, char * name , char * _name
     char *keyQuery_gracePeriodSeconds = NULL;
     char * valueQuery_gracePeriodSeconds = NULL;
     keyValuePair_t *keyPairQuery_gracePeriodSeconds = 0;
-    if (gracePeriodSeconds)
     {
         keyQuery_gracePeriodSeconds = strdup("gracePeriodSeconds");
         valueQuery_gracePeriodSeconds = calloc(1,MAX_NUMBER_LENGTH);

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

Successfully merging a pull request may close this issue.

2 participants