Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upDelete from yaml #1197
Delete from yaml #1197
Conversation
Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.
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. I understand the commands that are listed here. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: DiptoChakrabarty The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Welcome @DiptoChakrabarty! |
Hey @DiptoChakrabarty |
Yes I have done it |
print(msg) | ||
|
||
|
||
class FailToCreateError(Exception): |
This comment has been minimized.
This comment has been minimized.
# convert group name from DNS subdomain format to | ||
# python class name convention | ||
group = "".join(word.capitalize() for word in group.split('.')) | ||
group = "".join(word.capitalize() for word in group.split('.')) |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
from kubernetes import client | ||
|
||
|
||
def delete_from_yaml( |
This comment has been minimized.
This comment has been minimized.
yliaog
Jul 13, 2020
Contributor
overall, what is the difference between this and create_from_yaml? could you please list the differences in the PR description? is it possible to reuse to avoid dups?
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
DiptoChakrabarty
Jul 28, 2020
Author
I have written the difference between the methods create_from_yaml and delete_from_yaml editing the PR description and also fixed the issues as stated earlier.
Signed-off-by: Nabarun Pal <[email protected]>
Reference: OpenAPITools/openapi-generator#5377 Signed-off-by: Nabarun Pal <[email protected]>
The upstream 1.16 API moved ahead due to [patch releases](https://github.com/kubernetes/sig-release/blob/master/releases/patch-releases.md). The logs are gathered from the upstream [CHANGELOG](https://raw.githubusercontent.com/kubernetes/kubernetes/master/CHANGELOG/CHANGELOG-1.16.md). Signed-off-by: Nabarun Pal <[email protected]>
Reference: #974 Signed-off-by: Nabarun Pal <[email protected]>
The implementation and tests were already picked up by the upstream OpenAPI generator [here](OpenAPITools/openapi-generator#5094). Patching in the tests here for correctness and clarity. Reference: #1073 Signed-off-by: Nabarun Pal <[email protected]>
Signed-off-by: Nabarun Pal <[email protected]>
Signed-off-by: Nabarun Pal <[email protected]>
Update from 49ec06096ebc4e092c1ebc2291bf18ccaac935af to fb86b8acb66830b098c691fa14f4e6edbf9f7317 Signed-off-by: Nabarun Pal <[email protected]>
Signed-off-by: Nabarun Pal <[email protected]>
The changes have been listed in the CHANGELOG and linked to the respective milestone pull requests. Signed-off-by: Nabarun Pal <[email protected]>
Update OpenAPI generator and the client
There has been no API changes between 1.16.11 and 1.16.14 Signed-off-by: Nabarun Pal <[email protected]>
Update upstream version to 1.16.14
please add some e2e testcases in https://github.com/kubernetes-client/python/blob/master/kubernetes/e2e_test/test_utils.py and update https://github.com/kubernetes-client/python/blob/master/kubernetes/utils/__init__.py |
@@ -0,0 +1,146 @@ | |||
import re |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
DiptoChakrabarty
Aug 24, 2020
Author
added the boilerplate and added tests also modifying delete_from_dict function
this parameter has no effect. | ||
Available parameters for creating <kind>: | ||
:param async_req bool | ||
:param bool include_uninitialized: If true, partially initialized |
This comment has been minimized.
This comment has been minimized.
API object (i.e. List, Service, etc). | ||
Input: | ||
k8s_client: an ApiClient object, initialized with the client args. | ||
data: a dictionary holding valid kubernetes objects |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
name = yml_document["metadata"]["name"] | ||
#call function to delete from namespace | ||
res = getattr(k8s_api,"delete_namespaced_{}".format(kind))( | ||
name=name,body=client.V1DeleteOptions(propagation_policy="Foreground", grace_period_seconds=5),**kwargs) |
This comment has been minimized.
This comment has been minimized.
roycaihw
Jul 30, 2020
Member
if we want to achieve parity with kubectl delete -f
, we should probably use Background policy by default with a Cascade option: https://github.com/kubernetes/kubernetes/blob/0c642b6ef01071219b9b9e34ad6d89cb9b4b1971/staging/src/k8s.io/kubectl/pkg/cmd/delete/delete.go#L304-L308
This comment has been minimized.
This comment has been minimized.
name = yml_document["metadata"]["name"] | ||
kwargs.pop('namespace', None) | ||
res = getattr(k8s_api,"delete_{}".format(kind))( | ||
name=name,body=client.V1DeleteOptions(propagation_policy="Foreground", grace_period_seconds=5),**kwargs) |
This comment has been minimized.
This comment has been minimized.
roycaihw
Jul 30, 2020
Member
A 200 response from a delete request doesn't guarantee the resource being deleted. We should wait until the resource is no longer visible from the server.
This comment has been minimized.
This comment has been minimized.
DiptoChakrabarty
Sep 4, 2020
Author
How should the e2e tests work for objects being deleted , after deletion if they are search (the object) it gets timed out resulting in an error ,however in the create_from_yaml tests in the end all resources are being deleted using multiple separate commands could we delete those using the delete_from_yaml method and that would be sufficient?
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
yliaog
Sep 7, 2020
Contributor
in e2e, after delete, try listing the object again, if it does not exist anymore, it means the object is successfully deleted.
To get auth plugin support for client certificates, ref. kubernetes-client/python-base#205
Update python base
psikka1
commented
Aug 4, 2020
•
@DiptoChakrabarty @roycaihw - Does the API support non-namespaced resources such as
I feel they should also be supported. Same seems to be the case with
Adding a check |
this PR has 2151 files changed, please rebase. |
DiptoChakrabarty commentedJul 7, 2020
•
edited
This is a method to delete kubernetes resources using the yaml files . It is similar to the method create_from_yaml but for deleting kubernetes resources .
It can be used to any type pf resource deployment , pod , service etc.
Fixes #940
Resolved issue for tests failing for python2.7
create_from_yaml creates kubernetes objects like deployments,serivces,ingress etc from the given yml files , the delete_from_yaml method can be used to remove/delete those objects from the same yml files in the given cluster for any namespace