Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Interaction with Custom Resource Objects failing #2380

Open
Labels
help wantedDenotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.kind/bugCategorizes issue or PR as related to a bug.
@sujeetkp

Description

@sujeetkp

What happened (please include outputs or screenshots):

I have create a CRD and a Custom Object. When I try to pull the Custom Resource Status or try to patch the Custom Resource status, the request fails with unable to find the resource.

What you expected to happen:

The request should find the Custom Requests and patch it.

How to reproduce it (as minimally and precisely as possible):

    import kubernetes    import os    def main():            print("Loading kube config...")        kubernetes.config.load_kube_config()        proxy_url = os.environ.get("HTTP_PROXY", os.environ.get("http_proxy", None))        kubernetes.client.Configuration._default.proxy = proxy_url        api_instance = kubernetes.client.CustomObjectsApi()        namespace = "default"                # Works        custom_api_response = api_instance.get_namespaced_custom_object(            group="example.com",            version="v1alpha1",            namespace=namespace,            plural="podrequests",            name="test-req",        )            print("Custom resource found: %s", custom_api_response)                # Fails        custom_api_response = api_instance.get_namespaced_custom_object_status(            group="example.com",            version="v1alpha1",            namespace=namespace,            plural="podrequests",            name="test-req",        )            patch = {"status": {"status": "complete"}}                 # Fails        response = api_instance.patch_namespaced_custom_object_status(            group="example.com",            version="v1alpha1",            namespace=namespace,            plural="podrequests",            name="test-req",            body=patch        )                if __name__ == "__main__":        main()
