Merge pull request #3574 from chaunceyjiang/podinitContainers
feat: supports aggregating the status of a pod's initContainer
This commit is contained in:
commit
8045da4596
|
@ -385,6 +385,13 @@ func aggregatePodStatus(object *unstructured.Unstructured, aggregatedStatusItems
|
||||||
}
|
}
|
||||||
newStatus.ContainerStatuses = append(newStatus.ContainerStatuses, tempStatus)
|
newStatus.ContainerStatuses = append(newStatus.ContainerStatuses, tempStatus)
|
||||||
}
|
}
|
||||||
|
for _, initContainerStatus := range temp.InitContainerStatuses {
|
||||||
|
tempStatus := corev1.ContainerStatus{
|
||||||
|
Ready: initContainerStatus.Ready,
|
||||||
|
State: initContainerStatus.State,
|
||||||
|
}
|
||||||
|
newStatus.InitContainerStatuses = append(newStatus.InitContainerStatuses, tempStatus)
|
||||||
|
}
|
||||||
klog.V(3).Infof("Grab pod(%s/%s) status from cluster(%s), phase: %s", pod.Namespace,
|
klog.V(3).Infof("Grab pod(%s/%s) status from cluster(%s), phase: %s", pod.Namespace,
|
||||||
pod.Name, item.ClusterName, temp.Phase)
|
pod.Name, item.ClusterName, temp.Phase)
|
||||||
}
|
}
|
||||||
|
|
|
@ -411,6 +411,36 @@ func TestAggregatePodStatus(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
newInitContainerStatuses1 := []corev1.ContainerStatus{
|
||||||
|
{
|
||||||
|
Ready: false,
|
||||||
|
State: corev1.ContainerState{
|
||||||
|
Waiting: &corev1.ContainerStateWaiting{Reason: "PodInitializing"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Ready: false,
|
||||||
|
State: corev1.ContainerState{
|
||||||
|
Running: &corev1.ContainerStateRunning{
|
||||||
|
StartedAt: metav1.Time{
|
||||||
|
Time: timeNow,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
newInitContainerObj, _ := helper.ToUnstructured(&corev1.Pod{Status: corev1.PodStatus{
|
||||||
|
InitContainerStatuses: newInitContainerStatuses1,
|
||||||
|
Phase: corev1.PodPending,
|
||||||
|
}})
|
||||||
|
initContainerStatusMap1 := map[string]interface{}{
|
||||||
|
"initContainerStatuses": []corev1.ContainerStatus{newInitContainerStatuses1[0], newInitContainerStatuses1[1]},
|
||||||
|
"phase": corev1.PodPending,
|
||||||
|
}
|
||||||
|
initContainerRaw1, _ := helper.BuildStatusRawExtension(initContainerStatusMap1)
|
||||||
|
aggregatedInitContainerStatusItems1 := []workv1alpha2.AggregatedStatusItem{
|
||||||
|
{ClusterName: "member1", Status: initContainerRaw1, Applied: true},
|
||||||
|
}
|
||||||
|
|
||||||
curObj, _ := helper.ToUnstructured(&corev1.Pod{})
|
curObj, _ := helper.ToUnstructured(&corev1.Pod{})
|
||||||
newObj, _ := helper.ToUnstructured(&corev1.Pod{Status: corev1.PodStatus{
|
newObj, _ := helper.ToUnstructured(&corev1.Pod{Status: corev1.PodStatus{
|
||||||
|
@ -584,6 +614,12 @@ func TestAggregatePodStatus(t *testing.T) {
|
||||||
aggregatedStatusItems []workv1alpha2.AggregatedStatusItem
|
aggregatedStatusItems []workv1alpha2.AggregatedStatusItem
|
||||||
expectedObj *unstructured.Unstructured
|
expectedObj *unstructured.Unstructured
|
||||||
}{
|
}{
|
||||||
|
{
|
||||||
|
name: "update initContainer status",
|
||||||
|
curObj: curObj,
|
||||||
|
aggregatedStatusItems: aggregatedInitContainerStatusItems1,
|
||||||
|
expectedObj: newInitContainerObj,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "update pod status",
|
name: "update pod status",
|
||||||
curObj: curObj,
|
curObj: curObj,
|
||||||
|
|
Loading…
Reference in New Issue