Skip to content

Commit

Permalink
[v1alpha2]update tfjob condition for Created (kubeflow#694)
Browse files Browse the repository at this point in the history
* [v1alpha2]update tfjob condition for Created

* update ci
  • Loading branch information
yph152 authored and k8s-ci-robot committed Jun 22, 2018
1 parent 240be05 commit 2d88819
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/controller.v2/controller_tfjob.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ func (tc *TFJobController) addTFJob(obj interface{}) {
return
}

// Convert from tfjob object
err = unstructuredFromTFJob(obj, tfJob)
if err != nil {
log.Error("Failed to convert the obj: %v", err)
return
}
tc.enqueueTFJob(obj)
}

Expand Down
17 changes: 17 additions & 0 deletions pkg/controller.v2/informer.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,20 @@ func tfJobFromUnstructured(obj interface{}) (*tfv1alpha2.TFJob, error) {
}
return &tfjob, nil
}

func unstructuredFromTFJob(obj interface{}, tfJob *tfv1alpha2.TFJob) error {
un, ok := obj.(*metav1unstructured.Unstructured)
if !ok {
log.Warn("The objetc in index is not an unstructured")
return errGetFromKey
}

var err error
un.Object, err = runtime.DefaultUnstructuredConverter.ToUnstructured(tfJob)
if err != nil {
log.Error("The TFJob connvert failed")
return err
}
return nil

}

0 comments on commit 2d88819

Please sign in to comment.