Skip to content

feat: use proto streams to increase maximum module files payload #18268

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

Merged
merged 52 commits into from
Jun 13, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
e6b4635
feat: provisioners to stream over modules >4mb limit
Emyrk Jun 3, 2025
d115c5a
make gen
Emyrk Jun 3, 2025
dea4895
add chunk piece in response
Emyrk Jun 3, 2025
b5fceda
rename hash field
Emyrk Jun 3, 2025
99d4d54
remove upload type from the chunk
Emyrk Jun 3, 2025
e8d8b98
feat: handle uploading data files in runner
Emyrk Jun 3, 2025
fbfa08b
chore: implement first part of file streaming
Emyrk Jun 4, 2025
73151d1
test adding a stream on the server
Emyrk Jun 4, 2025
b61faaf
add completejob stream
Emyrk Jun 4, 2025
f547103
change upload behavior
Emyrk Jun 4, 2025
bcbf6ca
make gen
Emyrk Jun 5, 2025
1bd6b69
upload files independently
Emyrk Jun 5, 2025
931ac95
make gen
Emyrk Jun 5, 2025
fb8c284
select file by hash
Emyrk Jun 5, 2025
6b645d6
fix permissions
Emyrk Jun 6, 2025
9dc81db
add log for uploaded files
Emyrk Jun 6, 2025
124d366
remove dead file
Emyrk Jun 6, 2025
857e88c
ability to omit module file downloads
Emyrk Jun 6, 2025
5cf9beb
linting
Emyrk Jun 6, 2025
58b2371
linting
Emyrk Jun 6, 2025
e880894
make gen
Emyrk Jun 6, 2025
31d8e62
fixups
Emyrk Jun 6, 2025
bb2000a
linting
Emyrk Jun 9, 2025
6633548
linting
Emyrk Jun 9, 2025
b070e5a
linting
Emyrk Jun 9, 2025
1a70429
add unit tests and fuzz test
Emyrk Jun 9, 2025
0f056e8
unit testing
Emyrk Jun 9, 2025
1a8c658
comments
Emyrk Jun 9, 2025
4ec22d8
fixup test
Emyrk Jun 9, 2025
1c9df09
fixup dbmem to return unique files error
Emyrk Jun 9, 2025
c30607e
linting
Emyrk Jun 9, 2025
0484777
fmt
Emyrk Jun 9, 2025
a3cf121
linting
Emyrk Jun 9, 2025
3f7707a
linting
Emyrk Jun 9, 2025
0ec5d1b
Merge remote-tracking branch 'origin/main' into stevenmasley/4mb
Emyrk Jun 10, 2025
e50c8c3
update proto to reuse
Emyrk Jun 10, 2025
8cf7f5c
make gen
Emyrk Jun 10, 2025
28f83a2
fixup
Emyrk Jun 10, 2025
bb3d4ef
test fixup types
Emyrk Jun 10, 2025
74073cf
Merge remote-tracking branch 'origin/main' into stevenmasley/4mb
Emyrk Jun 11, 2025
c9575c5
add full_hash to complete job
Emyrk Jun 11, 2025
6b7e56e
Revert "add full_hash to complete job"
Emyrk Jun 11, 2025
24d6227
Reapply "add full_hash to complete job"
Emyrk Jun 11, 2025
4f343e6
chore: add hash check of uploaded file after planComplete
Emyrk Jun 11, 2025
539755b
bump provider version
Emyrk Jun 11, 2025
e4f49ab
linting
Emyrk Jun 11, 2025
363498a
nil bytes fail on the typescript
Emyrk Jun 11, 2025
02d8563
handle empty slices
Emyrk Jun 11, 2025
f1ce0ac
move module max to a constant
Emyrk Jun 12, 2025
f6bdf96
add 0 byte file test
Emyrk Jun 12, 2025
4f387ec
Merge branch 'main' into stevenmasley/4mb
Emyrk Jun 12, 2025
f3525c3
Merge branch 'main' into stevenmasley/4mb
Emyrk Jun 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: implement first part of file streaming
  • Loading branch information
