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

Commit

Permalink
GetCondition func fix (#114)
Browse files Browse the repository at this point in the history
* GetCondition func fix

* v1beta1 fix
  • Loading branch information
johnugeorge authored and k8s-ci-robot committed Dec 19, 2018
1 parent d3c6541 commit ebf3318
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
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

0 comments on commit ebf3318

Please sign in to comment.