diff --git a/pkg/controller.v1alpha3/consts/const.go b/pkg/controller.v1alpha3/consts/const.go index 35be3a0185f..ba97e9763ad 100644 --- a/pkg/controller.v1alpha3/consts/const.go +++ b/pkg/controller.v1alpha3/consts/const.go @@ -26,6 +26,8 @@ const ( LabelSuggestionTag = "suggestion" LabelSuggestionImageTag = "image" + + ReconcileErrorReason = "ReconcileError" ) var ( diff --git a/pkg/controller.v1alpha3/suggestion/suggestion_controller.go b/pkg/controller.v1alpha3/suggestion/suggestion_controller.go index 40e4fd9bffa..571d8103bde 100644 --- a/pkg/controller.v1alpha3/suggestion/suggestion_controller.go +++ b/pkg/controller.v1alpha3/suggestion/suggestion_controller.go @@ -26,6 +26,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" + "k8s.io/client-go/tools/record" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller" "sigs.k8s.io/controller-runtime/pkg/handler" @@ -37,6 +38,7 @@ import ( experimentsv1alpha3 "github.com/kubeflow/katib/pkg/apis/controller/experiments/v1alpha3" suggestionsv1alpha3 "github.com/kubeflow/katib/pkg/apis/controller/suggestions/v1alpha3" trialsv1alpha3 "github.com/kubeflow/katib/pkg/apis/controller/trials/v1alpha3" + "github.com/kubeflow/katib/pkg/controller.v1alpha3/consts" "github.com/kubeflow/katib/pkg/controller.v1alpha3/suggestion/composer" "github.com/kubeflow/katib/pkg/controller.v1alpha3/suggestion/suggestionclient" "github.com/kubeflow/katib/pkg/controller.v1alpha3/util" @@ -61,6 +63,7 @@ func newReconciler(mgr manager.Manager) reconcile.Reconciler { SuggestionClient: suggestionclient.New(), scheme: mgr.GetScheme(), Composer: composer.New(mgr.GetScheme(), mgr.GetClient()), + recorder: mgr.GetRecorder(ControllerName), } } @@ -104,7 +107,8 @@ type ReconcileSuggestion struct { composer.Composer suggestionclient.SuggestionClient - scheme *runtime.Scheme + scheme *runtime.Scheme + recorder record.EventRecorder } // Reconcile reads that state of the cluster for a Suggestion object and makes changes based on the state read @@ -143,6 +147,8 @@ func (r *ReconcileSuggestion) Reconcile(request reconcile.Request) (reconcile.Re } else { err := r.ReconcileSuggestion(instance) if err != nil { + r.recorder.Eventf(instance, corev1.EventTypeWarning, + consts.ReconcileErrorReason, err.Error()) logger.Error(err, "Reconcile Suggestion error") return reconcile.Result{}, err } diff --git a/test/e2e/v1alpha3/run-e2e-experiment.go b/test/e2e/v1alpha3/run-e2e-experiment.go index f7887cb576e..7bd9d9dc3ca 100644 --- a/test/e2e/v1alpha3/run-e2e-experiment.go +++ b/test/e2e/v1alpha3/run-e2e-experiment.go @@ -111,10 +111,4 @@ func main() { } log.Printf("Experiment has recorded best current Optimal Trial %v", exp.Status.CurrentOptimalTrial) - err = kclient.DeleteExperiment(exp) - if err != nil { - log.Printf("CreateExperiment from YAML failed: %v", err) - return - } - log.Printf("Experiment %v deleted", exp.Name) } diff --git a/test/scripts/v1alpha3/run-suggestion-bayesian.sh b/test/scripts/v1alpha3/run-suggestion-bayesian.sh index 4e792ad14b4..d901592b12f 100755 --- a/test/scripts/v1alpha3/run-suggestion-bayesian.sh +++ b/test/scripts/v1alpha3/run-suggestion-bayesian.sh @@ -62,5 +62,6 @@ cd ${GO_DIR}/test/e2e/v1alpha3 echo "Running e2e skopt bayesian optimization experiment" export KUBECONFIG=$HOME/.kube/config go run run-e2e-experiment.go ../../../examples/v1alpha3/skopt-bayesian-optimization-example.yaml - +kubectl -n kubeflow describe suggestion +kubectl -n kubeflow delete experiment skopt-bayesian-optimization-example exit 0 diff --git a/test/scripts/v1alpha3/run-suggestion-grid.sh b/test/scripts/v1alpha3/run-suggestion-grid.sh index 61f646919fb..166642b5a85 100755 --- a/test/scripts/v1alpha3/run-suggestion-grid.sh +++ b/test/scripts/v1alpha3/run-suggestion-grid.sh @@ -62,5 +62,6 @@ cd ${GO_DIR}/test/e2e/v1alpha3 echo "Running e2e chocolate grid experiment" export KUBECONFIG=$HOME/.kube/config go run run-e2e-experiment.go ../../../examples/v1alpha3/chocolate-grid-example.yaml - +kubectl -n kubeflow describe suggestion +kubectl -n kubeflow delete experiment chocolate-grid-example exit 0 diff --git a/test/scripts/v1alpha3/run-suggestion-random.sh b/test/scripts/v1alpha3/run-suggestion-random.sh index 6956432150c..c3e55586b95 100755 --- a/test/scripts/v1alpha3/run-suggestion-random.sh +++ b/test/scripts/v1alpha3/run-suggestion-random.sh @@ -62,5 +62,6 @@ cd ${GO_DIR}/test/e2e/v1alpha3 echo "Running e2e hyperopt random experiment" export KUBECONFIG=$HOME/.kube/config go run run-e2e-experiment.go ../../../examples/v1alpha3/hyperopt-random-example.yaml - +kubectl -n kubeflow describe suggestion +kubectl -n kubeflow delete experiment hyperopt-random-example exit 0