-
Notifications
You must be signed in to change notification settings - Fork 203
/
conveyor_with_retry.go
62 lines (53 loc) · 1.92 KB
/
conveyor_with_retry.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package build
import (
"context"
"github.com/werf/werf/pkg/config"
"github.com/werf/werf/pkg/container_backend"
"github.com/werf/werf/pkg/giterminism_manager"
"github.com/werf/werf/pkg/storage"
"github.com/werf/werf/pkg/storage/manager"
)
type ConveyorWithRetryWrapper struct {
WerfConfig *config.WerfConfig
GiterminismManager giterminism_manager.Interface
ProjectDir string
BaseTmpDir string
SshAuthSock string
ContainerBackend container_backend.ContainerBackend
StorageManager *manager.StorageManager
StorageLockManager storage.LockManager
ConveyorOptions ConveyorOptions
}
func NewConveyorWithRetryWrapper(werfConfig *config.WerfConfig, giterminismManager giterminism_manager.Interface, projectDir, baseTmpDir, sshAuthSock string, containerBackend container_backend.ContainerBackend, storageManager *manager.StorageManager, storageLockManager storage.LockManager, opts ConveyorOptions) *ConveyorWithRetryWrapper {
return &ConveyorWithRetryWrapper{
WerfConfig: werfConfig,
GiterminismManager: giterminismManager,
ProjectDir: projectDir,
BaseTmpDir: baseTmpDir,
SshAuthSock: sshAuthSock,
ContainerBackend: containerBackend,
StorageManager: storageManager,
StorageLockManager: storageLockManager,
ConveyorOptions: opts,
}
}
func (wrapper *ConveyorWithRetryWrapper) Terminate() error {
return nil
}
func (wrapper *ConveyorWithRetryWrapper) WithRetryBlock(ctx context.Context, f func(c *Conveyor) error) error {
return manager.RetryOnUnexpectedStagesStorageState(ctx, wrapper.StorageManager, func() error {
newConveyor := NewConveyor(
wrapper.WerfConfig,
wrapper.GiterminismManager,
wrapper.ProjectDir,
wrapper.BaseTmpDir,
wrapper.SshAuthSock,
wrapper.ContainerBackend,
wrapper.StorageManager,
wrapper.StorageLockManager,
wrapper.ConveyorOptions,
)
defer newConveyor.Terminate(ctx)
return f(newConveyor)
})
}