Emyrk committed Jun 6, 2025
commit fbfa08ba4323bc8aa89b976458a8b7572b4a53cc
10 changes: 4 additions & 6 deletions provisioner/terraform/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@ import (
tfjson "github.com/hashicorp/terraform-json"
"go.opentelemetry.io/otel/attribute"
"golang.org/x/xerrors"
protobuf "google.golang.org/protobuf/proto"

"cdr.dev/slog"

"github.com/coder/coder/v2/coderd/database"
"github.com/coder/coder/v2/coderd/tracing"
"github.com/coder/coder/v2/codersdk/drpcsdk"
"github.com/coder/coder/v2/provisionersdk/proto"
)

Expand Down Expand Up @@ -357,10 +355,10 @@ func (e *executor) plan(ctx, killCtx context.Context, env, vars []string, logr l
ModuleFiles: moduleFiles,
}

if protobuf.Size(msg) > drpcsdk.MaxMessageSize {
e.logger.Warn(ctx, "cannot persist terraform modules, message payload too big", slog.F("archive_size", len(msg.ModuleFiles)))
msg.ModuleFiles = nil
}
//if protobuf.Size(msg) > drpcsdk.MaxMessageSize {
// e.logger.Warn(ctx, "cannot persist terraform modules, message payload too big", slog.F("archive_size", len(msg.ModuleFiles)))
// msg.ModuleFiles = nil
//}

return msg, nil
}
Expand Down
7 changes: 6 additions & 1 deletion provisioner/terraform/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (

"golang.org/x/xerrors"

"github.com/coder/coder/v2/coderd/util/xio"
"github.com/coder/coder/v2/provisionersdk/proto"
)

Expand Down Expand Up @@ -85,7 +86,11 @@ func GetModulesArchive(root fs.FS) ([]byte, error) {

empty := true
var b bytes.Buffer
w := tar.NewWriter(&b)

// Limit to 20MB for now.
// TODO: Determine what a reasonable limit is for modules
lw := xio.NewLimitWriter(&b, 20<<20)
w := tar.NewWriter(lw)

for _, it := range m.Modules {
// Check to make sure that the module is a remote module fetched by
Expand Down
1 change: 1 addition & 0 deletions provisionerd/provisionerd_internal_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package provisionerd
38 changes: 38 additions & 0 deletions provisionersdk/proto/dataupload.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions provisionersdk/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ import (
"golang.org/x/xerrors"

"cdr.dev/slog"
"github.com/coder/coder/v2/codersdk/drpcsdk"

protobuf "google.golang.org/protobuf/proto"

"github.com/coder/coder/v2/provisionersdk/proto"
)
Expand Down Expand Up @@ -161,6 +164,29 @@ func (s *Session) handleRequests() error {
return err
}
resp.Type = &proto.Response_Plan{Plan: complete}

if protobuf.Size(resp) > drpcsdk.MaxMessageSize {
// Send the modules over as a stream
s.Logger.Info(s.Context(), "plan response too large, sending modules as stream")
dataUp, chunks := proto.BytesToDataUpload(complete.ModuleFiles)

complete.ModuleFiles = nil // sent over the stream
resp.Type = &proto.Response_Plan{Plan: complete}

err := s.stream.Send(&proto.Response{Type: &proto.Response_DataUpload{DataUpload: dataUp}})
if err != nil {
complete.Error = fmt.Sprintf("send data upload: %s", err.Error())
} else {
for i, chunk := range chunks {
err := s.stream.Send(&proto.Response{Type: &proto.Response_ChunkPiece{ChunkPiece: chunk}})
if err != nil {
complete.Error = fmt.Sprintf("send data piece upload %d/%d: %s", i, dataUp.Chunks, err.Error())
break
}
}
}
}

if complete.Error == "" {
planned = true
}
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy