Skip to content
This repository was archived by the owner on Sep 19, 2022. It is now read-only.

GetCondition func fix #114

Merged
merged 2 commits into from
Dec 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions pkg/controller.v1beta1/pytorch/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,10 @@ func newCondition(conditionType common.JobConditionType, reason, message string)

// getCondition returns the condition with the provided type.
func getCondition(status common.JobStatus, condType common.JobConditionType) *common.JobCondition {
if len(status.Conditions) > 0 {
return &status.Conditions[len(status.Conditions)-1]
for _, condition := range status.Conditions {
if condition.Type == condType {
return &condition
}
}
return nil
}
Expand Down
6 changes: 4 additions & 2 deletions pkg/controller.v2/pytorch/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,10 @@ func newCondition(conditionType v1alpha2.PyTorchJobConditionType, reason, messag

// getCondition returns the condition with the provided type.
func getCondition(status v1alpha2.PyTorchJobStatus, condType v1alpha2.PyTorchJobConditionType) *v1alpha2.PyTorchJobCondition {
if len(status.Conditions) > 0 {
return &status.Conditions[len(status.Conditions)-1]
for _, condition := range status.Conditions {
if condition.Type == condType {
return &condition
}
}
return nil
}
Expand Down