@@ -133,7 +133,8 @@ func runSchedulerController(ctx context.Context,
133133 }
134134 return
135135 }
136- log .WithPrefix ("scheduler" ).Info ("disconnected" )
136+ log .WithPrefix ("scheduler" ).
137+ Info ("disconnected" )
137138 }),
138139 )
139140}
@@ -437,6 +438,7 @@ func (state *schedulerState) resourceOffers(fidStore store.Singleton) events.Han
437438 taskClasses [i ] = d .TaskClassName
438439 }
439440 log .WithPrefix ("scheduler" ).
441+ WithField ("partition" , envId .String ()).
440442 WithFields (logrus.Fields {
441443 "roles" : strings .Join (rolePaths , ", " ),
442444 "classes" : strings .Join (taskClasses , ", " ),
@@ -542,6 +544,7 @@ func (state *schedulerState) resourceOffers(fidStore store.Singleton) events.Han
542544 if ! offerAttributes .Satisfy (descriptorConstraints [descriptor ]) {
543545 if viper .GetBool ("veryVerbose" ) {
544546 log .WithPrefix ("scheduler" ).
547+ WithField ("partition" , envId .String ()).
545548 WithFields (logrus.Fields {
546549 "taskClass" : descriptor .TaskClassName ,
547550 "constraints" : descriptorConstraints [descriptor ],
@@ -553,11 +556,14 @@ func (state *schedulerState) resourceOffers(fidStore store.Singleton) events.Han
553556 }
554557 continue
555558 }
556- log .WithPrefix ("scheduler" ).Debug ("offer attributes satisfy constraints" )
559+ log .WithPrefix ("scheduler" ).
560+ WithField ("partition" , envId .String ()).
561+ Debug ("offer attributes satisfy constraints" )
557562
558563 wants := state .taskman .GetWantsForDescriptor (descriptor )
559564 if wants == nil {
560565 log .WithPrefix ("scheduler" ).
566+ WithField ("partition" , envId .String ()).
561567 WithFields (logrus.Fields {
562568 "class" : descriptor .TaskClassName ,
563569 "level" : infologger .IL_Devel ,
@@ -569,6 +575,7 @@ func (state *schedulerState) resourceOffers(fidStore store.Singleton) events.Han
569575 if ! Resources (remainingResourcesInOffer ).Satisfy (wants ) {
570576 if viper .GetBool ("veryVerbose" ) {
571577 log .WithPrefix ("scheduler" ).
578+ WithField ("partition" , envId .String ()).
572579 WithFields (logrus.Fields {
573580 "taskClass" : descriptor .TaskClassName ,
574581 "wants" : * wants ,
@@ -619,9 +626,12 @@ func (state *schedulerState) resourceOffers(fidStore store.Singleton) events.Han
619626 taskPtr := state .taskman .newTaskForMesosOffer (& offer , descriptor , bindMap , targetExecutorId )
620627 if taskPtr == nil {
621628 log .WithPrefix ("scheduler" ).
629+ WithField ("partition" , envId .String ()).
622630 WithField ("offerId" , offer .ID .Value ).
623631 Error ("cannot get task for offer+descriptor, this should never happen" )
624- log .Trace ("state unlock" )
632+ log .WithPrefix ("scheduler" ).
633+ WithField ("partition" , envId .String ()).
634+ Trace ("state unlock" )
625635 continue
626636 }
627637
@@ -637,6 +647,7 @@ func (state *schedulerState) resourceOffers(fidStore store.Singleton) events.Han
637647 log .WithPrefix ("scheduler" ).
638648 WithField ("offerId" , offer .ID .Value ).
639649 WithError (err ).
650+ WithField ("partition" , envId .String ()).
640651 Error ("cannot build task command" )
641652 continue
642653 }
@@ -700,6 +711,7 @@ func (state *schedulerState) resourceOffers(fidStore store.Singleton) events.Han
700711 jsonCommand , err = json .Marshal (& runCommand )
701712 if err != nil {
702713 log .WithPrefix ("scheduler" ).
714+ WithField ("partition" , envId .String ()).
703715 WithFields (logrus.Fields {
704716 "error" : err .Error (),
705717 "value" : * runCommand .Value ,
@@ -710,6 +722,7 @@ func (state *schedulerState) resourceOffers(fidStore store.Singleton) events.Han
710722 Error ("cannot serialize mesos.CommandInfo for executor" )
711723 state .Unlock ()
712724 log .WithPrefix ("scheduler" ).
725+ WithField ("partition" , envId .String ()).
713726 Trace ("state unlock" )
714727 continue
715728 }
@@ -737,6 +750,7 @@ func (state *schedulerState) resourceOffers(fidStore store.Singleton) events.Han
737750 // Append executor resources to request
738751 executorResources := mesos .Resources (state .executor .Resources )
739752 log .WithPrefix ("scheduler" ).
753+ WithField ("partition" , envId .String ()).
740754 WithField ("taskResources" , resourcesRequest ).
741755 WithField ("executorResources" , executorResources ).
742756 Debug ("creating Mesos task" )
@@ -746,6 +760,7 @@ func (state *schedulerState) resourceOffers(fidStore store.Singleton) events.Han
746760
747761 executor := state .executor
748762 executor .ExecutorID .Value = taskPtr .GetExecutorId ()
763+ envIdS := envId .String ()
749764
750765 mesosTaskInfo := mesos.TaskInfo {
751766 Name : taskPtr .GetName (),
@@ -754,6 +769,10 @@ func (state *schedulerState) resourceOffers(fidStore store.Singleton) events.Han
754769 Executor : executor ,
755770 Resources : resourcesRequest ,
756771 Data : jsonCommand , // this ends up in LAUNCH for the executor
772+ Labels : & mesos.Labels {Labels : []mesos.Label {{
773+ Key : "environmentId" ,
774+ Value : & envIdS ,
775+ }}},
757776 }
758777
759778 // We must run the executor with a special LD_LIBRARY_PATH because
@@ -770,6 +789,7 @@ func (state *schedulerState) resourceOffers(fidStore store.Singleton) events.Han
770789 }
771790
772791 log .WithPrefix ("scheduler" ).
792+ WithField ("partition" , envId .String ()).
773793 WithFields (logrus.Fields {
774794 "taskId" : newTaskId ,
775795 "offerId" : offer .ID .Value ,
@@ -1003,11 +1023,13 @@ func (state *schedulerState) tryReviveOffers(ctx context.Context) {
10031023func doReviveOffers (ctx context.Context , state * schedulerState ) {
10041024 err := calls .CallNoData (ctx , state .cli , calls .Revive ())
10051025 if err != nil {
1006- log .WithPrefix ("scheduler" ).WithField ("error" , err .Error ()).
1026+ log .WithPrefix ("scheduler" ).
1027+ WithField ("error" , err .Error ()).
10071028 Error ("failed to revive offers" )
10081029 return
10091030 }
1010- log .WithPrefix ("scheduler" ).Debug ("revive offers done" )
1031+ log .WithPrefix ("scheduler" ).
1032+ Debug ("revive offers done" )
10111033}
10121034
10131035func (state * schedulerState ) killTask (ctx context.Context , receiver controlcommands.MesosCommandTarget ) (err error ) {
@@ -1029,6 +1051,7 @@ func (state *schedulerState) sendCommand(ctx context.Context, command controlcom
10291051 err = calls .CallNoData (ctx , state .cli , message )
10301052
10311053 log .WithPrefix ("scheduler" ).
1054+ WithField ("partition" , command .GetEnvironmentId ().String ()).
10321055 WithFields (logrus.Fields {
10331056 "agentId" : receiver .AgentId .Value ,
10341057 "executorId" : receiver .ExecutorId .Value ,
@@ -1085,7 +1108,8 @@ func logAllEvents() eventrules.Rule {
10851108 fields ["raw" ] = fmt .Sprintf ("%+v" , * e )
10861109 }
10871110 log .WithPrefix ("scheduler" ).
1088- WithFields (fields ).Trace ("incoming event" )
1111+ WithFields (fields ).
1112+ Trace ("incoming event" )
10891113 return ch (ctx , e , err )
10901114 }
10911115}
0 commit comments