This is an automated email from the ASF dual-hosted git repository.

pbacsko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/yunikorn-k8shim.git


The following commit(s) were added to refs/heads/master by this push:
     new 6f601c06 [YUNIKORN-2597] Improve error messages in Context (#829)
6f601c06 is described below

commit 6f601c069f4f347c7d25c6b75cad3be82ca53e96
Author: Peter Bacsko <[email protected]>
AuthorDate: Thu May 2 13:16:52 2024 +0200

    [YUNIKORN-2597] Improve error messages in Context (#829)
    
    Closes: #829
    
    Signed-off-by: Peter Bacsko <[email protected]>
---
 pkg/cache/context.go | 44 +++++++++++++++++++++++++++++++++++++-------
 1 file changed, 37 insertions(+), 7 deletions(-)

diff --git a/pkg/cache/context.go b/pkg/cache/context.go
index 301f1096..3d40419a 100644
--- a/pkg/cache/context.go
+++ b/pkg/cache/context.go
@@ -23,6 +23,7 @@ import (
        "encoding/json"
        "errors"
        "fmt"
+       "reflect"
        "sort"
        "strconv"
        "strings"
@@ -1294,41 +1295,70 @@ func (ctx *Context) HandleContainerStateUpdate(request 
*si.UpdateContainerSchedu
 func (ctx *Context) ApplicationEventHandler() func(obj interface{}) {
        return func(obj interface{}) {
                if event, ok := obj.(events.ApplicationEvent); ok {
-                       app := ctx.GetApplication(event.GetApplicationID())
+                       appID := event.GetApplicationID()
+                       app := ctx.GetApplication(appID)
                        if app == nil {
-                               log.Log(log.ShimContext).Error("failed to 
handle application event",
-                                       zap.String("reason", "application not 
exist"))
+                               log.Log(log.ShimContext).Error("failed to 
handle application event, application does not exist",
+                                       zap.String("applicationID", appID))
                                return
                        }
+
                        if app.canHandle(event) {
                                if err := app.handle(event); err != nil {
                                        log.Log(log.ShimContext).Error("failed 
to handle application event",
                                                zap.String("event", 
event.GetEvent()),
+                                               zap.String("applicationID", 
appID),
                                                zap.Error(err))
                                }
+                               return
                        }
+
+                       log.Log(log.ShimContext).Error("application event 
cannot be handled in the current state",
+                               zap.String("applicationID", appID),
+                               zap.String("event", event.GetEvent()),
+                               zap.String("state", app.sm.Current()))
+                       return
                }
+
+               log.Log(log.ShimContext).Error("could not handle application 
event",
+                       zap.String("type", reflect.TypeOf(obj).Name()))
        }
 }
 
 func (ctx *Context) TaskEventHandler() func(obj interface{}) {
        return func(obj interface{}) {
                if event, ok := obj.(events.TaskEvent); ok {
-                       task := ctx.getTask(event.GetApplicationID(), 
event.GetTaskID())
+                       appID := event.GetApplicationID()
+                       taskID := event.GetTaskID()
+                       task := ctx.getTask(appID, taskID)
                        if task == nil {
-                               log.Log(log.ShimContext).Error("failed to 
handle application event")
+                               log.Log(log.ShimContext).Error("failed to 
handle task event, task does not exist",
+                                       zap.String("applicationID", appID),
+                                       zap.String("taskID", taskID))
                                return
                        }
+
                        if task.canHandle(event) {
                                if err := task.handle(event); err != nil {
                                        log.Log(log.ShimContext).Error("failed 
to handle task event",
-                                               zap.String("applicationID", 
task.applicationID),
-                                               zap.String("taskID", 
task.taskID),
+                                               zap.String("applicationID", 
appID),
+                                               zap.String("taskID", taskID),
                                                zap.String("event", 
event.GetEvent()),
                                                zap.Error(err))
                                }
+                               return
                        }
+
+                       log.Log(log.ShimContext).Error("task event cannot be 
handled in the current state",
+                               zap.String("applicationID", appID),
+                               zap.String("taskID", taskID),
+                               zap.String("event", event.GetEvent()),
+                               zap.String("state", task.sm.Current()))
+                       return
                }
+
+               log.Log(log.ShimContext).Error("could not handle task event",
+                       zap.String("type", reflect.TypeOf(obj).Name()))
        }
 }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to