Skip to content

Commit

Permalink
Allow to set manifest app_instances to 0
Browse files Browse the repository at this point in the history
Signed-off-by: Ray <[email protected]>
  • Loading branch information
Dray56 authored and debTheRay committed May 2, 2024
1 parent f0617e8 commit 8220012
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
5 changes: 3 additions & 2 deletions operation/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ type AppManifestProcess struct {
HealthCheckType AppHealthCheckType `yaml:"health-check-type,omitempty"`
HealthCheckHTTPEndpoint string `yaml:"health-check-http-endpoint,omitempty"`
HealthCheckInvocationTimeout uint `yaml:"health-check-invocation-timeout,omitempty"`
Instances uint `yaml:"instances,omitempty"`
Instances *uint `yaml:"instances,omitempty"`
LogRateLimitPerSecond string `yaml:"log-rate-limit-per-second,omitempty"`
Memory string `yaml:"memory,omitempty"`
Timeout uint `yaml:"timeout,omitempty"`
Expand Down Expand Up @@ -150,12 +150,13 @@ func NewManifest(applications ...*AppManifest) *Manifest {
}

func NewAppManifest(appName string) *AppManifest {
var numOfInstances uint = 1
return &AppManifest{
Name: appName,
AppManifestProcess: AppManifestProcess{
HealthCheckType: "port",
HealthCheckHTTPEndpoint: "/",
Instances: 1,
Instances: &numOfInstances,
Memory: "256M",
},
}
Expand Down
3 changes: 2 additions & 1 deletion operation/manifest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ const fullSpringMusicYamlV2 = `applications:
`

func TestManifestMarshalling(t *testing.T) {
var numOfInstances uint = 2
m := &Manifest{
Applications: []*AppManifest{
{
Expand All @@ -86,7 +87,7 @@ func TestManifestMarshalling(t *testing.T) {
AppManifestProcess: AppManifestProcess{
HealthCheckType: "http",
HealthCheckHTTPEndpoint: "/health",
Instances: 2,
Instances: &numOfInstances,
LogRateLimitPerSecond: "100MB",
Memory: "1G",
Timeout: 60,
Expand Down
4 changes: 2 additions & 2 deletions operation/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func (p *AppPushOperation) pushRollingApp(ctx context.Context, space *resource.S
}
// In case application crashed due to new deployment, deployment will be stuck with value "ACTIVE" and reason "DEPLOYING"
// This will be considered as deployment failed after timeout
depPollErr := p.waitForDeployment(ctx, deployment.GUID, manifest.Instances)
depPollErr := p.waitForDeployment(ctx, deployment.GUID, *manifest.Instances)

// Check the app state if app not started or deployment failed rollback the deployment
originalApp, err = p.findApp(ctx, manifest.Name, space)
Expand All @@ -167,7 +167,7 @@ func (p *AppPushOperation) pushRollingApp(ctx context.Context, space *resource.S
if rollBackErr != nil {
return nil, fmt.Errorf("failed to confirm rollback deployment with: %s", rollBackErr.Error())
}
depRollPollErr := p.waitForDeployment(ctx, rollBackDeployment.GUID, manifest.Instances)
depRollPollErr := p.waitForDeployment(ctx, rollBackDeployment.GUID, *manifest.Instances)
if depRollPollErr != nil {
return nil, fmt.Errorf("failed to deploy with: %s \nfailed to confirm roll back to last deployment with: %s", depPollErr.Error(), depRollPollErr.Error())
}
Expand Down
3 changes: 2 additions & 1 deletion operation/push_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,15 @@ func TestAppPush(t *testing.T) {
dropletAssoc := g.DropletAssociation()

fakeAppZipReader := strings.NewReader("blah zip zip")
var numOfInstances uint = 2
manifest := &AppManifest{
Name: app.Name,
Buildpacks: []string{"java-buildpack-offline"},

AppManifestProcess: AppManifestProcess{
HealthCheckType: "http",
HealthCheckHTTPEndpoint: "/health",
Instances: 2,
Instances: &numOfInstances,
Memory: "1G",
},
Routes: &AppManifestRoutes{
Expand Down

0 comments on commit 8220012

Please sign in to comment.