Skip to content

Commit 4b56395

Browse files
committed
filesync: append rather than replace grpc md.
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]>
1 parent 687091b commit 4b56395

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

session/filesync/filesync.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"unicode"
1212

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

318319
client := NewFileSendClient(c.Conn())
319320

320-
opts := make(map[string][]string, len(md))
321+
opts, ok := metadata.FromOutgoingContext(ctx)
322+
if !ok {
323+
opts = make(map[string][]string, len(md))
324+
}
321325
for k, v := range md {
322-
opts[keyExporterMetaPrefix+k] = []string{v}
326+
k := keyExporterMetaPrefix + k
327+
if existingVal, ok := opts[k]; ok {
328+
bklog.G(ctx).Warnf("overwriting grpc metadata key %q from value %+v to %+v", k, existingVal, v)
329+
}
330+
opts[k] = []string{v}
323331
}
324332

325333
ctx = metadata.NewOutgoingContext(ctx, opts)

0 commit comments

Comments
 (0)