code: func (s *Scheduler) stopSurplusOmniJobs(formation *Formation) {
  	log := s.logger.New("fn", "stopSurplusOmniJobs")
  
  	for typ, proc := range formation.Release.Processes {
  		if !proc.Omni {
  			continue
  		}
  
  		// get a list of jobs per host so we can count them and
  		// potentially stop any surplus ones
  		hostJobs := make(map[string][]*Job)
  		for _, job := range s.jobs.WithFormationAndType(formation, typ) {
  			if job.IsRunning() {
  				hostJobs[job.HostID] = append(hostJobs[job.HostID], job)
  			}
  		}
  
  		// detect surplus jobs per host by comparing the expected count
  		// from the formation with the number of jobs currently running
  		// on that host
  		expected := formation.OriginalProcesses[typ]
  		var surplusJobs []*Job
  		for _, jobs := range hostJobs {
  			if diff := len(jobs) - expected; diff > 0 {
  				// add the most recent jobs which are at the start
  				// of the slice (WithFormationAndType returns them
  				// in reverse chronological order above)
  				surplusJobs = append(surplusJobs, jobs[0:diff]...)
  			}
  		}
  
  		if len(surplusJobs) == 0 {
  			continue
  		}
  
  		log.Info(fmt.Sprintf("detected %d surplus omni jobs", len(surplusJobs)), "type", typ)
  		for _, job := range surplusJobs {
  			s.stopJob(job)
  		}
  	}
  }
docs: // stopSurplusOmniJobs stops surplus jobs which are running on a host which has
  // more than the expected number of omni jobs for a given type (this happens
  // for example when both the bootstrapper and scheduler are starting jobs and
  // distribute omni jobs unevenly)