feat: persistent volumes with TTL for container/worktree storage (archie-core-j7v)
Add [containers].volume_ttl (default 72h). Persistent-storage repos get a per-repo bare Git cache (--reference-if-able --dissociate) so task worktrees clone fast without repeated full network clones, while staying fully independent of the cache's lifecycle — cache expiry can never corrupt an active or parked task's worktree. Docker repo volumes are labeled as Archie-owned and swept non-forced (a volume still attached to a running container survives and retries next cycle); the repo cache directory is swept by mtime. Both cleanups run at daemon startup and each poll cycle. Filed archie-core-756 (repo-wide golangci-lint baseline) and archie-core-340 (intermittent JetStream TempDir teardown flake) as separate follow-ups rather than scope-creeping them into this change.
This commit is contained in:
1 parent
827c108401
commit
e4368f70af
15 files changed
+562
-29
No files matched your search
@@ -18,10 +18,45 @@ import (
|
||||
"github.com/samcharles93/archie-core/internal/config"
|
||||
"github.com/samcharles93/archie-core/internal/forge"
|
||||
arnats "github.com/samcharles93/archie-core/internal/nats"
|
||||
"github.com/samcharles93/archie-core/internal/storage"
|
||||
"github.com/samcharles93/archie-core/internal/store"
|
||||
"github.com/samcharles93/archie-core/internal/taskrun"
|
||||
)
|
||||
|
||||
type cleanupStorage struct {
|
||||
ttl time.Duration
|
||||
}
|
||||
|
||||
func (s *cleanupStorage) Setup(context.Context, storage.TaskRef) ([]storage.Mount, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (s *cleanupStorage) Teardown(context.Context, storage.TaskRef) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *cleanupStorage) CleanupExpired(_ context.Context, ttl time.Duration) (int, error) {
|
||||
s.ttl = ttl
|
||||
return 2, nil
|
||||
}
|
||||
|
||||
func TestCleanupExpiredStorageUsesConfiguredTTL(t *testing.T) {
|
||||
backend := &cleanupStorage{}
|
||||
d := &Daemon{
|
||||
Cfg: config.Config{
|
||||
Containers: config.ContainerConfig{VolumeTTL: config.Duration(6 * time.Hour)},
|
||||
},
|
||||
Storage: backend,
|
||||
Log: slog.New(slog.DiscardHandler),
|
||||
}
|
||||
|
||||
d.cleanupExpiredStorage(context.Background())
|
||||
|
||||
if backend.ttl != 6*time.Hour {
|
||||
t.Fatalf("CleanupExpired ttl = %s, want 6h", backend.ttl)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTaskDispatcherEnforcesMaxConcurrency(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
Reference in new issue
Block a user