apiVersion: apiextensions.k8s.io/v1kind: CustomResourceDefinitionmetadata:  name: podrequests.example.comspec:  group: example.com  names:    kind: PodRequest    plural: podrequests    singular: podrequest    shortNames:      - podr  scope: Namespaced  versions:    - name: v1alpha1      served: true      storage: true      schema:        openAPIV3Schema:          type: object          properties:            spec:              type: object              properties:                podSpec:                  type: object                  x-kubernetes-preserve-unknown-fields: true                  description: "Full Kubernetes pod specification for machine creation"                count:                  type: integer                  description: "Number of machines to provision"            status:              type: object              properties:                status:                  type: string                  enum: [running, complete, complete_with_error]                  description: "Overall request status"                message:                  type: string                  description: "Additional status information"
apiVersion: example.com/v1alpha1kind: PodRequestmetadata:  name: "test-req"spec:  podSpec:    apiVersion: v1    kind: Pod    metadata:    spec:      containers:        - name: hello          image: xxxxxxxxxxxx:2025-02-01-02-04          command: ['sh', '-c', 'echo "Hello, Kubernetes!" && sleep infinity']  count: 1status:  status: running  message: "Request is being processed"
Loading kube config...Custom resource found: %s {'apiVersion': 'example.com/v1alpha1', 'kind': 'PodRequest', 'metadata': {'annotations': {'kubectl.kubernetes.io/last-applied-configuration': '{"apiVersion":"example.com/v1alpha1","kind":"PodRequest","metadata":{"annotations":{},"name":"test-req","namespace":"default"},"spec":{"count":1,"podSpec":{"apiVersion":"v1","kind":"Pod","metadata":null,"spec":{"containers":[{"command":["sh","-c","echo \\"Hello, Kubernetes!\\" \\u0026\\u0026 sleep infinity"],"image":"xxxxxxxxxxxx:2025-02-01-02-04","name":"hello"}]}}},"status":{"message":"Request is being processed","status":"running"}}\n'}, 'creationTimestamp': '2025-04-05T11:33:53Z', 'generation': 1, 'managedFields': [{'apiVersion': 'example.com/v1alpha1', 'fieldsType': 'FieldsV1', 'fieldsV1': {'f:metadata': {'f:annotations': {'.': {}, 'f:kubectl.kubernetes.io/last-applied-configuration': {}}}, 'f:spec': {'.': {}, 'f:count': {}, 'f:podSpec': {'.': {}, 'f:apiVersion': {}, 'f:kind': {}, 'f:spec': {'.': {}, 'f:containers': {}}}}, 'f:status': {'.': {}, 'f:message': {}, 'f:status': {}}}, 'manager': 'kubectl-client-side-apply', 'operation': 'Update', 'time': '2025-04-05T11:33:53Z'}], 'name': 'test-req', 'namespace': 'default', 'resourceVersion': '4505753', 'uid': 'fc01f9f7-a216-4378-9364-7af71423cbf7'}, 'spec': {'count': 1, 'podSpec': {'apiVersion': 'v1', 'kind': 'Pod', 'spec': {'containers': [{'command': ['sh', '-c', 'echo "Hello, Kubernetes!" && sleep infinity'], 'image': 'xxxxxxxxxxxx:2025-02-01-02-04', 'name': 'hello'}]}}}, 'status': {'message': 'Request is being processed', 'status': 'running'}}Traceback (most recent call last):  File "xxxxxxxxxxxxxxxxxxxxxxxxx/test_crd.py", line 36, in <module>    main()  File "xxxxxxxxxxxxxxxxxxxxxxxxx/test_crd.py", line 25, in main    response = api_instance.patch_namespaced_custom_object_status(               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/venv/lib/python3.12/site-packages/kubernetes/client/api/custom_objects_api.py", line 3530, in patch_namespaced_custom_object_status    return self.patch_namespaced_custom_object_status_with_http_info(group, version, namespace, plural, name, body, **kwargs)  # noqa: E501           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/venv/lib/python3.12/site-packages/kubernetes/client/api/custom_objects_api.py", line 3665, in patch_namespaced_custom_object_status_with_http_info    return self.api_client.call_api(           ^^^^^^^^^^^^^^^^^^^^^^^^^  File "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/venv/lib/python3.12/site-packages/kubernetes/client/api_client.py", line 348, in call_api    return self.__call_api(resource_path, method,           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/venv/lib/python3.12/site-packages/kubernetes/client/api_client.py", line 180, in __call_api    response_data = self.request(                    ^^^^^^^^^^^^^  File "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/venv/lib/python3.12/site-packages/kubernetes/client/api_client.py", line 407, in request    return self.rest_client.PATCH(url,           ^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/venv/lib/python3.12/site-packages/kubernetes/client/rest.py", line 299, in PATCH    return self.request("PATCH", url,           ^^^^^^^^^^^^^^^^^^^^^^^^^^  File "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/venv/lib/python3.12/site-packages/kubernetes/client/rest.py", line 238, in request    raise ApiException(http_resp=r)kubernetes.client.exceptions.ApiException: (404)Reason: Not FoundHTTP response headers: HTTPHeaderDict({'Audit-Id': '22068da1-ed18-498b-9a72-07847f0b2318', 'Cache-Control': 'no-cache, private', 'Content-Type': 'application/json', 'X-Kubernetes-Pf-Flowschema-Uid': 'c813a998-781a-4491-81e4-b4efd3dfb7dc', 'X-Kubernetes-Pf-Prioritylevel-Uid': '660d6ee5-e61e-4378-b46a-30a880e6213b', 'Date': 'Sat, 05 Apr 2025 11:43:10 GMT', 'Content-Length': '232'})HTTP response body: {"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"podrequests.example.com \"test-req\" not found","reason":"NotFound","details":{"name":"test-req","group":"example.com","kind":"podrequests"},"code":404}

Anything else we need to know?:

Environment:

  • Kubernetes version (kubectl version):
Client Version: v1.31.2Kustomize Version: v5.4.2Server Version: v1.31.6-eks-bc803b4
  • OS (e.g., MacOS 10.13.6):
    Red Hat Enterprise Linux release 8.10

  • Python version (python --version)
    Python 3.12.7

  • Python client version (pip list | grep kubernetes)
    kubernetes 32.0.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedDenotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.kind/bugCategorizes issue or PR as related to a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp