Navigation Menu

Skip to content

Commit

Permalink
feat(cleanup/purge): speeding up with runtime caching for stages
Browse files Browse the repository at this point in the history
Signed-off-by: Alexey Igrychev <alexey.igrychev@flant.com>
  • Loading branch information
alexey-igrychev committed Mar 17, 2022
1 parent bd03900 commit cbb31b2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/cleaning/purge.go
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cleaning/stage_manager/manager.go
Expand Up @@ -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
}
Expand Down
11 changes: 10 additions & 1 deletion pkg/storage/manager/storage_manager.go
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit cbb31b2

Please sign in to comment.