Skip to content

Errors are being cached #10320

@marcosnils

Description

@marcosnils

Problem

Given the following example:

package main

import (
	"context"
	"time"
)

type CacheErrorsTest struct{}

func (m *CacheErrorsTest) Test(ctx context.Context) {
	c := dag.Container().From("alpine").
		WithMountedCache("/lala", dag.CacheVolume("cache")).
		WithEnvVariable("BUST", time.Now().String()).
		WithExec([]string{"rm", "-rf", "/lala/foo.txt"})

	_, err := c.WithExec([]string{"ls", "/lala/foo.txt"}).Sync(ctx)

	if err == nil {
		panic("should error")
	}

	c.WithExec([]string{"touch", "/lala/foo.txt"}).Sync(ctx)

	_, err = c.
		//WithEnvVariable("BUST", time.Now().String()).  uncomment to make the test pass
		WithExec([]string{"ls", "/lala/foo.txt"}).Sync(ctx)

	if err != nil {
		panic("should not error")
	}

}

You'll notice that without a cache bust, the second ls exec will fail given that it will return the cached error response from the first one.

Seem to me that this comes from the dagQL level somehow given that the trace (https://v3.dagger.cloud/marcos-test/traces/000a7698719eb365026ed03cc27ed7e1?span=06966b2aa4707511) doesn't show the second operation as being cached from buildkit's side.

Solution

The test should pass since we shouldn't be caching error responses.

Metadata

Metadata

Assignees

Labels

area/engineAbout dagger core engine

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions