[FIX] InitContainers has nil element

This commit is contained in:
GLYASAI 2019-08-24 14:55:08 +08:00
parent b290761743
commit 7d02944bdf
2 changed files with 4 additions and 9 deletions

View File

@ -1087,7 +1087,3 @@ func checkActionFinish(serviceID string, optTypes ...string) bool {
func parseLabels(labels map[string]string) (string, string, string, string) {
return labels["tenant_id"], labels["service_id"], labels["version"], labels["creater_id"]
}
func recordUpdateEvent(old, new *corev1.Pod) {
}

View File

@ -60,7 +60,7 @@ func (r *RuntimeServer) GetPodDetail(ctx context.Context, req *pb.GetPodDetailRe
podDetail.Events = append(podDetail.Events, events...)
}
if len(pod.Spec.InitContainers) == 0 {
if len(pod.Spec.InitContainers) != 0 {
describeContainers(pod.Spec.InitContainers, pod.Status.InitContainerStatuses, &podDetail.InitContainers)
}
describeContainers(pod.Spec.Containers, pod.Status.ContainerStatuses, &podDetail.Containers)
@ -128,8 +128,7 @@ func describeContainers(containers []corev1.Container, containerStatuses []corev
statuses[status.Name] = status
}
var pcs []*pb.PodContainer
for _, container := range containers {
for idx, container := range containers {
status, ok := statuses[container.Name]
pc := &pb.PodContainer{
Image: container.Image,
@ -138,9 +137,9 @@ func describeContainers(containers []corev1.Container, containerStatuses []corev
describeContainerState(status, pc)
}
describeContainerResource(container, pc)
pcs = append(pcs, pc)
pcs := *podContainers
pcs[idx] = pc
}
*podContainers = pcs
}
func describeContainerState(status corev1.ContainerStatus, podContainer *pb.PodContainer) {