From 51ca2ee9d89eaf06637603f81f3e64ee6cc5390e Mon Sep 17 00:00:00 2001 From: stefanprodan Date: Tue, 9 Jun 2020 16:12:40 +0300 Subject: [PATCH] Improve cluster sync wait --- cmd/tk/bootstrap_github.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/cmd/tk/bootstrap_github.go b/cmd/tk/bootstrap_github.go index 64d8d5d8..05361ca8 100644 --- a/cmd/tk/bootstrap_github.go +++ b/cmd/tk/bootstrap_github.go @@ -181,7 +181,7 @@ func bootstrapGitHubCmdRun(cmd *cobra.Command, args []string) error { } if err := createGitHubDeployKey(ctx, key, ghHostname, ghOwner, ghRepository, ghToken, ghPersonal); err != nil { - return nil + return err } logSuccess("deploy key configured") } @@ -446,6 +446,12 @@ func applyGitHubKustomization(ctx context.Context, kubeClient client.Client, nam } logWaiting("waiting for cluster sync") + + if err := wait.PollImmediate(pollInterval, timeout, + isGitRepositoryReady(ctx, kubeClient, name, namespace)); err != nil { + return err + } + if err := wait.PollImmediate(pollInterval, timeout, isKustomizationReady(ctx, kubeClient, name, namespace)); err != nil { return err @@ -515,12 +521,8 @@ func createGitHubDeployKey(ctx context.Context, key, hostname, owner, name, toke return err } keyName := fmt.Sprintf("tk-%s", namespace) - org := "" - if !isPersonal { - org = owner - } isReadOnly := true - _, _, err = gh.Repositories.CreateKey(ctx, org, name, &github.Key{ + _, _, err = gh.Repositories.CreateKey(ctx, owner, name, &github.Key{ Title: &keyName, Key: &key, ReadOnly: &isReadOnly,