From 1652e59c9b3ad817c336cb089527e6ca672e0cae Mon Sep 17 00:00:00 2001 From: Haowei Cai Date: Wed, 19 May 2021 17:05:42 -0700 Subject: [PATCH 1/2] mark ContainerImage.names as optional kubelet is the only writer of v1.Node .status.images[].names. When an image has neither RepoDigests nor RepoTags, the value gets stored in etcd as null. Marking the field as optional can help JSON API clients to avoid hitting serialization error when the returned status contains null .status.images[].names. --- pkg/apis/core/types.go | 1 + staging/src/k8s.io/api/core/v1/types.go | 1 + 2 files changed, 2 insertions(+) diff --git a/pkg/apis/core/types.go b/pkg/apis/core/types.go index 43146537870..9a74daecce3 100644 --- a/pkg/apis/core/types.go +++ b/pkg/apis/core/types.go @@ -4206,6 +4206,7 @@ type PodSignature struct { // ContainerImage describe a container image type ContainerImage struct { // Names by which this image is known. + // +optional Names []string // The size of the image in bytes. // +optional diff --git a/staging/src/k8s.io/api/core/v1/types.go b/staging/src/k8s.io/api/core/v1/types.go index 6d98efa56bd..d5e86a7c7b8 100644 --- a/staging/src/k8s.io/api/core/v1/types.go +++ b/staging/src/k8s.io/api/core/v1/types.go @@ -4872,6 +4872,7 @@ type PodSignature struct { type ContainerImage struct { // Names by which this image is known. // e.g. ["k8s.gcr.io/hyperkube:v1.0.7", "dockerhub.io/google_containers/hyperkube:v1.0.7"] + // +optional Names []string `json:"names" protobuf:"bytes,1,rep,name=names"` // The size of the image in bytes. // +optional From dc8bc41f14686f9fb9b71b3d2561db70db035de3 Mon Sep 17 00:00:00 2001 From: Haowei Cai Date: Wed, 19 May 2021 17:50:52 -0700 Subject: [PATCH 2/2] generated --- api/openapi-spec/swagger.json | 3 --- staging/src/k8s.io/api/core/v1/generated.proto | 1 + 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/api/openapi-spec/swagger.json b/api/openapi-spec/swagger.json index 30f6d263c9c..88e1c443723 100644 --- a/api/openapi-spec/swagger.json +++ b/api/openapi-spec/swagger.json @@ -4937,9 +4937,6 @@ "type": "integer" } }, - "required": [ - "names" - ], "type": "object" }, "io.k8s.api.core.v1.ContainerPort": { diff --git a/staging/src/k8s.io/api/core/v1/generated.proto b/staging/src/k8s.io/api/core/v1/generated.proto index 940b150c51f..f7b44a6dc65 100644 --- a/staging/src/k8s.io/api/core/v1/generated.proto +++ b/staging/src/k8s.io/api/core/v1/generated.proto @@ -787,6 +787,7 @@ message Container { message ContainerImage { // Names by which this image is known. // e.g. ["k8s.gcr.io/hyperkube:v1.0.7", "dockerhub.io/google_containers/hyperkube:v1.0.7"] + // +optional repeated string names = 1; // The size of the image in bytes.