Skip to content

Commit

Permalink
Merge pull request #1110 from chauberahul1993/ODIM-7167
Browse files Browse the repository at this point in the history
Fixed default event subscription creation bug
  • Loading branch information
amar-shalgar authored Feb 13, 2023
2 parents 9181315 + 121d5dd commit b82a3d8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 21 deletions.
16 changes: 16 additions & 0 deletions lib-utilities/common/responses.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,19 @@ func ModifyContext(ctx context.Context, threadName, podName string) context.Cont
ctx = context.WithValue(ctx, ProcessName, podName)
return ctx
}
func CreateNewRequestContext(ctx context.Context) context.Context {
reqCtx := context.Background()
processName, _ := ctx.Value(ProcessName).(string)
transactionID, _ := ctx.Value(TransactionID).(string)
actionID, _ := ctx.Value(ActionID).(string)
actionName, _ := ctx.Value(ActionName).(string)
threadID, _ := ctx.Value(ThreadID).(string)
threadName, _ := ctx.Value(ThreadName).(string)
reqCtx = context.WithValue(reqCtx, ProcessName, processName)
reqCtx = context.WithValue(reqCtx, TransactionID, transactionID)
reqCtx = context.WithValue(reqCtx, ActionID, actionID)
reqCtx = context.WithValue(reqCtx, ActionName, actionName)
reqCtx = context.WithValue(reqCtx, ThreadID, threadID)
reqCtx = context.WithValue(reqCtx, ThreadName, threadName)
return reqCtx
}
23 changes: 3 additions & 20 deletions lib-utilities/services/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func CreateTask(ctx context.Context, sessionUserName string) (string, error) {
}
defer conn.Close()
taskService := taskproto.NewGetTaskServiceClient(conn)
reqCtx := CreateNewRequestContext(ctx)
reqCtx := common.CreateNewRequestContext(ctx)
reqCtx = common.CreateMetadata(reqCtx)
response, err := taskService.CreateTask(
reqCtx, &taskproto.CreateTaskRequest{
Expand All @@ -54,7 +54,7 @@ func CreateChildTask(ctx context.Context, sessionUserName string, parentTaskID s
}
defer conn.Close()
taskService := taskproto.NewGetTaskServiceClient(conn)
reqCtx := CreateNewRequestContext(ctx)
reqCtx := common.CreateNewRequestContext(ctx)
reqCtx = common.CreateMetadata(reqCtx)
response, err := taskService.CreateChildTask(
reqCtx, &taskproto.CreateTaskRequest{
Expand All @@ -81,7 +81,7 @@ func UpdateTask(ctx context.Context, taskID string, taskState string, taskStatus
return fmt.Errorf("Failed to create client connection: %s", errConn.Error())
}
defer conn.Close()
reqCtx := CreateNewRequestContext(ctx)
reqCtx := common.CreateNewRequestContext(ctx)
reqCtx = common.CreateMetadata(reqCtx)
taskService := taskproto.NewGetTaskServiceClient(conn)
_, err = taskService.UpdateTask(
Expand All @@ -96,20 +96,3 @@ func UpdateTask(ctx context.Context, taskID string, taskState string, taskStatus
)
return err
}

func CreateNewRequestContext(ctx context.Context) context.Context {
reqCtx := context.Background()
processName, _ := ctx.Value(common.ProcessName).(string)
transactionID, _ := ctx.Value(common.TransactionID).(string)
actionID, _ := ctx.Value(common.ActionID).(string)
actionName, _ := ctx.Value(common.ActionName).(string)
threadID, _ := ctx.Value(common.ThreadID).(string)
threadName, _ := ctx.Value(common.ThreadName).(string)
reqCtx = context.WithValue(reqCtx, common.ProcessName, processName)
reqCtx = context.WithValue(reqCtx, common.TransactionID, transactionID)
reqCtx = context.WithValue(reqCtx, common.ActionID, actionID)
reqCtx = context.WithValue(reqCtx, common.ActionName, actionName)
reqCtx = context.WithValue(reqCtx, common.ThreadID, threadID)
reqCtx = context.WithValue(reqCtx, common.ThreadName, threadName)
return reqCtx
}
4 changes: 3 additions & 1 deletion svc-aggregation/system/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -1159,8 +1159,10 @@ func CreateDefaultEventSubscription(ctx context.Context, systemID []string) {
}
defer conn.Close()
events := eventsproto.NewEventsClient(conn)
reqCtx := common.CreateNewRequestContext(ctx)
reqCtx = common.CreateMetadata(reqCtx)

_, err := events.CreateDefaultEventSubscription(ctx, &eventsproto.DefaultEventSubRequest{
_, err := events.CreateDefaultEventSubscription(reqCtx, &eventsproto.DefaultEventSubRequest{
SystemID: systemID,
EventTypes: []string{"Alert"},
MessageIDs: []string{},
Expand Down

0 comments on commit b82a3d8

Please sign in to comment.