Skip to content

Commit fec9a69

Browse files
committed
[core] Send run number in ODC Start/Stop calls
1 parent 210a733 commit fec9a69

2 files changed

Lines changed: 39 additions & 5 deletions

File tree

core/integration/odc/handlers.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,15 @@ func handleGetState(ctx context.Context, odcClient *RpcClient, envId string) (st
9090
return odcutils.StateForOdcState(newState), err
9191
}
9292

93-
func handleStart(ctx context.Context, odcClient *RpcClient, arguments map[string]string, envId string) error {
93+
func handleStart(ctx context.Context, odcClient *RpcClient, arguments map[string]string, envId string, runNumber uint64) error {
9494
defer utils.TimeTrackFunction(time.Now(), log.WithPrefix("odcclient").WithField("partition", envId))
95+
9596
req := &odcpb.StartRequest{
9697
Request: &odcpb.StateRequest{
9798
Partitionid: envId,
9899
Path: "",
99100
Detailed: false,
101+
Runnr: runNumber,
100102
},
101103
}
102104

@@ -181,13 +183,14 @@ func handleStart(ctx context.Context, odcClient *RpcClient, arguments map[string
181183
return err
182184
}
183185

184-
func handleStop(ctx context.Context, odcClient *RpcClient, arguments map[string]string, envId string) error {
186+
func handleStop(ctx context.Context, odcClient *RpcClient, arguments map[string]string, envId string, runNumber uint64) error {
185187
defer utils.TimeTrackFunction(time.Now(), log.WithPrefix("odcclient").WithField("partition", envId))
186188
req := &odcpb.StopRequest{
187189
Request: &odcpb.StateRequest{
188190
Partitionid: envId,
189191
Path: "",
190192
Detailed: false,
193+
Runnr: runNumber,
191194
},
192195
}
193196

@@ -382,7 +385,7 @@ func handleCleanup(ctx context.Context, odcClient *RpcClient, arguments map[stri
382385
func doReset(ctx context.Context, odcClient *RpcClient, arguments map[string]string, envId string) error {
383386
// RESET
384387
req := &odcpb.ResetRequest{
385-
Request: &odcpb.StateRequest{
388+
Request: &odcpb.StateRequest{
386389
Partitionid: envId,
387390
Path: "",
388391
Detailed: false,

core/integration/odc/plugin.go

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,18 @@ func (p *Plugin) ObjectStack(data interface{}) (stack map[string]interface{}) {
219219
WithField("call", "Start").
220220
Warn("cannot acquire run number for ODC")
221221
}
222+
var (
223+
runNumberu64 uint64
224+
err error
225+
)
226+
227+
runNumberu64, err = strconv.ParseUint(rn, 10, 32)
228+
if err != nil {
229+
log.WithField("partition", envId).
230+
WithError(err).
231+
Error("cannot acquire run number for DCS SOR")
232+
runNumberu64 = 0
233+
}
222234

223235
timeout := callable.AcquireTimeout(ODC_START_TIMEOUT, varStack, "Start", envId)
224236

@@ -228,7 +240,7 @@ func (p *Plugin) ObjectStack(data interface{}) (stack map[string]interface{}) {
228240

229241
ctx, cancel := context.WithTimeout(context.Background(), timeout)
230242
defer cancel()
231-
err := handleStart(ctx, p.odcClient, arguments, envId)
243+
err = handleStart(ctx, p.odcClient, arguments, envId, runNumberu64)
232244
if err != nil {
233245
log.WithError(err).
234246
WithField("level", infologger.IL_Support).
@@ -244,11 +256,30 @@ func (p *Plugin) ObjectStack(data interface{}) (stack map[string]interface{}) {
244256
stack["Stop"] = func() (out string) {
245257
// ODC Stop
246258

259+
rn, ok := varStack["run_number"]
260+
if !ok {
261+
log.WithField("partition", envId).
262+
WithField("call", "Start").
263+
Warn("cannot acquire run number for ODC")
264+
}
265+
var (
266+
runNumberu64 uint64
267+
err error
268+
)
269+
270+
runNumberu64, err = strconv.ParseUint(rn, 10, 32)
271+
if err != nil {
272+
log.WithField("partition", envId).
273+
WithError(err).
274+
Error("cannot acquire run number for DCS SOR")
275+
runNumberu64 = 0
276+
}
277+
247278
timeout := callable.AcquireTimeout(ODC_STOP_TIMEOUT, varStack, "Stop", envId)
248279

249280
ctx, cancel := context.WithTimeout(context.Background(), timeout)
250281
defer cancel()
251-
err := handleStop(ctx, p.odcClient, nil, envId)
282+
err = handleStop(ctx, p.odcClient, nil, envId, runNumberu64)
252283
if err != nil {
253284
log.WithError(err).
254285
WithField("level", infologger.IL_Support).

0 commit comments

Comments
 (0)