about summary refs log tree commit diff
path: root/tools/nixery/server/builder/builder.go
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2019-10-03T10·23+0100
committerVincent Ambo <github@tazj.in>2019-10-03T12·21+0100
commit355fe3f5ec05c3c698ea3ba21a5d57454daeceef (patch)
treeb0d67ab7a9cc66eb26e2be225a60ec87fb99b7fb /tools/nixery/server/builder/builder.go
parent1308a6e1fd8e5f9cbd0d6b5d872628ec234114d5 (diff)
feat(server): Reintroduce manifest caching to GCS
The new builder now caches and reads cached manifests to/from GCS. The
in-memory cache is disabled, as manifests are no longer written to
local file and the caching of file paths does not work (unless we
reintroduce reading/writing from temp files as part of the local
cache).
Diffstat (limited to 'tools/nixery/server/builder/builder.go')
-rw-r--r--tools/nixery/server/builder/builder.go15
1 files changed, 12 insertions, 3 deletions
diff --git a/tools/nixery/server/builder/builder.go b/tools/nixery/server/builder/builder.go
index d0650648fbcb..f3342f9918f8 100644
--- a/tools/nixery/server/builder/builder.go
+++ b/tools/nixery/server/builder/builder.go
@@ -366,7 +366,14 @@ func uploadHashLayer(ctx context.Context, s *State, key string, data io.Reader)
 }
 
 func BuildImage(ctx context.Context, s *State, image *Image) (*BuildResult, error) {
-	// TODO(tazjin): Use the build cache
+	key := s.Cfg.Pkgs.CacheKey(image.Packages, image.Tag)
+	if key != "" {
+		if m, c := manifestFromCache(ctx, s, key); c {
+			return &BuildResult{
+				Manifest: m,
+			}, nil
+		}
+	}
 
 	imageResult, err := prepareImage(s, image)
 	if err != nil {
@@ -410,10 +417,12 @@ func BuildImage(ctx context.Context, s *State, image *Image) (*BuildResult, erro
 		return nil, err
 	}
 
+	if key != "" {
+		go cacheManifest(ctx, s, key, m)
+	}
+
 	result := BuildResult{
 		Manifest: m,
 	}
-	// TODO: cache manifest
-
 	return &result, nil
 }