From c05f3a6709f4289bf418a5f64ef6bec8cd782b79 Mon Sep 17 00:00:00 2001 From: Rajadeepan D Ramesh Date: Tue, 18 Jun 2019 20:07:27 +0530 Subject: [PATCH] Adding Events for Action --- pkg/apis/batch/v1alpha1/job.go | 2 ++ pkg/controllers/job/job_controller.go | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/pkg/apis/batch/v1alpha1/job.go b/pkg/apis/batch/v1alpha1/job.go index e304ad195d..7ddf67aac0 100644 --- a/pkg/apis/batch/v1alpha1/job.go +++ b/pkg/apis/batch/v1alpha1/job.go @@ -112,6 +112,8 @@ const ( PVCError JobEvent = "PVCError" // PodGroupError pod grp error event is generated if error happens during pod grp creation PodGroupError JobEvent = "PodGroupError" + //ExecuteAction action issued event for each action + ExecuteAction JobEvent = "ExecuteAction" ) // Event represent the phase of Job, e.g. pod-failed. diff --git a/pkg/controllers/job/job_controller.go b/pkg/controllers/job/job_controller.go index 8f6eb06dea..c82c875355 100644 --- a/pkg/controllers/job/job_controller.go +++ b/pkg/controllers/job/job_controller.go @@ -17,6 +17,8 @@ limitations under the License. package job import ( + "fmt" + "github.com/golang/glog" "k8s.io/api/core/v1" @@ -38,6 +40,7 @@ import ( kbinfo "github.com/kubernetes-sigs/kube-batch/pkg/client/informers/externalversions/scheduling/v1alpha1" kblister "github.com/kubernetes-sigs/kube-batch/pkg/client/listers/scheduling/v1alpha1" + vkbatchv1 "volcano.sh/volcano/pkg/apis/batch/v1alpha1" vkver "volcano.sh/volcano/pkg/client/clientset/versioned" vkscheme "volcano.sh/volcano/pkg/client/clientset/versioned/scheme" vkinfoext "volcano.sh/volcano/pkg/client/informers/externalversions" @@ -239,6 +242,11 @@ func (cc *Controller) processNextReq() bool { glog.V(3).Infof("Execute <%v> on Job <%s/%s> in <%s> by <%T>.", action, req.Namespace, req.JobName, jobInfo.Job.Status.State.Phase, st) + if action != vkbatchv1.SyncJobAction { + cc.recordJobEvent(jobInfo.Job.Namespace, jobInfo.Job.Name, vkbatchv1.ExecuteAction, fmt.Sprintf( + "Start to execute action %s ", action)) + } + if err := st.Execute(action); err != nil { glog.Errorf("Failed to handle Job <%s/%s>: %v", jobInfo.Job.Namespace, jobInfo.Job.Name, err)