Skip to content

Exist bug in function v1_container_status_convertToJSON #262

Open
@vinnie6seu

Description

@vinnie6seu

After calling the CoreV1API_readNamespacedPod function to query the specified POD, pass the returned result v1_pod_t to the v1_pod_convertToJSON function to convert it into a JSON structure, return NULL.

The reason is that there is a field container_statuses.restart_count in the v1_pod_t structure, which causes the conversion to a JSON string to fail.

The JSON response obtained from the execution of the CoreV1API_readNamespacedPod function is as follows:
{
"kind": "Pod",
"apiVersion": "v1",
"metadata": {
"name": "my-pod",
"namespace": "default",
"uid": "4d1feefd-b58e-44cd-a6af-cc7a13fe562a",
"resourceVersion": "19586013",
"creationTimestamp": "2025-02-08T06:26:43Z",
"managedFields": [{
"manager": "unknown",
"operation": "Update",
"apiVersion": "v1",
"time": "2025-02-08T06:26:43Z",
"fieldsType": "FieldsV1",
"fieldsV1": {
"f:spec": {
"f:containers": {
"k:{"name":"my-container"}": {
".": {},
"f:image": {},
"f:imagePullPolicy": {},
"f:name": {},
"f:resources": {},
"f:terminationMessagePath": {},
"f:terminationMessagePolicy": {}
}
},
"f:dnsPolicy": {},
"f:enableServiceLinks": {},
"f:restartPolicy": {},
"f:schedulerName": {},
"f:securityContext": {},
"f:terminationGracePeriodSeconds": {}
}
}
}, {
"manager": "kubelet",
"operation": "Update",
"apiVersion": "v1",
"time": "2025-02-08T06:26:44Z",
"fieldsType": "FieldsV1",
"fieldsV1": {
"f:status": {
"f:conditions": {
"k:{"type":"ContainersReady"}": {
".": {},
"f:lastProbeTime": {},
"f:lastTransitionTime": {},
"f:status": {},
"f:type": {}
},
"k:{"type":"Initialized"}": {
".": {},
"f:lastProbeTime": {},
"f:lastTransitionTime": {},
"f:status": {},
"f:type": {}
},
"k:{"type":"Ready"}": {
".": {},
"f:lastProbeTime": {},
"f:lastTransitionTime": {},
"f:status": {},
"f:type": {}
}
},
"f:containerStatuses": {},
"f:hostIP": {},
"f:phase": {},
"f:podIP": {},
"f:podIPs": {
".": {},
"k:{"ip":"10.244.5.190"}": {
".": {},
"f:ip": {}
}
},
"f:startTime": {}
}
},
"subresource": "status"
}]
},
"spec": {
"volumes": [{
"name": "kube-api-access-bszt4",
"projected": {
"sources": [{
"serviceAccountToken": {
"expirationSeconds": 3607,
"path": "token"
}
}, {
"configMap": {
"name": "kube-root-ca.crt",
"items": [{
"key": "ca.crt",
"path": "ca.crt"
}]
}
}, {
"downwardAPI": {
"items": [{
"path": "namespace",
"fieldRef": {
"apiVersion": "v1",
"fieldPath": "metadata.namespace"
}
}]
}
}],
"defaultMode": 420
}
}],
"containers": [{
"name": "my-container",
"image": "docker.io/library/nginx:latest",
"resources": {},
"volumeMounts": [{
"name": "kube-api-access-bszt4",
"readOnly": true,
"mountPath": "/var/run/secrets/kubernetes.io/serviceaccount"
}],
"terminationMessagePath": "/dev/termination-log",
"terminationMessagePolicy": "File",
"imagePullPolicy": "IfNotPresent"
}],
"restartPolicy": "Always",
"terminationGracePeriodSeconds": 30,
"dnsPolicy": "ClusterFirst",
"serviceAccountName": "default",
"serviceAccount": "default",
"nodeName": "node5",
"securityContext": {},
"schedulerName": "default-scheduler",
"tolerations": [{
"key": "node.kubernetes.io/not-ready",
"operator": "Exists",
"effect": "NoExecute",
"tolerationSeconds": 300
}, {
"key": "node.kubernetes.io/unreachable",
"operator": "Exists",
"effect": "NoExecute",
"tolerationSeconds": 300
}],
"priority": 0,
"enableServiceLinks": true,
"preemptionPolicy": "PreemptLowerPriority"
},
"status": {
"phase": "Running",
"conditions": [{
"type": "Initialized",
"status": "True",
"lastProbeTime": null,
"lastTransitionTime": "2025-02-08T06:26:43Z"
}, {
"type": "Ready",
"status": "True",
"lastProbeTime": null,
"lastTransitionTime": "2025-02-08T06:26:44Z"
}, {
"type": "ContainersReady",
"status": "True",
"lastProbeTime": null,
"lastTransitionTime": "2025-02-08T06:26:44Z"
}, {
"type": "PodScheduled",
"status": "True",
"lastProbeTime": null,
"lastTransitionTime": "2025-02-08T06:26:43Z"
}],
"hostIP": "172.21.243.49",
"podIP": "10.244.5.190",
"podIPs": [{
"ip": "10.244.5.190"
}],
"startTime": "2025-02-08T06:26:43Z",
"containerStatuses": [{
"name": "my-container",
"state": {
"running": {
"startedAt": "2025-02-08T06:26:44Z"
}
},
"lastState": {},
"ready": true,
"restartCount": 0,
"image": "docker.io/library/nginx:latest",
"imageID": "docker.io/library/import-2024-12-05@sha256:112b2cdc904bf7befbfe50544c954ac4f6996b70f7ff9e759525802a7d27834e",
"containerID": "containerd://cf06dda13b21b2d58f5db5bd2bba02a04dbdb8746d8255d000ed2a28db5d3e50",
"started": true
}],
"qosClass": "BestEffort"
}
}

The problematic code is v1_container_status:225.

Metadata

Metadata

Assignees

No one assigned

    Labels

    lifecycle/rottenDenotes an issue or PR that has aged beyond stale and will be auto-closed.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions