Skip to content
Permalink
Browse files
feat(cleanup/purge): speeding up with runtime caching for stages
Signed-off-by: Alexey Igrychev <alexey.igrychev@flant.com>
  • Loading branch information
alexey-igrychev committed Mar 17, 2022
1 parent bd03900 commit cbb31b29778a94bd0a900eee021a4967c626217b
Showing with 12 additions and 3 deletions.
  1. +1 −1 pkg/cleaning/purge.go
  2. +1 −1 pkg/cleaning/stage_manager/manager.go
  3. +10 −1 pkg/storage/manager/storage_manager.go
@@ -38,7 +38,7 @@ type purgeManager struct {

func (m *purgeManager) run(ctx context.Context) error {
if err := logboek.Context(ctx).Default().LogProcess("Deleting stages").DoError(func() error {
stages, err := m.StorageManager.GetStageDescriptionList(ctx)
stages, err := m.StorageManager.GetStageDescriptionListWithCache(ctx)
if err != nil {
return err
}
@@ -63,7 +63,7 @@ func (m *Manager) newImageMetadata(imageName string, stageID string) *imageMetad
}

func (m *Manager) InitStages(ctx context.Context, storageManager manager.StorageManagerInterface) error {
stageDescriptionList, err := storageManager.GetStageDescriptionList(ctx)
stageDescriptionList, err := storageManager.GetStageDescriptionListWithCache(ctx)
if err != nil {
return err
}
@@ -63,6 +63,7 @@ type StorageManagerInterface interface {
GetStagesByDigest(ctx context.Context, stageName, stageDigest string) ([]*image.StageDescription, error)
GetStagesByDigestFromStagesStorage(ctx context.Context, stageName, stageDigest string, stagesStorage storage.StagesStorage) ([]*image.StageDescription, error)
GetStageDescriptionList(ctx context.Context) ([]*image.StageDescription, error)
GetStageDescriptionListWithCache(ctx context.Context) ([]*image.StageDescription, error)
GetFinalStageDescriptionList(ctx context.Context) ([]*image.StageDescription, error)

FetchStage(ctx context.Context, containerRuntime container_runtime.ContainerRuntime, stg stage.Interface) error
@@ -214,8 +215,16 @@ func (m *StorageManager) MaxNumberOfWorkers() int {
return 1
}

func (m *StorageManager) GetStageDescriptionListWithCache(ctx context.Context) ([]*image.StageDescription, error) {
return m.getStageDescriptionList(ctx, storage.WithCache())
}

func (m *StorageManager) GetStageDescriptionList(ctx context.Context) ([]*image.StageDescription, error) {
stageIDs, err := m.StagesStorage.GetStagesIDs(ctx, m.ProjectName)
return m.getStageDescriptionList(ctx)
}

func (m *StorageManager) getStageDescriptionList(ctx context.Context, opts ...storage.Option) ([]*image.StageDescription, error) {
stageIDs, err := m.StagesStorage.GetStagesIDs(ctx, m.ProjectName, opts...)
if err != nil {
return nil, fmt.Errorf("error getting stages ids from %s: %s", m.StagesStorage, err)
}

0 comments on commit cbb31b2

Please sign in to comment.