Skip to content

sanitize_for_serialization returns empty Dict when all values are None #1846

Closed as not planned

Description

@Uranium2

What happened:
I'm trying to monitor my Jobs with read_namespaced_job_status and return the status in Dict/Json format. When I create the Job and get it's status just after (under 5/10 seconds before real creation on Cluster) I get a status of Dict where all values are None, which is fine. But when I try to sanitize_for_serialization it, I get an empty Dict.

> from kubernetes import client
> from kubernetes.client import ApiClient

> batch_v1 = client.BatchV1Api()
> api_response = batch_v1.read_namespaced_job_status(name="job-1", namespace="my-namespace")
> print(api_response)
{'active': None,
 'completed_indexes': None,
 'completion_time': None,
 'conditions': None,
 'failed': None,
 'ready': None,
 'start_time': None,
 'succeeded': None,
 'uncounted_terminated_pods': None}
> api = ApiClient()
> api_response_status_dict = api.sanitize_for_serialization(api_response.status)
> print(api_response_status_dict)
{}

What you expected to happen:
I expected api_response_status_dict to be a non empty Dict, with all keys and with values to None.

Environment:

  • Kubernetes version: v1.23.5
  • OS : Ubuntu 20.04.3 LTS (WSL1)
  • Python version : Python 3.8.10
  • Python client version: 23.3.0

Activity

  1. added
    kind/bug
    on Jun 28, 2022
  2. k8s-triage-robot commented on Sep 26, 2022

    @k8s-triage-robot

    The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

    This bot triages issues and PRs according to the following rules:

    • After 90d of inactivity, lifecycle/stale is applied
    • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
    • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

    You can:

    • Mark this issue or PR as fresh with /remove-lifecycle stale
    • Mark this issue or PR as rotten with /lifecycle rotten
    • Close this issue or PR with /close
    • Offer to help out with Issue Triage

    Please send feedback to sig-contributor-experience at kubernetes/community.

    /lifecycle stale

  3. added
    lifecycle/stale
    on Sep 26, 2022
  4. k8s-triage-robot commented on Oct 26, 2022

    @k8s-triage-robot

    The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

    This bot triages issues and PRs according to the following rules:

    • After 90d of inactivity, lifecycle/stale is applied
    • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
    • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

    You can:

    • Mark this issue or PR as fresh with /remove-lifecycle rotten
    • Close this issue or PR with /close
    • Offer to help out with Issue Triage

    Please send feedback to sig-contributor-experience at kubernetes/community.

    /lifecycle rotten

  5. added
    lifecycle/rotten
    and removed
    lifecycle/stale
    on Oct 26, 2022
  6. k8s-triage-robot commented on Nov 25, 2022

    @k8s-triage-robot

    The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

    This bot triages issues according to the following rules:

    • After 90d of inactivity, lifecycle/stale is applied
    • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
    • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

    You can:

    • Reopen this issue with /reopen
    • Mark this issue as fresh with /remove-lifecycle rotten
    • Offer to help out with Issue Triage

    Please send feedback to sig-contributor-experience at kubernetes/community.

    /close not-planned

  7. k8s-ci-robot commented on Nov 25, 2022

    @k8s-ci-robot
    Contributor

    @k8s-triage-robot: Closing this issue, marking it as "Not Planned".

    Details

    In response to this:

    The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

    This bot triages issues according to the following rules:

    • After 90d of inactivity, lifecycle/stale is applied
    • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
    • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

    You can:

    • Reopen this issue with /reopen
    • Mark this issue as fresh with /remove-lifecycle rotten
    • Offer to help out with Issue Triage

    Please send feedback to sig-contributor-experience at kubernetes/community.

    /close not-planned

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/buglifecycle/rotten

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions