Skip to content

Commit

Permalink
Merge pull request #3512 from tonistiigi/v0.11.1-cherry-picks
Browse files Browse the repository at this point in the history
[v0.11] cherry picks
  • Loading branch information
tonistiigi authored Jan 17, 2023
2 parents e1d867e + 822a6ec commit b6051af
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 2 deletions.
4 changes: 4 additions & 0 deletions frontend/dockerfile/dockerfile2llb/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ func toDispatchState(ctx context.Context, dt []byte, opt ConvertOpt) (*dispatchS
opt.ContextLocalName = defaultContextLocalName
}

if opt.Warn == nil {
opt.Warn = func(string, string, [][]byte, *parser.Range) {}
}

platformOpt := buildPlatformOpt(&opt)

optMetaArgs := getPlatformArgs(platformOpt)
Expand Down
76 changes: 76 additions & 0 deletions frontend/dockerfile/dockerfile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ var allTests = integration.TestFuncs(
testSecretSSHProvenance,
testNilProvenance,
testSBOMScannerArgs,
testMultiPlatformWarnings,
)

// Tests that depend on the `security.*` entitlements
Expand Down Expand Up @@ -6394,6 +6395,81 @@ ARG BUILDKIT_SBOM_SCAN_STAGE=true
require.Equal(t, 1, len(att.LayersRaw))
}

// #3495
func testMultiPlatformWarnings(t *testing.T, sb integration.Sandbox) {
f := getFrontend(t, sb)

// empty line in here is intentional to cause line continuation warning
dockerfile := []byte(`
FROM scratch
COPY Dockerfile \
.
`)

dir, err := integration.Tmpdir(
t,
fstest.CreateFile("Dockerfile", dockerfile, 0600),
)
require.NoError(t, err)
defer os.RemoveAll(dir)

c, err := client.New(sb.Context(), sb.Address())
require.NoError(t, err)
defer c.Close()

status := make(chan *client.SolveStatus)
statusDone := make(chan struct{})
done := make(chan struct{})

var warnings []*client.VertexWarning

go func() {
defer close(statusDone)
for {
select {
case st, ok := <-status:
if !ok {
return
}
warnings = append(warnings, st.Warnings...)
case <-done:
return
}
}
}()

_, err = f.Solve(sb.Context(), c, client.SolveOpt{
FrontendAttrs: map[string]string{
"platform": "linux/amd64,linux/arm64",
},
LocalDirs: map[string]string{
builder.DefaultLocalNameDockerfile: dir,
builder.DefaultLocalNameContext: dir,
},
}, status)
require.NoError(t, err)

select {
case <-statusDone:
case <-time.After(10 * time.Second):
close(done)
}

<-statusDone

// two platforms only show one warning
require.Equal(t, 1, len(warnings))

w := warnings[0]

require.Equal(t, "Empty continuation line found in: COPY Dockerfile .", string(w.Short))
require.Equal(t, 1, len(w.Detail))
require.Equal(t, "Empty continuation lines will become errors in a future release", string(w.Detail[0]))
require.Equal(t, "https://github.com/moby/moby/pull/33719", w.URL)
require.Equal(t, 1, w.Level)
}

func runShell(dir string, cmds ...string) error {
for _, args := range cmds {
var cmd *exec.Cmd
Expand Down
7 changes: 6 additions & 1 deletion session/sshforward/copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ func Copy(ctx context.Context, conn io.ReadWriteCloser, stream Stream, closeStre
if err := stream.RecvMsg(p); err != nil {
if err == io.EOF {
// indicates client performed CloseSend, but they may still be
// reading data, so don't close conn yet
// reading data
if conn, ok := conn.(interface {
CloseWrite() error
}); ok {
conn.CloseWrite()
}
return nil
}
conn.Close()
Expand Down
2 changes: 1 addition & 1 deletion util/tracing/detect/otlp.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func init() {
}

func otlpExporter() (sdktrace.SpanExporter, error) {
set := os.Getenv("OTEL_TRACES_EXPORTER") == "otpl" || os.Getenv("OTEL_EXPORTER_OTLP_ENDPOINT") != "" || os.Getenv("OTEL_EXPORTER_OTLP_TRACES_ENDPOINT") != ""
set := os.Getenv("OTEL_TRACES_EXPORTER") == "otlp" || os.Getenv("OTEL_EXPORTER_OTLP_ENDPOINT") != "" || os.Getenv("OTEL_EXPORTER_OTLP_TRACES_ENDPOINT") != ""
if !set {
return nil, nil
}
Expand Down

0 comments on commit b6051af

Please sign in to comment.