Source:
<code>private List<SingularityPendingTask> getScheduledTaskIds(int numMissingInstances, List<SingularityTaskId> matchingTaskIds, SingularityRequest request, RequestState state, SingularityDeployStatistics deployStatistics, String deployId, SingularityPendingRequest pendingRequest, Optional<SingularityPendingDeploy> maybePendingDeploy) { final Optional<Long> nextRunAt = getNextRunAt(request, state, deployStatistics, pendingRequest, maybePendingDeploy); if (!nextRunAt.isPresent()) { return Collections.emptyList(); } final Set<Integer> inuseInstanceNumbers = Sets.newHashSetWithExpectedSize(matchingTaskIds.size()); for (SingularityTaskId matchingTaskId : matchingTaskIds) { inuseInstanceNumbers.add(matchingTaskId.getInstanceNo()); } final List<SingularityPendingTask> newTasks = Lists.newArrayListWithCapacity(numMissingInstances); int nextInstanceNumber = 1; for (int i = 0; i < numMissingInstances; i++) { while (inuseInstanceNumbers.contains(nextInstanceNumber)) { nextInstanceNumber++; } newTasks.add( new SingularityPendingTask( new SingularityPendingTaskId( request.getId(), deployId, nextRunAt.get(), nextInstanceNumber, pendingRequest.getPendingType(), pendingRequest.getTimestamp()), pendingRequest.getCmdLineArgsList(), pendingRequest.getUser(), pendingRequest.getRunId(), pendingRequest.getSkipHealthchecks(), pendingRequest.getMessage(), pendingRequest.getResources(), <START> null, <END> pendingRequest.getActionId())); nextInstanceNumber++; } return newTasks; }</code><technical_language>this missing piece of puzzle connect through. SingularityPendingRequest is object carry envOverrides RunNowRequest pending task. In RequestResource.scheduleImmediately create a SingularityPendingRequest provided SingularityRunNowRequest. pending request need in environment overrides, this line put pending task. RequestResource calls checkRunNowRequest SingularityValidator, is constructs object running some checks. is envOverrides need put SingularityPendingRequest</technical_language>

Target:
private List<SingularityPendingTask> getScheduledTaskIds(int numMissingInstances, List<SingularityTaskId> matchingTaskIds, SingularityRequest request, RequestState state, SingularityDeployStatistics deployStatistics, String deployId, SingularityPendingRequest pendingRequest, Optional<SingularityPendingDeploy> maybePendingDeploy) { final Optional<Long> nextRunAt = getNextRunAt(request, state, deployStatistics, pendingRequest, maybePendingDeploy); if (!nextRunAt.isPresent()) { return Collections.emptyList(); } final Set<Integer> inuseInstanceNumbers = Sets.newHashSetWithExpectedSize(matchingTaskIds.size()); for (SingularityTaskId matchingTaskId : matchingTaskIds) { inuseInstanceNumbers.add(matchingTaskId.getInstanceNo()); } final List<SingularityPendingTask> newTasks = Lists.newArrayListWithCapacity(numMissingInstances); int nextInstanceNumber = 1; for (int i = 0; i < numMissingInstances; i++) { while (inuseInstanceNumbers.contains(nextInstanceNumber)) { nextInstanceNumber++; } newTasks.add( new SingularityPendingTask( new SingularityPendingTaskId( request.getId(), deployId, nextRunAt.get(), nextInstanceNumber, pendingRequest.getPendingType(), pendingRequest.getTimestamp()), pendingRequest.getCmdLineArgsList(), pendingRequest.getUser(), pendingRequest.getRunId(), pendingRequest.getSkipHealthchecks(), pendingRequest.getMessage(), pendingRequest.getResources(), pendingRequest.getRunAsUserOverride(), pendingRequest.getEnvOverrides(), pendingRequest.getExtraArtifacts(), pendingRequest.getActionId())); nextInstanceNumber++; } return newTasks; }