From 8220012878f354d042ba652759818992a489649f Mon Sep 17 00:00:00 2001 From: Debaditya Ray Date: Thu, 2 May 2024 12:19:15 +0530 Subject: [PATCH] Allow to set manifest app_instances to 0 Signed-off-by: Ray --- operation/manifest.go | 5 +++-- operation/manifest_test.go | 3 ++- operation/push.go | 4 ++-- operation/push_test.go | 3 ++- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/operation/manifest.go b/operation/manifest.go index 087993d..8662993 100644 --- a/operation/manifest.go +++ b/operation/manifest.go @@ -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"` @@ -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", }, } diff --git a/operation/manifest_test.go b/operation/manifest_test.go index 9602385..6a51297 100644 --- a/operation/manifest_test.go +++ b/operation/manifest_test.go @@ -67,6 +67,7 @@ const fullSpringMusicYamlV2 = `applications: ` func TestManifestMarshalling(t *testing.T) { + var numOfInstances uint = 2 m := &Manifest{ Applications: []*AppManifest{ { @@ -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, diff --git a/operation/push.go b/operation/push.go index 89c6225..c5035da 100644 --- a/operation/push.go +++ b/operation/push.go @@ -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) @@ -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()) } diff --git a/operation/push_test.go b/operation/push_test.go index 4c12776..74d6c0d 100644 --- a/operation/push_test.go +++ b/operation/push_test.go @@ -29,6 +29,7 @@ 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"}, @@ -36,7 +37,7 @@ func TestAppPush(t *testing.T) { AppManifestProcess: AppManifestProcess{ HealthCheckType: "http", HealthCheckHTTPEndpoint: "/health", - Instances: 2, + Instances: &numOfInstances, Memory: "1G", }, Routes: &AppManifestRoutes{