Skip to content

fix(k8s): use call_api for patch_pvc — _headers and _content_type both unsupported - #1210

Open
shenshouer wants to merge 1 commit into
opensandbox-group:mainfrom
shenshouer:fix/pvc-owner-ref
Open

fix(k8s): use call_api for patch_pvc — _headers and _content_type both unsupported#1210
shenshouer wants to merge 1 commit into
opensandbox-group:mainfrom
shenshouer:fix/pvc-owner-ref

Conversation

@shenshouer

Copy link
Copy Markdown
Contributor

问题

_attach_pvc_owner_references 在给自动创建的 PVC 附加 ownerReferences 时失败,导致 K8s GC 无法级联删除 PVC。

修复历程

  1. _content_type -> 生产环境 kubernetes-client(旧版)不支持该参数
  2. _headers -> 同样不支持,旧版 OpenAPI 生成器不生成任何下划线参数
  3. ApiClient.call_api() + header_params + auth_settings -> 最终方案

call_api 是 kubernetes-client 最底层的方法,header_params 在所有版本中均受支持。需同时指定 auth_settings=['BearerToken'],否则请求以 system:anonymous 身份发送导致 403 Forbidden。

Fixes #1199

测试

tests/k8s/test_k8s_client.py ........... 43 passed

…h unsupported

生成的 patch_namespaced_persistent_volume_claim 方法在旧版 kubernetes-client 中既不支持 _content_type 也不支持 _headers 参数。

修复历程:
1. _content_type -> 生产环境 client 不支持(部署版本为 pre-OpenAPI-generator)
2. _headers -> 同样不支持,该类版本不生成任何下划线参数
3. ApiClient.call_api() + header_params + auth_settings -> 最终方案

call_api 是 kubernetes-client 最底层的方法,header_params 在所有版本
中均受支持。需同时指定 auth_settings=['BearerToken'] 否则请求以
system:anonymous 发送导致 403 Forbidden。

Fixes opensandbox-group#1199
@Pangjiping Pangjiping added the bug Something isn't working label Jul 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working component/server

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PVC ownerReferences not attached due to _content_type error in patch_pvc

2 participants