@@ -864,11 +864,16 @@ func (st *buildStatus) cleanForSnapshot(bc buildlet.Client) error {
864
864
func (st * buildStatus ) writeSnapshot (bc buildlet.Client ) (err error ) {
865
865
sp := st .CreateSpan ("write_snapshot_to_gcs" )
866
866
defer func () { sp .Done (err ) }()
867
- // This should happen in 15 seconds or so, but I saw timeouts
868
- // a couple times at 1 minute. Some buildlets might be far
869
- // away on the network, so be more lenient. The timeout mostly
870
- // is here to prevent infinite hangs.
871
- ctx , cancel := context .WithTimeout (st .ctx , 5 * time .Minute )
867
+ // A typical Go snapshot tarball in April 2022 is around 150 MB in size.
868
+ // Builders with a fast uplink speed can upload the tar within seconds or minutes.
869
+ // Reverse builders might be far away on the network, so be more lenient for them.
870
+ // (Fast builds require a sufficiently fast uplink speed or turning off snapshots,
871
+ // so the timeout here is mostly an upper bound to prevent infinite hangs.)
872
+ timeout := 5 * time .Minute
873
+ if st .conf .IsReverse () {
874
+ timeout *= 3
875
+ }
876
+ ctx , cancel := context .WithTimeout (st .ctx , timeout )
872
877
defer cancel ()
873
878
874
879
tsp := st .CreateSpan ("fetch_snapshot_reader_from_buildlet" )
@@ -890,8 +895,8 @@ func (st *buildStatus) writeSnapshot(bc buildlet.Client) (err error) {
890
895
wr := sc .Bucket (bucket ).Object (st .SnapshotObjectName ()).NewWriter (ctx )
891
896
wr .ContentType = "application/octet-stream"
892
897
wr .ACL = append (wr .ACL , storage.ACLRule {Entity : storage .AllUsers , Role : storage .RoleReader })
893
- if _ , err := io .Copy (wr , tgz ); err != nil {
894
- st .logf ("failed to write snapshot to GCS: %v" , err )
898
+ if n , err := io .Copy (wr , tgz ); err != nil {
899
+ st .logf ("failed to write snapshot to GCS after copying %d bytes : %v" , n , err )
895
900
return err
896
901
}
897
902
0 commit comments