Merge pull request #64 from entireio/soph/http-stale-pool-fix · Entire

Merge pull request #64 from entireio/soph/http-stale-pool-fix

957831e→main·

Fix materialized push against CDN-fronted HTTP targets (Cloudflare)

Changes

7

3 unmodified lines

4
5
6
7
7
8
9
10

3 unmodified lines

require (
    github.com/go-git/go-billy/v6 v6.0.0-alpha.1
    github.com/go-git/go-git/v6 v6.0.0-alpha.4
    github.com/go-git/go-git/v6 v6.0.0-alpha.4.0.20260521151600-590487407c38
    github.com/spf13/cobra v1.10.2
    github.com/stretchr/testify v1.11.1
    github.com/zalando/go-keyring v0.2.8
)

Mgo.mod+1/-1

23 unmodified lines

24
25
26
27
28
27
28
29
30
31

23 unmodified lines

github.com/go-git/go-billy/v6 v6.0.0-alpha.1/go.mod h1:eaCUpHbedW7//EwcYmUDfJe2N6sJC9O12AT0OTqJR1E=
github.com/go-git/go-git-fixtures/v6 v6.0.0-alpha.1 h1:gmqi2jvsreu0s8JMLylYDFq4sbjHwwlhktMw0DUg3mA=
github.com/go-git/go-git-fixtures/v6 v6.0.0-alpha.1/go.mod h1:ECf1MqJlBdYpKggBrOXjo/0EnvRZx6D++I86UYjPgAQ=
github.com/go-git/go-git/v6 v6.0.0-alpha.4 h1:aDTc2UGanmaE7FkGLSlBEB9nohMnQ+RKXcfq/D+esDQ=
github.com/go-git/go-git/v6 v6.0.0-alpha.4/go.mod h1:4ODa/G7hPWrh4Y+7lmt59Ij3zW38IEfvRoAZxLYYBhc=
github.com/go-git/go-git/v6 v6.0.0-alpha.4.0.20260521151600-590487407c38 h1:uA2L2RZQTkmvHjzBqMNMFR+UWdjicJBc0UqhCrgodZs=
github.com/go-git/go-git/v6 v6.0.0-alpha.4.0.20260521151600-590487407c38/go.mod h1:4ODa/G7hPWrh4Y+7lmt59Ij3zW38IEfvRoAZxLYYBhc=
github.com/godbus/dbus/v5 v5.2.2 h1:TUR3TgtSVDmjiXOgAAyaZbYmIeP3DPkld3jgKGV8mXQ=
github.com/godbus/dbus/v5 v5.2.2/go.mod h1:3AAv2+hPq5rdnr5txxxRwiGjPXamgoIHgz9FPBfOp3c=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=

Mgo.sum+2/-2

7 unmodified lines

8
9
10
11
12
13
14
15
185 unmodified lines

201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
12 unmodified lines

228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
223
243
225
244
245
246
247
248
249
250
251
10 unmodified lines

262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402

7 unmodified lines

"io"
    "os"
    "strings"
    "sync/atomic"
    "time"

"github.com/go-git/go-git/v6/plumbing"
    "github.com/go-git/go-git/v6/plumbing/format/packfile"
185 unmodified lines

}

// PushObjects pushes locally-materialized objects to the target.

// Delta selection runs synchronously up front via
// packfile.DeltaSelector. The selected objects are then handed back to
// a packfile.Encoder behind a passthrough ObjectSelector, so the
// encoder's write phase (Encode → encode(objects)) streams pack bytes
// continuously into an io.Pipe to the HTTP request body. This avoids
// the mid-stream stall that occurs when Encode runs selection itself —
// CDN edges treat the resulting idle gap as a stalled upload and close
// the connection. See go-git PR #2142 for the API hook.
func PushObjects(
    ctx context.Context,
    conn Conn,

stopSelect := startSelectionProgress(progressDest)
objects, err := packfile.NewDeltaSelector(store).ObjectsToPack(hashes, 10)
stopSelect(len(objects), err)
if err != nil {
    return fmt.Errorf("select objects to pack: %w", err)
}

useRefDeltas := !adv.Capabilities.Supports(capability.OFSDelta)
pr, pw := io.Pipe()
done := make(chan error, 1)

go func() {
    enc := packfile.NewEncoder(pw, store, useRefDeltas)
cw := &countingWriter{w: pw}
stopWrite := startPackWriteProgress(cw, progressDest)
defer stopWrite()
enc := packfile.NewEncoder(cw, store, useRefDeltas,
        packfile.WithObjectSelector(precomputedSelector{objects: objects}))
if _, err := enc.Encode(hashes, 10); err != nil {
    done <- pw.CloseWithError(fmt.Errorf("encode packfile: %w", err))
    return
}