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

RawCustomResourceOperationsImpl#delete should return a boolean value indicating deletion status #2781

Closed
rohanKanojia opened this issue Feb 3, 2021 · 0 comments · Fixed by #2820 or jenkinsci/kubernetes-client-api-plugin#83
Assignees
Labels
Milestone

Comments

@rohanKanojia
Copy link
Member

Right now we have these delete methods in API which seems to work okay but they fail with 404 in case resource is not present in the cluster:

public Map<String, Object> delete(String namespace) {
return makeCall(fetchUrl(namespace, null, null), null, HttpCallMethod.DELETE);
}
/**
* Delete all custom resources in a specific namespace
*
* @param namespace desired namespace
* @param cascading whether dependent object need to be orphaned or not. If true/false, the "orphan"
* finalizer will be added to/removed from the object's finalizers list.
* @return deleted objects as HashMap
* @throws IOException in case of any network/parsing exception
*/
public Map<String, Object> delete(String namespace, boolean cascading) throws IOException {
return makeCall(fetchUrl(namespace, null, null), objectMapper.writeValueAsString(fetchDeleteOptions(cascading, null)), HttpCallMethod.DELETE);
}
/**
* Delete all custom resources in a specific namespace
*
* @param namespace desired namespace
* @param deleteOptions object provided by Kubernetes API for more fine grained control over deletion.
* For more information please see https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.16/#deleteoptions-v1-meta
* @return deleted object as HashMap
* @throws IOException in case of any network/object parse problems
*/
public Map<String, Object> delete(String namespace, DeleteOptions deleteOptions) throws IOException {
return makeCall(fetchUrl(namespace, null, null), objectMapper.writeValueAsString(deleteOptions), HttpCallMethod.DELETE);
}
/**
* Delete a custom resource in a specific namespace
*

We discovered this behavior in one of the issues[0] on Eclipse JKube. I think we should align this behavior with standard deletion API's to return false if resource requested for deletion doesn't exist in server:

} catch (KubernetesClientException e) {
if (e.getCode() != HttpURLConnection.HTTP_NOT_FOUND) {
throw e;
}
return false;

[0] eclipse-jkube/jkube#534

@manusa manusa added the bug label Feb 3, 2021
@manusa manusa added this to the 5.1.0 milestone Feb 3, 2021
@manusa manusa modified the milestones: 5.1.0, 5.2.0 Feb 17, 2021
@rohanKanojia rohanKanojia self-assigned this Feb 18, 2021
rohanKanojia added a commit to rohanKanojia/kubernetes-client that referenced this issue Feb 19, 2021
…urn a boolean value

Align RawCustomResource delete API to return a boolean value indicating
status for deletion just like we have in regular DSL. Right now we're
just throwing an exception in case item doesn't exist in server.
rohanKanojia added a commit to rohanKanojia/kubernetes-client that referenced this issue Feb 22, 2021
…urn a boolean value

Align RawCustomResource delete API to return a boolean value indicating
status for deletion just like we have in regular DSL. Right now we're
just throwing an exception in case item doesn't exist in server.
manusa pushed a commit that referenced this issue Mar 1, 2021
…lean value

Align RawCustomResource delete API to return a boolean value indicating
status for deletion just like we have in regular DSL. Right now we're
just throwing an exception in case item doesn't exist in server.
This was referenced Mar 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment