Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] ODC: Send SOR/EOR timestamps as FMQ properties #658

Merged
merged 1 commit into from
Mar 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 37 additions & 12 deletions core/integration/odc/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,10 @@ func handleGetState(ctx context.Context, odcClient *RpcClient, envId string) (st
return odcutils.StateForOdcState(newState), err
}

func handleStart(ctx context.Context, odcClient *RpcClient, arguments map[string]string, paddingTimeout time.Duration, envId string, runNumber uint64, call *callable.Call) error {
defer utils.TimeTrackFunction(time.Now(), log.WithPrefix("odcclient").WithField("partition", envId))
func setProperties(ctx context.Context, odcClient *RpcClient, arguments map[string]string, paddingTimeout time.Duration, envId string, runNumber uint64, call *callable.Call) error {

var err error = nil
var rep *odcpb.StateReply

if envId == "" {
return errors.New("cannot proceed with empty environment id")
}

// SetProperties before START
setPropertiesRequest := &odcpb.SetPropertiesRequest{
Partitionid: envId,
Path: "",
Expand Down Expand Up @@ -252,6 +245,25 @@ func handleStart(ctx context.Context, odcClient *RpcClient, arguments map[string
}).
Debug("call to ODC complete: odc.SetProperties")

return nil
}

func handleStart(ctx context.Context, odcClient *RpcClient, arguments map[string]string, paddingTimeout time.Duration, envId string, runNumber uint64, call *callable.Call) error {
defer utils.TimeTrackFunction(time.Now(), log.WithPrefix("odcclient").WithField("partition", envId))

var err error = nil
var rep *odcpb.StateReply

if envId == "" {
return errors.New("cannot proceed with empty environment id")
}

// SetProperties before START
err = setProperties(ctx, odcClient, arguments, paddingTimeout, envId, runNumber, call)
if err != nil {
return err
}

// The actual START operation starts here
req := &odcpb.StartRequest{
Request: &odcpb.StateRequest{
Expand All @@ -262,15 +274,15 @@ func handleStart(ctx context.Context, odcClient *RpcClient, arguments map[string
},
}
// We ask this ODC call to complete within our own DEADLINE, minus 1 second
ctxDeadline, ok = ctx.Deadline()
ctxDeadline, ok := ctx.Deadline()
if ok {
req.Request.Timeout = uint32((time.Until(ctxDeadline) - paddingTimeout).Seconds())
}

payload = map[string]interface{}{
payload := map[string]interface{}{
"odcRequest": &req,
}
payloadJson, _ = json.Marshal(payload)
payloadJson, _ := json.Marshal(payload)
the.EventWriterWithTopic(TOPIC).WriteEvent(&pb.Ev_IntegratedServiceEvent{
Name: call.GetName(),
OperationName: call.Func,
Expand Down Expand Up @@ -382,6 +394,20 @@ func handleStart(ctx context.Context, odcClient *RpcClient, arguments map[string

func handleStop(ctx context.Context, odcClient *RpcClient, arguments map[string]string, paddingTimeout time.Duration, envId string, runNumber uint64, call *callable.Call) error {
defer utils.TimeTrackFunction(time.Now(), log.WithPrefix("odcclient").WithField("partition", envId))
var err error = nil

// SetProperties before STOP
if len(arguments) > 0 {
err = setProperties(ctx, odcClient, arguments, paddingTimeout, envId, runNumber, call)
if err != nil {
log.WithField("partition", envId).
WithField("level", infologger.IL_Support).
WithError(err).
Warn("setProperties call to ODC failed. will continue with odc.Stop")
}
}

// The actual STOP operation starts here
req := &odcpb.StopRequest{
Request: &odcpb.StateRequest{
Partitionid: envId,
Expand All @@ -396,7 +422,6 @@ func handleStop(ctx context.Context, odcClient *RpcClient, arguments map[string]
req.Request.Timeout = uint32((time.Until(ctxDeadline) - paddingTimeout).Seconds())
}

var err error = nil
var rep *odcpb.StateReply

if envId == "" {
Expand Down
33 changes: 24 additions & 9 deletions core/integration/odc/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -1363,6 +1363,12 @@ func (p *Plugin) CallStack(data interface{}) (stack map[string]interface{}) {
WithField("call", "Start").
Warn("cannot acquire FairMQ devices cleanup count for ODC")
}
runStartTimeMs, ok := varStack["run_start_time_ms"]
if !ok {
log.WithField("partition", envId).
WithField("call", "Start").
Warn("cannot acquire run_start_time_ms")
}

var (
runNumberu64 uint64
Expand Down Expand Up @@ -1391,6 +1397,7 @@ func (p *Plugin) CallStack(data interface{}) (stack map[string]interface{}) {
arguments := make(map[string]string)
arguments["run_number"] = rn
arguments["runNumber"] = rn
arguments["run_start_time_ms"] = runStartTimeMs
arguments["cleanup"] = strconv.Itoa(cleanupCount)

ctx, cancel := context.WithTimeout(context.Background(), timeout)
Expand All @@ -1409,32 +1416,40 @@ func (p *Plugin) CallStack(data interface{}) (stack map[string]interface{}) {
}
stack["Stop"] = func() (out string) {
// ODC Stop
callFailedStr := "EPN Stop call failed"
var (
runNumberu64 uint64
err error
)

rn, ok := varStack["run_number"]
if !ok {
log.WithField("partition", envId).
WithField("call", "Start").
Warn("cannot acquire run number for ODC")
Warn("cannot acquire run number for ODC Stop")
}
var (
runNumberu64 uint64
err error
)
callFailedStr := "EPN Stop call failed"

runNumberu64, err = strconv.ParseUint(rn, 10, 32)
if err != nil {
log.WithField("partition", envId).
WithError(err).
Error("cannot acquire run number for DCS SOR")
Error("cannot acquire run number for ODC EOR")
runNumberu64 = 0
}
runEndTimeMs, ok := varStack["run_end_time_ms"]
if !ok {
log.WithField("partition", envId).
WithField("call", "Start").
Warn("cannot acquire run_end_time_ms")
}

arguments := make(map[string]string)
arguments["run_end_time_ms"] = runEndTimeMs
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a question about this. Is this documented parameter that just wasn't used before, or are you introducing something new?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand the question. This parameter was not sent before to ODC, thus it could not be used, so it is something new.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for not being specific enough. I know that it wasn't used before. I am asking whether run_end_time_ms is existing parameter of ODC or something totally new, that needs to be implemented in ODC

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah no, these parameters are transparent to ODC, it just receives them and propagates to the tasks on EPNs. It's just key-values that tasks may use if they want to, e.g. QC is going to use it if it's available.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay, thanks


timeout := callable.AcquireTimeout(ODC_STOP_TIMEOUT, varStack, "Stop", envId)

ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()
err = handleStop(ctx, p.odcClient, nil, paddingTimeout, envId, runNumberu64, call)
err = handleStop(ctx, p.odcClient, arguments, paddingTimeout, envId, runNumberu64, call)
if err != nil {
log.WithError(err).
WithField("level", infologger.IL_Support).
Expand Down
5 changes: 4 additions & 1 deletion docs/handbook/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,10 @@ In addition to the above, which varies depending on the configuration of the env
* `pdp_beam_type`
* `pdp_override_run_start_time`

FairMQ task implementors should expect that these values are written to the FairMQ properties map right before the `RUN` transition via `SetProperty` calls.
The following values are pushed by AliECS during `STOP_ACTIVITY`:
* `run_end_time_ms`

FairMQ task implementors should expect that these values are written to the FairMQ properties map right before the `RUN` and `STOP` transitions via `SetProperty` calls.

## Resource wants and limits

Expand Down
Loading