Skip to content

Commit 93c6eb1

Browse files
committed
chore: registry push
1 parent 7e5bf07 commit 93c6eb1

1 file changed

Lines changed: 22 additions & 11 deletions

File tree

cmd/registry_push.go

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"path"
66
"strings"
7+
"time"
78

89
"github.com/highcard-dev/daemon/internal/core/domain"
910
"github.com/highcard-dev/daemon/internal/core/services/registry"
@@ -69,17 +70,27 @@ var PushCommand = &cobra.Command{
6970
ps[name] = port
7071
}
7172

72-
_, err = ociClient.Push(fullPath, repo, tag, domain.AnnotationInfo{
73-
MinRam: minRam,
74-
MinCpu: minCpu,
75-
MinDisk: minDisk,
76-
Image: image,
77-
Ports: ps,
78-
Smart: smart,
79-
}, packMeta)
80-
81-
if err != nil {
82-
return err
73+
var tries int
74+
for tries < 3 {
75+
_, err = ociClient.Push(fullPath, repo, tag, domain.AnnotationInfo{
76+
MinRam: minRam,
77+
MinCpu: minCpu,
78+
MinDisk: minDisk,
79+
Image: image,
80+
Ports: ps,
81+
Smart: smart,
82+
}, packMeta)
83+
if err != nil {
84+
tries++
85+
logger.Log().Error("Failed to push scroll to registry, retrying...", zap.Error(err), zap.Int("tries", tries))
86+
if tries >= 3 {
87+
logger.Log().Error("Failed to push scroll to registry after 3 attempts", zap.Error(err))
88+
return err
89+
}
90+
} else {
91+
break
92+
}
93+
time.Sleep(time.Duration(tries+1) * time.Second)
8394
}
8495

8596
logger.Log().Info("Pushed "+scroll.Name+" to registry", zap.String("path", fullPath), zap.String("registry", host))

0 commit comments

Comments
 (0)