Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEVPROD-10420: do not link patch_optional dependencies for alias versions #8348

Merged

Conversation

Kimchelly
Copy link
Contributor

@Kimchelly Kimchelly commented Sep 27, 2024

DEVPROD-10420

Description

The tasks that have hit the task dependencies alert are tasks that have a dependency on a nonexistent task. They get stuck in the task queue because they're waiting to run on the nonexistent task.

This happens because of patch_optional dependencies in non-commit waterfall versions. For example, let's say there's a taskA and it has a patch_optional dependency on taskB. The expected behavior of patch_optional is that the dependency will never be created automatically in the version, so the dependency link should only be created if both taskA and taskB are created together. Furthermore, let's assume there's a periodic build that has an alias that selects only taskA to run. In this case, taskA should be created and taskB shouldn't (and we do see this happen, which is correct). However, even though taskB wasn't created, taskA nonetheless has a depends_on link to the nonexistent taskB (this shouldn't happen).

The cause of the bug is that, when creating a waterfall version, we have to make a pre-generated table of task IDs. Currently, the pre-generated task ID table creates task IDs for all possible variant-tasks, even those that might not be created upon version creation. This logic will skip the patch_optional dependency so the dependent task is not automatically created (correct), but this logic will still create the dependency link to the (nonexistent) task because the pre-generated task ID exists (not correct). To fix this, I filtered tasks from the task ID table so that for versions like periodic builds that create a subset of all possible tasks, they only generate task IDs for tasks that will actually be created.

  • Do not create task IDs for tasks that won't exist.
    • Add safety check to error if somehow we try to create a task that has no task ID.
  • Improve "Task dependencies" alert log to include the error.

Testing

  • Added unit tests. Verified that this unit test fails before the change, and passes afterwards.
  • Ran a periodic build in the sandbox to reproduce the issue of the task with a nonexistent dependency. Then applied my fix and verified that the next periodic build was fixed and the patch_optional dependency was ignored.

Documentation

Clarified in documentation that, despite the name of the field, patch_optional means the dependency is optional in all versions, not just patches. The docs already say this explicitly, but I thought it was worth clarifying that the name of the field doesn't correspond to what you'd expect it to do.

@Kimchelly Kimchelly requested a review from a team September 27, 2024 17:05
Copy link
Contributor

@hadjri hadjri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good find!


tasks, err := task.Find(task.ByVersion(v.Id))
s.NoError(err)
s.Require().Len(tasks, 2)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: don't need require here since we don't index the slice

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switched to assert.

@@ -742,6 +742,9 @@ func createTasksForBuild(ctx context.Context, creationInfo TaskCreationInfo) (ta
taskMap := make(map[string]*task.Task)
for _, t := range tasksToCreate {
id := execTable.GetId(creationInfo.Build.BuildVariant, t.Name)
if id == "" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can we move this into createOneTask for empty id protection against potential future uses of it?

@Kimchelly Kimchelly enabled auto-merge (squash) September 27, 2024 19:19
@Kimchelly Kimchelly merged commit 3774057 into evergreen-ci:main Sep 27, 2024
10 checks passed
@Kimchelly Kimchelly deleted the DEVPROD-10420_patch_optional_dep branch September 27, 2024 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants