kubelet now returns PodConditions based on aciState (#147)
Fix for https://github.com/virtual-kubelet/virtual-kubelet/issues/136
This commit is contained in:
@@ -810,11 +810,9 @@ func containerGroupToPod(cg *aci.ContainerGroup) (*v1.Pod, error) {
|
||||
Volumes: []v1.Volume{},
|
||||
Containers: containers,
|
||||
},
|
||||
// TODO: Make this dynamic, likely can translate the provisioningState or instanceView.ContainerState into a Phase,
|
||||
// and some of the Events into Conditions
|
||||
Status: v1.PodStatus{
|
||||
Phase: aciStateToPodPhase(aciState),
|
||||
Conditions: []v1.PodCondition{},
|
||||
Conditions: aciStateToPodConditions(aciState, podCreationTimestamp),
|
||||
Message: "",
|
||||
Reason: "",
|
||||
HostIP: "",
|
||||
@@ -850,6 +848,28 @@ func aciStateToPodPhase(state string) v1.PodPhase {
|
||||
return v1.PodUnknown
|
||||
}
|
||||
|
||||
func aciStateToPodConditions(state string, transitiontime metav1.Time) []v1.PodCondition {
|
||||
switch state {
|
||||
case "Running", "Succeeded":
|
||||
return []v1.PodCondition{
|
||||
v1.PodCondition{
|
||||
Type: v1.PodReady,
|
||||
Status: v1.ConditionTrue,
|
||||
LastTransitionTime: transitiontime,
|
||||
}, v1.PodCondition{
|
||||
Type: v1.PodInitialized,
|
||||
Status: v1.ConditionTrue,
|
||||
LastTransitionTime: transitiontime,
|
||||
}, v1.PodCondition{
|
||||
Type: v1.PodScheduled,
|
||||
Status: v1.ConditionTrue,
|
||||
LastTransitionTime: transitiontime,
|
||||
},
|
||||
}
|
||||
}
|
||||
return []v1.PodCondition{}
|
||||
}
|
||||
|
||||
func aciContainerStateToContainerState(cs aci.ContainerState) v1.ContainerState {
|
||||
startTime := metav1.NewTime(time.Time(cs.StartTime))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user