From 270276ec1295bdc3e9f78b5dabc46b6ea2c1fc11 Mon Sep 17 00:00:00 2001 From: Ahmed Nour Date: Tue, 27 Aug 2024 09:31:19 +0200 Subject: [PATCH] databse portforward to the end --- .../pkg/repository/transformer.go | 26 +++++++++---------- .../cluster-setup/argocd-kuberpult.sh | 2 ++ .../cluster-setup/setup-postgres.sh | 16 ------------ 3 files changed, 15 insertions(+), 29 deletions(-) diff --git a/services/manifest-repo-export-service/pkg/repository/transformer.go b/services/manifest-repo-export-service/pkg/repository/transformer.go index e498f575a..b7f07b905 100644 --- a/services/manifest-repo-export-service/pkg/repository/transformer.go +++ b/services/manifest-repo-export-service/pkg/repository/transformer.go @@ -791,7 +791,7 @@ func (c *CreateApplicationVersion) Transform( releaseDir := releasesDirectoryWithVersion(fs, c.Application, version) appDir := applicationDirectory(fs, c.Application) if err := fs.MkdirAll(releaseDir, 0777); err != nil { - return "", GetCreateReleaseGeneralFailure(fmt.Errorf("mkdir %s error:%v", releaseDir, err)) + return "", GetCreateReleaseGeneralFailure(err) } var checkForInvalidCommitId = func(commitId, helperText string) { @@ -808,27 +808,27 @@ func (c *CreateApplicationVersion) Transform( if c.SourceCommitId != "" { c.SourceCommitId = strings.ToLower(c.SourceCommitId) if err := util.WriteFile(fs, fs.Join(releaseDir, fieldSourceCommitId), []byte(c.SourceCommitId), 0666); err != nil { - return "", GetCreateReleaseGeneralFailure(fmt.Errorf("writefile %s error:%v", fieldSourceCommitId, err)) + return "", GetCreateReleaseGeneralFailure(err) } } if c.SourceAuthor != "" { if err := util.WriteFile(fs, fs.Join(releaseDir, fieldSourceAuthor), []byte(c.SourceAuthor), 0666); err != nil { - return "", GetCreateReleaseGeneralFailure(fmt.Errorf("writefile %s error:%v", fieldSourceAuthor, err)) + return "", GetCreateReleaseGeneralFailure(err) } } if c.SourceMessage != "" { if err := util.WriteFile(fs, fs.Join(releaseDir, fieldSourceMessage), []byte(c.SourceMessage), 0666); err != nil { - return "", GetCreateReleaseGeneralFailure(fmt.Errorf("writefile %s error:%v", fieldSourceMessage, err)) + return "", GetCreateReleaseGeneralFailure(err) } } if c.DisplayVersion != "" { if err := util.WriteFile(fs, fs.Join(releaseDir, fieldDisplayVersion), []byte(c.DisplayVersion), 0666); err != nil { - return "", GetCreateReleaseGeneralFailure(fmt.Errorf("writefile %s error:%v", fieldDisplayVersion, err)) + return "", GetCreateReleaseGeneralFailure(err) } } if err := util.WriteFile(fs, fs.Join(releaseDir, fieldCreatedAt), []byte(time2.GetTimeNow(ctx).Format(time.RFC3339)), 0666); err != nil { - return "", GetCreateReleaseGeneralFailure(fmt.Errorf("writefile %s error:%v", fieldCreatedAt, err)) + return "", GetCreateReleaseGeneralFailure(err) } if c.Team != "" { @@ -839,22 +839,22 @@ func (c *CreateApplicationVersion) Transform( if _, err := fs.Stat(teamFileLoc); err == nil { //If path to file exists err := fs.Remove(teamFileLoc) if err != nil { - return "", GetCreateReleaseGeneralFailure(fmt.Errorf("remove %s error:%v", teamFileLoc, err)) + return "", GetCreateReleaseGeneralFailure(err) } } if err := util.WriteFile(fs, teamFileLoc, []byte(c.Team), 0666); err != nil { - return "", GetCreateReleaseGeneralFailure(fmt.Errorf("writefile %s error:%v", teamFileLoc, err)) + return "", GetCreateReleaseGeneralFailure(err) } } isLatest, err := isLatestVersion(state, c.Application, version) if err != nil { - return "", GetCreateReleaseGeneralFailure(fmt.Errorf("islatest version error:%v", err)) + return "", GetCreateReleaseGeneralFailure(err) } if !isLatest { // check that we can actually backfill this version oldVersions, err := findOldApplicationVersions(ctx, transaction, state, c.Application) if err != nil { - return "", GetCreateReleaseGeneralFailure(fmt.Errorf("findOldApplicationVersions error:%v", err)) + return "", GetCreateReleaseGeneralFailure(err) } for _, oldVersion := range oldVersions { if version == oldVersion { @@ -906,10 +906,10 @@ func (c *CreateApplicationVersion) Transform( } if err = fs.MkdirAll(envDir, 0777); err != nil { - return "", GetCreateReleaseGeneralFailure(fmt.Errorf("mkdir %s error:%v", envDir, err)) + return "", GetCreateReleaseGeneralFailure(err) } if err := util.WriteFile(fs, fs.Join(envDir, "manifests.yaml"), []byte(man), 0666); err != nil { - return "", GetCreateReleaseGeneralFailure(fmt.Errorf("writefile %s error:%v", envDir, err)) + return "", GetCreateReleaseGeneralFailure(err) } teamOwner, err := state.GetApplicationTeamOwner(ctx, transaction, c.Application) @@ -939,7 +939,7 @@ func (c *CreateApplicationVersion) Transform( if ok { continue // LockedErrors are expected } else { - return "", GetCreateReleaseGeneralFailure(fmt.Errorf("execute error:%v", err)) + return "", GetCreateReleaseGeneralFailure(err) } } } diff --git a/tests/integration-tests/cluster-setup/argocd-kuberpult.sh b/tests/integration-tests/cluster-setup/argocd-kuberpult.sh index 3d8dbd032..dd1796a2f 100755 --- a/tests/integration-tests/cluster-setup/argocd-kuberpult.sh +++ b/tests/integration-tests/cluster-setup/argocd-kuberpult.sh @@ -224,6 +224,8 @@ print "connection to frontend service successful" waitForDeployment "default" "app=kuberpult-rollout-service" waitForDeployment "default" "app=kuberpult-manifest-repo-export-service" +portForwardAndWait "default" deploy/postgres "5432" "5432" + kubectl get deployment kubectl get pods diff --git a/tests/integration-tests/cluster-setup/setup-postgres.sh b/tests/integration-tests/cluster-setup/setup-postgres.sh index de02aa7a7..00573ec1d 100755 --- a/tests/integration-tests/cluster-setup/setup-postgres.sh +++ b/tests/integration-tests/cluster-setup/setup-postgres.sh @@ -22,21 +22,6 @@ function waitForDeployment() { done } -function portForwardAndWait() { - ns="$1" - deployment="$2" - portHere="$3" - portThere="$4" - ports="$portHere:$portThere" - print "portForwardAndWait for $ns/$deployment $ports" - kubectl -n "$ns" port-forward "$deployment" "$ports" & - print "portForwardAndWait: waiting until the port forward works..." - until nc -vz localhost "$portHere" - do - sleep 1s - done -} - kubectl apply -f - <