Skip to content

Commit

Permalink
Fix missing clousql-proxy sidecar in the release pod
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Guerra authored and aguerra committed Aug 30, 2018
1 parent c99a7b4 commit 81f3841
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Validation for env var and secret names
- Support to create more than one web app per code base

### Fixed
- [server] Missing clousql-proxy sidecar in the release pod

## [0.26.0]
### Added
- Support for creating apps with multiple virtual hosts
Expand Down
14 changes: 7 additions & 7 deletions pkg/server/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,15 @@ func (ops *DeployOperations) Deploy(ctx context.Context, user *database.User, ap
return r, errChan
}

func (ops *DeployOperations) runReleaseCmd(a *app.App, deployId, slugURL string, stream io.Writer) error {
func (ops *DeployOperations) runReleaseCmd(a *app.App, deployId, slugURL string, csp *spec.CloudSQLProxy, stream io.Writer) error {
podName := fmt.Sprintf("release-%s-%s", a.Name, deployId)
podSpec := spec.NewRunnerPodBuilder(podName, ops.opts.SlugRunnerImage, ops.opts.SlugStoreImage).
ForApp(a).
WithSlug(slugURL).
WithLimits(ops.opts.BuildLimitCPU, ops.opts.BuildLimitMemory).
WithStorage(ops.fileStorage).
WithArgs([]string{"start", ProcfileReleaseCmd}).
WithCloudSQLProxySideCar(csp).
Build()

fmt.Fprintln(stream, "Running release command")
Expand All @@ -139,8 +140,12 @@ func (ops *DeployOperations) runReleaseCmd(a *app.App, deployId, slugURL string,
}

func (ops *DeployOperations) createOrUpdateDeploy(a *app.App, confFiles *DeployConfigFiles, w io.Writer, slugURL, description, deployId string) error {
csp, err := spec.NewCloudSQLProxy(ops.opts.CloudSQLProxyImage, confFiles.TeresaYaml)
if err != nil {
return errors.Wrap(err, "failed to create the deploy")
}
if releaseCmd := confFiles.Procfile[ProcfileReleaseCmd]; releaseCmd != "" {
if err := ops.runReleaseCmd(a, deployId, slugURL, w); err != nil {
if err := ops.runReleaseCmd(a, deployId, slugURL, csp, w); err != nil {
log.WithError(err).WithField("id", deployId).Errorf("Running release command %s in app %s", releaseCmd, a.Name)
return err
}
Expand All @@ -166,11 +171,6 @@ func (ops *DeployOperations) createOrUpdateDeploy(a *app.App, confFiles *DeployC
return err
}
}

csp, err := spec.NewCloudSQLProxy(ops.opts.CloudSQLProxyImage, confFiles.TeresaYaml)
if err != nil {
return errors.Wrap(err, "failed to create the deploy")
}
podBuilder = podBuilder.WithCloudSQLProxySideCar(csp)

deploySpec := spec.NewDeployBuilder(slugURL).
Expand Down
1 change: 1 addition & 0 deletions pkg/server/deploy/deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,7 @@ func TestRunReleaseCmd(t *testing.T) {
&app.App{Name: "Test"},
"123456",
"/slug.tgz",
nil,
new(bytes.Buffer),
)

Expand Down

0 comments on commit 81f3841

Please sign in to comment.