Skip to content

Commit

Permalink
fix: add missing sync call, increase sync waiting time
Browse files Browse the repository at this point in the history
Signed-off-by: João Vanzuita <joao@kubeshop.io>
  • Loading branch information
João Vanzuita committed Jul 22, 2022
1 parent c724078 commit 998cfb3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
22 changes: 20 additions & 2 deletions cmd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ to quickly create a Cobra application.`,
httpClient := http.Client{Transport: customTransport}

// retry to sync ArgoCD application until reaches the maximum attempts
argoCDIsReady, err := argocd.SyncRetry(&httpClient, 10, 6, "registry", token)
argoCDIsReady, err := argocd.SyncRetry(&httpClient, 60, 5, "registry", token)
if err != nil {
log.Printf("something went wrong during ArgoCD sync step, error is: %v", err)
}
Expand Down Expand Up @@ -368,7 +368,25 @@ to quickly create a Cobra application.`,

informUser("Syncing the registry application")
token := argocd.GetArgocdAuthToken(dryRun)
argocd.SyncArgocdApplication(dryRun, "registry", token)

if dryRun {
log.Printf("[#99] Dry-run mode, Sync ArgoCD skipped")
} else {
// todo: create ArgoCD struct, and host dependencies (like http client)
customTransport := http.DefaultTransport.(*http.Transport).Clone()
customTransport.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
httpClient := http.Client{Transport: customTransport}

// retry to sync ArgoCD application until reaches the maximum attempts
argoCDIsReady, err := argocd.SyncRetry(&httpClient, 60, 5, "registry", token)
if err != nil {
log.Printf("something went wrong during ArgoCD sync step, error is: %v", err)
}

if !argoCDIsReady {
log.Println("unable to sync ArgoCD application, continuing...")
}
}

viper.Set("gitlab.registered", true)
viper.WriteConfig()
Expand Down
4 changes: 3 additions & 1 deletion internal/argocd/argocd.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ func SyncRetry(httpClient pkg.HTTPDoer, attempts int, interval int, applicationN
}

log.Printf(
"sleeping %d seconds before trying to ArgoCD sync again, last Sync status is: %q",
"(%d/%d) sleeping %d seconds before trying to ArgoCD sync again, last Sync status is: %q",
i+1,
attempts,
interval,
syncStatus,
)
Expand Down

0 comments on commit 998cfb3

Please sign in to comment.