mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-02 16:29:21 +00:00
fix panic when watching ReplicationController with AllowWatchBookmarks enabled
This commit is contained in:
parent
7127246344
commit
07198b90be
@ -1126,7 +1126,11 @@ func printReplicationController(obj *api.ReplicationController, options printers
|
|||||||
|
|
||||||
row.Cells = append(row.Cells, obj.Name, int64(desiredReplicas), int64(currentReplicas), int64(readyReplicas), translateTimestampSince(obj.CreationTimestamp))
|
row.Cells = append(row.Cells, obj.Name, int64(desiredReplicas), int64(currentReplicas), int64(readyReplicas), translateTimestampSince(obj.CreationTimestamp))
|
||||||
if options.Wide {
|
if options.Wide {
|
||||||
names, images := layoutContainerCells(obj.Spec.Template.Spec.Containers)
|
var containers []api.Container
|
||||||
|
if obj.Spec.Template != nil {
|
||||||
|
containers = obj.Spec.Template.Spec.Containers
|
||||||
|
}
|
||||||
|
names, images := layoutContainerCells(containers)
|
||||||
row.Cells = append(row.Cells, names, images, labels.FormatLabels(obj.Spec.Selector))
|
row.Cells = append(row.Cells, names, images, labels.FormatLabels(obj.Spec.Selector))
|
||||||
}
|
}
|
||||||
return []metav1.TableRow{row}, nil
|
return []metav1.TableRow{row}, nil
|
||||||
|
@ -4666,6 +4666,19 @@ func TestPrintReplicationController(t *testing.T) {
|
|||||||
// Columns: Name, Desired, Current, Ready, Age, Containers, Images, Selector
|
// Columns: Name, Desired, Current, Ready, Age, Containers, Images, Selector
|
||||||
expected: []metav1.TableRow{{Cells: []interface{}{"rc1", int64(5), int64(3), int64(1), "<unknown>", "test", "test_image", "a=b"}}},
|
expected: []metav1.TableRow{{Cells: []interface{}{"rc1", int64(5), int64(3), int64(1), "<unknown>", "test", "test_image", "a=b"}}},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
// make sure Bookmark event will not lead a panic
|
||||||
|
rc: api.ReplicationController{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Annotations: map[string]string{
|
||||||
|
metav1.InitialEventsAnnotationKey: "true",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
options: printers.GenerateOptions{Wide: true},
|
||||||
|
// Columns: Name, Desired, Current, Ready, Age, Containers, Images, Selector
|
||||||
|
expected: []metav1.TableRow{{Cells: []interface{}{"", int64(0), int64(0), int64(0), "<unknown>", "", "", "<none>"}}},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, test := range tests {
|
for i, test := range tests {
|
||||||
|
Loading…
Reference in New Issue
Block a user