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

body type of patch_namespaced_config_map is not clear #2299

Closed
broken-dream opened this issue Oct 23, 2024 · 2 comments · Fixed by #2301
Closed

body type of patch_namespaced_config_map is not clear #2299

broken-dream opened this issue Oct 23, 2024 · 2 comments · Fixed by #2301
Labels
kind/documentation Categorizes issue or PR as related to documentation.

Comments

@broken-dream
Copy link
Contributor

broken-dream commented Oct 23, 2024

Link to the issue (please include a link to the specific documentation or example):
documentation for patch_namespaced_config_map

Description of the issue (please include outputs or screenshots if possible):
I want to update config map from python client. I implemented it according the example in homepage and the doc above:

from kubernetes import client, config
config.load_kube_config("my-kube-file-path")

v1 = client.CoreV1Api()
body = {"test_key": "test_value"}
v1.patch_namespaced_config_map(name="my-config-map", namespace="my-namespace", body=body)

No error occurred but the config map is not updated, which is very confusing. When searching solution, I found another implementation in this issue. I modified my code as follow:

from kubernetes import client, config
config.load_kube_config("my-kube-file-path")

v1 = client.CoreV1Api()
data = {"test_key": "test_value"}
namespace = "my-namespace"
object_meta = client.V1ObjectMeta(name="my-config-map", namespace=namespace)
body = client.V1ConfigMap(api_version="v1", kind="ConfigMap", metadata=object_meta, data=data)
v1.patch_namespaced_config_map(name="my-config-map", namespace=namespace, body=body)

then it worked.

I'm not sure whether my original implementation is correct, but I think the documentation should be more detailed or the API should raise exception when the body type is wrong.

my environment information:

  • k8s server version: 1.26.8
  • python client version: 31.0.0
@broken-dream broken-dream added the kind/documentation Categorizes issue or PR as related to documentation. label Oct 23, 2024
@roycaihw
Copy link
Member

The documentation is generated by the code generator from the openapi spec. Could you create an example (under https://github.com/kubernetes-client/python/tree/master/examples) of the patch based on this issue so it's easier for future users to refer to the example?

@mqray
Copy link

mqray commented Nov 13, 2024

it doesn't the solute this situation, modify cm with multi-level dict

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/documentation Categorizes issue or PR as related to documentation.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants