Merge pull request #125991 from xuzhenglun/fix-watch-rc-panic
fix panic when watching ReplicationController with Bookmark enabled
This commit is contained in:
		| @@ -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)) | ||||
| 	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)) | ||||
| 	} | ||||
| 	return []metav1.TableRow{row}, nil | ||||
|   | ||||
| @@ -4666,6 +4666,19 @@ func TestPrintReplicationController(t *testing.T) { | ||||
| 			// 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"}}}, | ||||
| 		}, | ||||
| 		{ | ||||
| 			// 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 { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Kubernetes Prow Robot
					Kubernetes Prow Robot