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

Support clients that don't enable side-band or side-band-64k #41

Merged
merged 8 commits into from
Apr 6, 2023

Conversation

spraints
Copy link
Member

@spraints spraints commented Apr 6, 2023

Some clients don't request side-band data when doing a push. In those cases, spokes-receive-pack needs to write the report only, without nesting it in a sideband packet. spokes-receive-pack was already handling index-pack output correctly, though it doesn't need to pass as many flags when the sideband is disabled.

When the client doesn't request sideband information, the report should
be sent directly, not in a sideband message, and there should be no
other sideband messages (i.e. from index-pack).
Most git clients enable the side-band or side-band-64k capability. When
they do this, the report ("unpack ok" and per-ref status) will be sent
nested in a sideband 1 packet. However, git clients aren't required to
do this, and when they don't the report is supposed to be written
without getting nested. So that's what this change does.
The empty pack is the same for all of these tests, so we can generate it
once, store it in the repo, and avoid the complexity of shelling out to
git during the tests.

Here's how I generated the file:

  $ git pack-objects --revs --stdout > internal/integration/testdata/empty.pack </dev/null
  Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
@spraints spraints requested a review from a team April 6, 2023 14:11
When reading the output from spokes-receive-pack, sometimes we get "file
already closed" instead of EOF at the end of the output. In that case,
when there is some data, just log the error and proceed to parsing the
data.

This is an attempt to fix or at least learn more about errors like the
one in https://github.com/github/spokes-receive-pack/actions/runs/4629813916/jobs/8190557968.
@spraints spraints merged commit 1336e5f into main Apr 6, 2023
@spraints spraints deleted the better-sideband-support branch April 6, 2023 14:36
Comment on lines -64 to +68
return nil, "", nil, err
if len(data) > 0 {
t.Logf("got data, but there was an error: %v", err)
} else {
return nil, "", nil, err
}
Copy link
Member Author

Choose a reason for hiding this comment

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

This change works around a similar problem to the one described in hashicorp/go-plugin#116, where there's a race between reads from a pipe and exec.Cmd.Wait closing the pipe after the process exits.

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