Ejemplo n.º 1
0
// mergeAxisValue overwrites a parserBV's fields based on settings
// in the axis value. Matrix expansions are evaluated as this process occurs.
// Returns any errors evaluating expansions.
func (pbv *parserBV) mergeAxisValue(av axisValue) error {
	// expand the variant's expansions (woah, dude) and update them
	if len(av.Variables) > 0 {
		expanded, err := expandExpansions(av.Variables, pbv.Expansions)
		if err != nil {
			return fmt.Errorf("expanding variables: %v", err)
		}
		pbv.Expansions.Update(expanded)
	}
	// merge tags, removing dupes
	if len(av.Tags) > 0 {
		expanded, err := expandStrings(av.Tags, pbv.Expansions)
		if err != nil {
			return fmt.Errorf("expanding tags: %v", err)
		}
		pbv.Tags = util.UniqueStrings(append(pbv.Tags, expanded...))
	}
	// overwrite run_on
	var err error
	if len(av.RunOn) > 0 {
		pbv.RunOn, err = expandStrings(av.RunOn, pbv.Expansions)
		if err != nil {
			return fmt.Errorf("expanding run_on: %v", err)
		}
	}
	// overwrite modules
	if len(av.Modules) > 0 {
		pbv.Modules, err = expandStrings(av.Modules, pbv.Expansions)
		if err != nil {
			return fmt.Errorf("expanding modules: %v", err)
		}
	}
	if av.Stepback != nil {
		pbv.Stepback = av.Stepback
	}
	if av.BatchTime != nil {
		pbv.BatchTime = av.BatchTime
	}
	return nil
}
Ejemplo n.º 2
0
// Takes in a list of tasks, and splits them by distro.
// Returns a map of distro name -> tasks that can be run on that distro
// and a map of task id -> distros that the task can be run on (for tasks
// that can be run on multiple distro)
func (s *Scheduler) splitTasksByDistro(tasksToSplit []task.Task) (
	map[string][]task.Task, map[string][]string, error) {
	tasksByDistro := make(map[string][]task.Task)
	taskRunDistros := make(map[string][]string)

	// map of versionBuildVariant -> build variant
	versionBuildVarMap := make(map[versionBuildVariant]model.BuildVariant)

	// insert the tasks into the appropriate distro's queue in our map
	for _, task := range tasksToSplit {
		key := versionBuildVariant{task.Version, task.BuildVariant}
		if _, exists := versionBuildVarMap[key]; !exists {
			err := s.updateVersionBuildVarMap(task.Version, versionBuildVarMap)
			if err != nil {
				evergreen.Logger.Logf(slogger.WARN, "error getting buildvariant "+
					"map for task %v: %v", task.Id, err)
				continue
			}
		}

		// get the build variant for the task
		buildVariant, ok := versionBuildVarMap[key]
		if !ok {
			evergreen.Logger.Logf(slogger.WARN, "task %v has no buildvariant called "+
				"'%v' on project %v", task.Id, task.BuildVariant, task.Project)
			continue
		}

		// get the task specification for the build variant
		var taskSpec model.BuildVariantTask
		for _, tSpec := range buildVariant.Tasks {
			if tSpec.Name == task.DisplayName {
				taskSpec = tSpec
				break
			}
		}

		// if no matching spec was found log it and continue
		if taskSpec.Name == "" {
			evergreen.Logger.Logf(slogger.WARN, "task %v has no matching spec for "+
				"build variant %v on project %v", task.Id,
				task.BuildVariant, task.Project)
			continue
		}

		// use the specified distros for the task, or, if none are specified,
		// the default distros for the build variant
		distrosToUse := buildVariant.RunOn
		if len(taskSpec.Distros) != 0 {
			distrosToUse = taskSpec.Distros
		}
		// remove duplicates to avoid scheduling twice
		distrosToUse = util.UniqueStrings(distrosToUse)
		for _, d := range distrosToUse {
			tasksByDistro[d] = append(tasksByDistro[d], task)
		}

		// for tasks that can run on multiple distros, keep track of which
		// distros they will be scheduled on
		if len(distrosToUse) > 1 {
			taskRunDistros[task.Id] = distrosToUse
		}
	}

	return tasksByDistro, taskRunDistros, nil

}