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