Skip to content

Commit a3e4aba

Browse files
authored
Merge pull request #409 from Dray56/app_instance
Allow to set manifest app_instances to 0
2 parents 6c4178b + 8220012 commit a3e4aba

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

operation/manifest.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ type AppManifestProcess struct {
5959
HealthCheckType AppHealthCheckType `yaml:"health-check-type,omitempty"`
6060
HealthCheckHTTPEndpoint string `yaml:"health-check-http-endpoint,omitempty"`
6161
HealthCheckInvocationTimeout uint `yaml:"health-check-invocation-timeout,omitempty"`
62-
Instances uint `yaml:"instances,omitempty"`
62+
Instances *uint `yaml:"instances,omitempty"`
6363
LogRateLimitPerSecond string `yaml:"log-rate-limit-per-second,omitempty"`
6464
Memory string `yaml:"memory,omitempty"`
6565
Timeout uint `yaml:"timeout,omitempty"`
@@ -150,12 +150,13 @@ func NewManifest(applications ...*AppManifest) *Manifest {
150150
}
151151

152152
func NewAppManifest(appName string) *AppManifest {
153+
var numOfInstances uint = 1
153154
return &AppManifest{
154155
Name: appName,
155156
AppManifestProcess: AppManifestProcess{
156157
HealthCheckType: "port",
157158
HealthCheckHTTPEndpoint: "/",
158-
Instances: 1,
159+
Instances: &numOfInstances,
159160
Memory: "256M",
160161
},
161162
}

operation/manifest_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ const fullSpringMusicYamlV2 = `applications:
6767
`
6868

6969
func TestManifestMarshalling(t *testing.T) {
70+
var numOfInstances uint = 2
7071
m := &Manifest{
7172
Applications: []*AppManifest{
7273
{
@@ -86,7 +87,7 @@ func TestManifestMarshalling(t *testing.T) {
8687
AppManifestProcess: AppManifestProcess{
8788
HealthCheckType: "http",
8889
HealthCheckHTTPEndpoint: "/health",
89-
Instances: 2,
90+
Instances: &numOfInstances,
9091
LogRateLimitPerSecond: "100MB",
9192
Memory: "1G",
9293
Timeout: 60,

operation/push.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ func (p *AppPushOperation) pushRollingApp(ctx context.Context, space *resource.S
155155
}
156156
// In case application crashed due to new deployment, deployment will be stuck with value "ACTIVE" and reason "DEPLOYING"
157157
// This will be considered as deployment failed after timeout
158-
depPollErr := p.waitForDeployment(ctx, deployment.GUID, manifest.Instances)
158+
depPollErr := p.waitForDeployment(ctx, deployment.GUID, *manifest.Instances)
159159

160160
// Check the app state if app not started or deployment failed rollback the deployment
161161
originalApp, err = p.findApp(ctx, manifest.Name, space)
@@ -167,7 +167,7 @@ func (p *AppPushOperation) pushRollingApp(ctx context.Context, space *resource.S
167167
if rollBackErr != nil {
168168
return nil, fmt.Errorf("failed to confirm rollback deployment with: %s", rollBackErr.Error())
169169
}
170-
depRollPollErr := p.waitForDeployment(ctx, rollBackDeployment.GUID, manifest.Instances)
170+
depRollPollErr := p.waitForDeployment(ctx, rollBackDeployment.GUID, *manifest.Instances)
171171
if depRollPollErr != nil {
172172
return nil, fmt.Errorf("failed to deploy with: %s \nfailed to confirm roll back to last deployment with: %s", depPollErr.Error(), depRollPollErr.Error())
173173
}

operation/push_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,15 @@ func TestAppPush(t *testing.T) {
2929
dropletAssoc := g.DropletAssociation()
3030

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

3637
AppManifestProcess: AppManifestProcess{
3738
HealthCheckType: "http",
3839
HealthCheckHTTPEndpoint: "/health",
39-
Instances: 2,
40+
Instances: &numOfInstances,
4041
Memory: "1G",
4142
},
4243
Routes: &AppManifestRoutes{

0 commit comments

Comments
 (0)