-
Notifications
You must be signed in to change notification settings - Fork 48
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
Different return types of Delete Pod #31
Comments
This code is generated, so unfortunately we really can't do this. This is basically a fundamental disconnect between the implementation of the Kubernetes API (which as you note, can return multiple different types) and the Swagger/OpenAPI document for the API (which only describes one type) There's a much larger discussion of the issue here: |
In the current situation, if CoreV1API_deleteNamespacedPod() succeeds, app got a segfault. |
Hi @clearday4 Which case will trigger a segfault by Case 1: Deleting succeeded ( e.g. The pod that will be deleted is valid) Or |
Hi |
When deleting pod succeeds, So, this segfault can be avoided by below gurad: void delete_a_pod(apiClient_t * apiClient)
{
v1_status_t *status = CoreV1API_deleteNamespacedPod(apiClient,
"test-pod-6", // char *name
"default", // char *namespace
NULL, // char *pretty
NULL, // char *dryRun
0, // int gracePeriodSeconds
0, // int orphanDependents
NULL, // char *propagationPolicy
NULL // v1_delete_options_t *body
);
printf("The return code of HTTP request=%ld\n", apiClient->response_code);
if ( 200 == apiClient->response_code ||
202 == apiClient->response_code) {
printf("delete pod succeed\n");
} else {
if (status && status->message) {
printf("error message: %s\n", status->message);
}
}
} As @brendandburns said, the parsing is generated according to Swagger doc. It's not easy to update by manual. |
Thank you for the opinion |
You can also use the generic delete: Which will return the raw JSON. |
closed |
When calling CoreV1API_deleteNamespacedPod() if there is an error, returns a pointer of v1_status_t type. but if it succeeds, it returns a pointer of v1_pod_t type.
The return type depends on the success / fail of the function call.
How can we handle this?
https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.19/#delete-pod-v1-core
According to the above link, v1_pod_t is returned when delete pod is success.
and v1_status_t is returned when delete collection of pod is success.
There is no mention of what structure type will be returned when delete command fails.
First, you need to change the return type of CoreV1API_deleteNamespacedPod() to v1_pod_t pointer type.
The text was updated successfully, but these errors were encountered: