Skip to content

Commit

Permalink
filesync: append rather than replace grpc md.
Browse files Browse the repository at this point in the history
Before this, CopyFileWriter just used metadata.NewOutgoingContext to set
metadata, which results in any pre-existing metadata from the provided
context to be removed.

Now, it gets the current metadata and then sets its own on top of that,
so any pre-existing unrelated metadata is retained.

Signed-off-by: Erik Sipsma <[email protected]>
  • Loading branch information
sipsma committed Jul 25, 2023
1 parent 687091b commit 4b56395
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions session/filesync/filesync.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"unicode"

"github.com/moby/buildkit/session"
"github.com/moby/buildkit/util/bklog"
"github.com/pkg/errors"
"github.com/tonistiigi/fsutil"
fstypes "github.com/tonistiigi/fsutil/types"
Expand Down Expand Up @@ -317,9 +318,16 @@ func CopyFileWriter(ctx context.Context, md map[string]string, c session.Caller)

client := NewFileSendClient(c.Conn())

opts := make(map[string][]string, len(md))
opts, ok := metadata.FromOutgoingContext(ctx)
if !ok {
opts = make(map[string][]string, len(md))
}
for k, v := range md {
opts[keyExporterMetaPrefix+k] = []string{v}
k := keyExporterMetaPrefix + k
if existingVal, ok := opts[k]; ok {
bklog.G(ctx).Warnf("overwriting grpc metadata key %q from value %+v to %+v", k, existingVal, v)
}
opts[k] = []string{v}
}

ctx = metadata.NewOutgoingContext(ctx, opts)
Expand Down

0 comments on commit 4b56395

Please sign in to comment.