Skip to content

Commit aab4fae

Browse files
Add retry mechanism to integrations (#481)
* Add retry mechanism to integrations * bump
1 parent 60c5246 commit aab4fae

File tree

4 files changed

+34
-5
lines changed

4 files changed

+34
-5
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION=v0.0.426
1+
VERSION=v0.0.427
22

33
OUT_DIR=dist
44
YEAR?=$(shell date +"%Y")

cmd/commands/runtime.go

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@ To complete the installation:
878878
opts.RuntimeName))
879879
summaryArr = append(summaryArr, summaryLog{skipIngressInfoMsg, Info})
880880
} else {
881-
gitIntegrationErr := createGitIntegration(ctx, opts)
881+
gitIntegrationErr := intervalCheckIsGitIntegrationCreated(ctx, opts)
882882
if gitIntegrationErr != nil {
883883
return gitIntegrationErr
884884
}
@@ -1057,6 +1057,35 @@ func createGitIntegration(ctx context.Context, opts *RuntimeInstallOptions) erro
10571057
return nil
10581058
}
10591059

1060+
func intervalCheckIsGitIntegrationCreated(ctx context.Context, opts *RuntimeInstallOptions) error{
1061+
maxRetries := 6 // up to a minute
1062+
ticker := time.NewTicker(time.Second * 10)
1063+
defer ticker.Stop()
1064+
_, cancel := context.WithCancel(ctx)
1065+
defer cancel()
1066+
1067+
for triesLeft := maxRetries; triesLeft > 0; triesLeft-- {
1068+
select {
1069+
case <-ctx.Done():
1070+
return ctx.Err()
1071+
case <-ticker.C:
1072+
}
1073+
1074+
err := createGitIntegration(ctx, opts)
1075+
if err != nil {
1076+
if err == ctx.Err() {
1077+
return ctx.Err()
1078+
}
1079+
1080+
log.G(ctx).Debugf("Retrying to create the default git integration. Error: %s", err.Error())
1081+
} else {
1082+
return nil
1083+
}
1084+
}
1085+
1086+
return fmt.Errorf("timed ot while waiting for git integration to be created")
1087+
}
1088+
10601089
func removeGitIntegrations(ctx context.Context, opts *RuntimeUninstallOptions) error {
10611090
appProxyClient, err := cfConfig.NewClient().AppProxy(ctx, opts.RuntimeName, store.Get().InsecureIngressHost)
10621091
if err != nil {

docs/releases/release_notes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ cf version
2323

2424
```bash
2525
# download and extract the binary
26-
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.426/cf-linux-amd64.tar.gz | tar zx
26+
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.427/cf-linux-amd64.tar.gz | tar zx
2727

2828
# move the binary to your $PATH
2929
mv ./cf-linux-amd64 /usr/local/bin/cf
@@ -36,7 +36,7 @@ cf version
3636

3737
```bash
3838
# download and extract the binary
39-
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.426/cf-darwin-amd64.tar.gz | tar zx
39+
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.427/cf-darwin-amd64.tar.gz | tar zx
4040

4141
# move the binary to your $PATH
4242
mv ./cf-darwin-amd64 /usr/local/bin/cf

manifests/runtime.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ metadata:
55
namespace: "{{ namespace }}"
66
spec:
77
defVersion: 1.0.1
8-
version: 0.0.426
8+
version: 0.0.427
99
bootstrapSpecifier: github.com/codefresh-io/cli-v2/manifests/argo-cd
1010
components:
1111
- name: events

0 commit comments

Comments
 (0)