Skip to content

Ensure if-dependency edges don't pull in unselected tasks during target phase#917

Open
ahal wants to merge 1 commit intotaskcluster:mainfrom
ahal:ahal/push-xnxwptstknpm
Open

Ensure if-dependency edges don't pull in unselected tasks during target phase#917
ahal wants to merge 1 commit intotaskcluster:mainfrom
ahal:ahal/push-xnxwptstknpm

Conversation

@ahal
Copy link
Collaborator

@ahal ahal commented Mar 6, 2026

No description provided.

@ahal ahal self-assigned this Mar 6, 2026
@ahal ahal force-pushed the ahal/push-xnxwptstknpm branch 2 times, most recently from 4ff66be to a28e1c2 Compare March 11, 2026 14:46
@ahal ahal changed the title WIP: apply if-dependencies at target phase Ensure if-dependency edges don't pull in unselected tasks during target phase Mar 11, 2026
@ahal ahal marked this pull request as ready for review March 11, 2026 14:47
@ahal ahal requested a review from a team as a code owner March 11, 2026 14:47
@ahal ahal requested a review from bhearsum March 11, 2026 14:47
@Eijebong
Copy link
Contributor

Does this fix #710 ?

@ahal
Copy link
Collaborator Author

ahal commented Mar 11, 2026

Yes! Forgot about that.. I'll add it to the commit message

BREAKING CHANGE: Tasks will no longer pull `if-dependencies` in at the
target phase.

It's now possible for a task with multiple `if-dependencies` to run
after one task, without also causing the other to run.

Bug: 2020718
Issue: taskcluster#710
@ahal ahal force-pushed the ahal/push-xnxwptstknpm branch from a28e1c2 to 5f87817 Compare March 11, 2026 16:45
@ahal
Copy link
Collaborator Author

ahal commented Mar 11, 2026

Hm, though it would only impact the if-dependencies.. Should we use the same logic for soft-dependencies?

I think I'd want to do it in a follow-up as there is some time pressure to fixing this for if-dependencies. The bug is currently causing some havoc in Gecko.

Copy link
Contributor

@Eijebong Eijebong left a comment

Choose a reason for hiding this comment

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

I think this is slightly wrong? If a task is both an if-dep for one task and a hard dep for another, the if-dep edge gets dropped.

def test_if_deps_bork(maketgg):
    tgg = maketgg(
        target_tasks=["u-t-0", "v-t-0"],
        kinds=[
            ("base", {}),
            (
                "v",
                {
                    "task-defaults": {
                        "dependencies": {"base": "base-t-0"},
                    }
                },
            ),
            (
                "u",
                {
                    "task-defaults": {
                        "dependencies": {"if-dep": "base-t-0"},
                        "if-dependencies": ["base-t-0"],
                    }
                },
            ),
        ],
    )

    target_graph = tgg.target_task_graph

    assert "u-t-0" in target_graph.tasks
    assert "v-t-0" in target_graph.tasks
    assert "base-t-0" in target_graph.tasks

    edges = target_graph.graph.edges
    assert ("u-t-0", "base-t-0", "if-dep") in edges

@jcristau
Copy link
Contributor

I worry a bit about unintended consequences here, for tasks that might expect that if they're running then all their dependencies have also run, not just one of them.

@ahal
Copy link
Collaborator Author

ahal commented Mar 12, 2026

I think this is slightly wrong? If a task is both an if-dep for one task and a hard dep for another, the if-dep edge gets dropped.

Is that wrong though? Tbh, that sounds like intuitively what I'd expect. But I guess part of the problem is that this behaviour is all undefined and everyone has a slightly different idea of what's intuitive.

But specifically to this question, why should the existence of a hard dep have any bearing on the how the if-deps are treated?

@ahal
Copy link
Collaborator Author

ahal commented Mar 12, 2026

I worry a bit about unintended consequences here, for tasks that might expect that if they're running then all their dependencies have also run, not just one of them.

For sure, definitely a backwards incompatible change. I guess we could pretty easily audit Gecko to see where if-dependencies are actually being used.

In practice I don't think this will be a huge issue though? Like if a task has that expectation it feels like they shouldn't be using if-dependencies in the first place because I believe it's already possible for this to not be the case depending on how the optimization shakes out.

@Eijebong
Copy link
Contributor

But specifically to this question, why should the existence of a hard dep have any bearing on the how the if-deps are treated?

Because both u-t-0 and base-t-0 are in the graph, with base-t-0 being brought up not as target but because of v-t-0. I'd expect a task that defines something as a dependency to keep the edge on said dependency (which it doesn't).

@ahal
Copy link
Collaborator Author

ahal commented Mar 12, 2026

I believe it's already possible for this to not be the case depending on how the optimization shakes out.

Actually this appears to be incorrect. I wrote a quick test to try it out and as long as one if-dep doesn't get optimized away, the others appear to get pulled in as well..

This feels surprising and wrong to me, but maybe I'm not thinking of the use cases for it properly?

@ahal
Copy link
Collaborator Author

ahal commented Mar 12, 2026

Because both u-t-0 and base-t-0 are in the graph, with base-t-0 being brought up not as target but because of v-t-0. I'd expect a task that defines something as a dependency to keep the edge on said dependency (which it doesn't).

Oh I see, that makes sense. Before fixing this edge case however, I think we need to agree on what the behaviour of if-dependencies ought to be. As is this patch makes what happens in the target phase inconsistent with what happens at the optimization phase.. which I'm not in favour of.

Intuitively I kind of think we should fix the optimization phase to follow this PR. But is it worth breaking backwards compat? If we decide not to fix this, it does mean we need to stop using if-dependencies for code coverage in Gecko.

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.

3 participants