Skip to content

fix: flake on TestSSHAuthSockPathHandling test - #8574

Merged
jedevc merged 1 commit into
dagger:mainfrom
grouville:fix-ssh-flake
Sep 26, 2024
Merged

jedevc merged 1 commit into
dagger:mainfrom
grouville:fix-ssh-flake

Conversation

@grouville

@grouville grouville commented Sep 25, 2024 •

Copy link
Copy Markdown
Member

Closes #8571

When testing the TestSSHAuthSockPathHandling, Alex encountered rightfully a flake on this test, leading to this error:

Error: module at source dir "" doesn't exist or is invalid

It turns out that the error comes from the tests being run in parallel whilst relying on the same client

More context here. After the change, no flake after 30 runs on my side

Still a bit surprised that in a nested environment, when interacting with the host, the same client cannot be used in parallel. Is it my test / setup that is wrong or is it by-design / expected ?

The very reason that it sometimes work would be that one of the test sets the nested SESSION's env vars prior the second one's erasing the HOME var, or before ?

When testing the TestSSHAuthSockPathHandling, Alex encountered
rightfully a flake on this test, leading to this error:

```
Error: module at source dir "" doesn't exist or is invalid
```

It turns out that the error comes from the tests being run in parallel
whilst relying on the same client

Signed-off-by: Guillaume de Rouville <[email protected]>
@sipsma

sipsma commented Sep 25, 2024

Copy link
Copy Markdown
Contributor

The error message you were getting here is very weird, poked around and realized that if you look in the engine logs you actually can see:

[buildkit] [client=2zpsohynpqyijy61a4upbhlt6] #3 git://gitlab.com/dagger-modules/private/test/more/dagger-test-modules-private.git
[buildkit] [client=2zpsohynpqyijy61a4upbhlt6] #3 ERROR: NotFound: rpc error: code = NotFound desc = socket xxh3:f9b3115dbb65e64e not found

So I think this is actually related to #8385

The reason the error message ends up being module at source dir "" doesn't exist or is invalid is not 100% clear to me yet, didn't dig in that deeply yet, but it has something to do with the fact that this line is saying the Git module source config file doesn't exist yet.

  • I'm guessing that it doesn't exist because of the error that showed up in the logs above? But would have liked this to fail more cleanly
  • Also the error message itself is extra confusing because it is assuming the module was local, not git (hence the source dir "" part of the message). This should probably be improved separately.

I'll keep poking at this for a few in parallel with you since it turns out to be one the good flakes that are actually reproducible locally 🎉


If it comes down to it, I'm totally fine merging this PR as is to avoid the flakes. These nested exec setups are not anything close to what real world users would do, so it's not a huge loss of test coverage if we just avoid whatever this problem is by giving each test case its own client. Worth a little bit of effort to dig into though in case it reveals any problems that are user-facing after all though.

@sipsma

sipsma commented Sep 26, 2024

Copy link
Copy Markdown
Contributor

After some println debugging, the problem appears to be that when concurrent requests are made by the clients, sometimes only one of the Query.git calls actually executes between them? At least, when I add a log to this line and the tests fail, only one of the clients actually prints anything from it. I can however see both clients are hitting the git source implementation in buildkit, which is where the socket is requested and fails in one of them (the one with the missing Query.git call).

So that all adds up: a client never executes Query.git, which is where the socket is registered in its store, and then when buildkit goes to the store to ask for the socket, it's not there.

You can also see this by running the tests with -parallel=1 and without the change in this PR: that also avoids the flake for me.

I think the reason only one of the clients actually executes Query.git is dagql caching: that API is not marked impure and so it gets deduped based on its dagql ID, which is identical for the two clients.

The last thing I don't understand is the fact that when I marked Query.git as impure (which technically would be more correct since it can end up implicitly accessing+registering these host dependent sockets), I still get the same behavior as before.

  • I'll poke at this for a little bit longer, but consider it separate from all this.

Overall, I don't think it's really productive for us to care about any of this. These requirements for making some API calls impure because there could technically be multiple nested clients in the same session using the same paths for different resources is something that exists only inside our test framework, not the real world. So we are honestly better off ignoring things like this for now IMO rather than going down unnecessary rabbit holes (we have plenty of necessary rabbit holes first).

@grouville tl;dr lets go with just giving each test case its own client, as you did in this PR. It might be worth a minute of your time to check if any of the other SSH socket related tests are sharing a dagger client and make the same change to this ones.

cc @vito (related to impurity, caching and all that fun stuff if you're in the mood)

@sipsma sipsma left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, with added suggestion mentioned in other comment that it might be worth making the same change to the other SSH socket related test cases if needed.

@jedevc

jedevc commented Sep 26, 2024

Copy link
Copy Markdown
Contributor

Ohhh @sipsma could it be because the socket access only actually occurs in tree? We wouldn't want to mark Query.git as impure, we'd want to mark Git.tree and Git.tags.

Still seems good to me though, but also... confused. I feel like this only started appearing yesterday, about when I merged #8318. But really really unsure as to why this would have any effect at all.

@jedevc
jedevc merged commit 72a848a into dagger:main Sep 26, 2024
vikram-dagger pushed a commit to vikram-dagger/dagger that referenced this pull request Sep 26, 2024
When testing the TestSSHAuthSockPathHandling, Alex encountered
rightfully a flake on this test, leading to this error:

```
Error: module at source dir "" doesn't exist or is invalid
```

It turns out that the error comes from the tests being run in parallel
whilst relying on the same client

Signed-off-by: Guillaume de Rouville <[email protected]>
Co-authored-by: Guillaume de Rouville <[email protected]>
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.

Flake?: TestSSHAuthSockPathHandling

3 participants