@@ -25203,6 +25203,74 @@ func TestValidatePodResize(t *testing.T) {
25203
25203
new: mkPod(core.ResourceList{}, getResources("200m", "0", "1Gi", ""), podtest.SetOS(core.Windows)),
25204
25204
err: "Forbidden: windows pods cannot be resized",
25205
25205
},
25206
+ {
25207
+ test: "Pod with nil Resource field in Status",
25208
+ old: mkPod(core.ResourceList{}, getResources("100m", "0", "1Gi", ""), podtest.SetStatus(core.PodStatus{
25209
+ ContainerStatuses: []core.ContainerStatus{{
25210
+ ContainerID: "docker://numbers",
25211
+ Image: "nginx:alpine",
25212
+ Name: "main",
25213
+ Ready: true,
25214
+ Started: proto.Bool(true),
25215
+ Resources: nil,
25216
+ State: core.ContainerState{
25217
+ Running: &core.ContainerStateRunning{
25218
+ StartedAt: metav1.NewTime(time.Now()),
25219
+ },
25220
+ },
25221
+ }},
25222
+ })),
25223
+ new: mkPod(core.ResourceList{}, getResources("200m", "0", "1Gi", "")),
25224
+ err: "Forbidden: Pod running on node without support for resize",
25225
+ },
25226
+ {
25227
+ test: "Pod with non-nil Resources field in Status",
25228
+ old: mkPod(core.ResourceList{}, getResources("100m", "0", "1Gi", ""), podtest.SetStatus(core.PodStatus{
25229
+ ContainerStatuses: []core.ContainerStatus{{
25230
+ ContainerID: "docker://numbers",
25231
+ Image: "nginx:alpine",
25232
+ Name: "main",
25233
+ Ready: true,
25234
+ Started: proto.Bool(true),
25235
+ Resources: &core.ResourceRequirements{},
25236
+ State: core.ContainerState{
25237
+ Running: &core.ContainerStateRunning{
25238
+ StartedAt: metav1.NewTime(time.Now()),
25239
+ },
25240
+ },
25241
+ }},
25242
+ })),
25243
+ new: mkPod(core.ResourceList{}, getResources("200m", "0", "1Gi", "")),
25244
+ err: "",
25245
+ },
25246
+ {
25247
+ test: "Pod without running containers",
25248
+ old: mkPod(core.ResourceList{}, getResources("100m", "0", "1Gi", ""), podtest.SetStatus(core.PodStatus{
25249
+ ContainerStatuses: []core.ContainerStatus{},
25250
+ })),
25251
+ new: mkPod(core.ResourceList{}, getResources("200m", "0", "1Gi", "")),
25252
+ err: "",
25253
+ },
25254
+ {
25255
+ test: "Pod with containers which are not running yet",
25256
+ old: mkPod(core.ResourceList{}, getResources("100m", "0", "1Gi", ""), podtest.SetStatus(core.PodStatus{
25257
+ ContainerStatuses: []core.ContainerStatus{{
25258
+ ContainerID: "docker://numbers",
25259
+ Image: "nginx:alpine",
25260
+ Name: "main",
25261
+ Ready: true,
25262
+ Started: proto.Bool(true),
25263
+ Resources: &core.ResourceRequirements{},
25264
+ State: core.ContainerState{
25265
+ Waiting: &core.ContainerStateWaiting{
25266
+ Reason: "PodInitializing",
25267
+ },
25268
+ },
25269
+ }},
25270
+ })),
25271
+ new: mkPod(core.ResourceList{}, getResources("200m", "0", "1Gi", "")),
25272
+ err: "",
25273
+ },
25206
25274
}
25207
25275
25208
25276
for _, test := range tests {
0 commit comments