Skip to content
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

Commit all refs aside from "run once" group #64

Merged
merged 1 commit into from
May 27, 2024
Merged
Changes from all commits
Commits
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
29 changes: 17 additions & 12 deletions solver/simple.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,6 @@ func (s *simpleSolver) build(ctx context.Context, job *Job, e Edge) (CachedResul
})
}

err := s.commitRefFunc(ctx, ret)
if err != nil {
return nil, err
}

return NewCachedResult(ret, expKeys), nil
}

Expand Down Expand Up @@ -210,6 +205,15 @@ func (s *simpleSolver) buildOne(ctx context.Context, runCacheMan *cacheKeyManage
}
}

// Some operations need to be left in a mutable state. All others need to be
// committed in order to be cached and loaded correctly.
if !isRunOnce {
err = s.commitRefFunc(ctx, res)
if err != nil {
return nil, "", err
}
}

err = s.resultSource.Link(ctx, cacheKey, res.ID())
if err != nil {
return nil, "", err
Expand Down Expand Up @@ -445,14 +449,8 @@ func (m *cacheKeyManager) cacheKeyRecurse(ctx context.Context, d digest.Digest,
io.WriteString(h, c.salt)
}

for _, in := range c.inputs {
err := m.cacheKeyRecurse(ctx, in, h)
if err != nil {
return err
}
}

io.WriteString(h, c.digest.String())

for _, dep := range c.deps {
if dep.selector != "" {
io.WriteString(h, dep.selector.String())
Expand All @@ -462,6 +460,13 @@ func (m *cacheKeyManager) cacheKeyRecurse(ctx context.Context, d digest.Digest,
}
}

for _, in := range c.inputs {
err := m.cacheKeyRecurse(ctx, in, h)
if err != nil {
return err
}
}

return nil
}

Expand Down
Loading