Skip to content

Commit 4462c05

Browse files
committed
Set special users before automatic run stops
A minimal, but not comprehensive addition for OCTRL-1065.
1 parent 3383b74 commit 4462c05

5 files changed

Lines changed: 122 additions & 41 deletions

File tree

common/protos/common.pb.go

Lines changed: 97 additions & 41 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

common/protos/common.proto

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,15 @@ message User {
4040
string name = 3;
4141
}
4242

43+
// Production and staging BKP recognizes these special user IDs.
44+
// They are used to associate certain actions (e.g. EOR) with certain subsystem
45+
// or AliECS component rather than a human user.
46+
enum SpecialUserId {
47+
INVALID = 0;
48+
LHC = 60;
49+
TIMER = 65;
50+
}
51+
4352
message WorkflowTemplateInfo {
4453
string name = 1;
4554
string description = 2;

common/protos/protoutils.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,17 @@ func WrapEvent(ce isEvent_Payload) *Event {
3434
Payload: ce,
3535
}
3636
}
37+
38+
// SpecialUser returns a User populated from a SpecialUserId enum:
39+
// - externalId = enum numeric value
40+
// - id = enum numeric value
41+
// - name = enum string name
42+
func SpecialUser(enumId SpecialUserId) *User {
43+
externalId := int32(enumId)
44+
name := enumId.String()
45+
return &User{
46+
ExternalId: &externalId,
47+
Id: nil,
48+
Name: name,
49+
}
50+
}

core/environment/environment.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1460,6 +1460,7 @@ func (env *Environment) scheduleAutoStopTransition() (scheduled bool, expected t
14601460
log.WithField("partition", env.id).
14611461
WithField("run", env.currentRunNumber).
14621462
Infof("Executing scheduled auto stop transition following expiration of %s", autoStopDuration)
1463+
env.SetLastRequestUser(pb.SpecialUser(pb.SpecialUserId_TIMER))
14631464
err = env.TryTransition(NewStopActivityTransition(ManagerInstance().taskman))
14641465
if err != nil {
14651466
log.WithField("partition", env.id).

core/environment/manager.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,6 +1113,7 @@ func (envs *Manager) handleLhcEvents(evt event.IntegratedServiceEvent) {
11131113
WithField("run", env.currentRunNumber).
11141114
Info("stopping the run due to beam dump")
11151115

1116+
env.SetLastRequestUser(evpb.SpecialUser(evpb.SpecialUserId_LHC))
11161117
err := env.TryTransition(NewStopActivityTransition(envs.taskman))
11171118
if err != nil {
11181119
log.WithPrefix("scheduler").

0 commit comments

Comments
 (0)