-
Notifications
You must be signed in to change notification settings - Fork 931
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[v8] Max in flight flag #3085
[v8] Max in flight flag #3085
Changes from all commits
d07173f
d0e5398
22f9462
1925135
b70dcf7
62dd356
ea1a89c
91d1c27
b1a0160
5d88245
ffcb898
63c394b
deff01c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ import ( | |
"code.cloudfoundry.org/cli/actor/v7action" | ||
. "code.cloudfoundry.org/cli/actor/v7pushaction" | ||
"code.cloudfoundry.org/cli/actor/v7pushaction/v7pushactionfakes" | ||
"code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" | ||
"code.cloudfoundry.org/cli/resources" | ||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
|
@@ -106,6 +107,51 @@ var _ = Describe("CreateDeploymentForApplication()", func() { | |
Expect(events).To(ConsistOf(StartingDeployment)) | ||
}) | ||
}) | ||
|
||
When("strategy is provided", func() { | ||
BeforeEach(func() { | ||
fakeV7Actor.PollStartForDeploymentCalls(func(_ resources.Application, _ string, _ bool, handleInstanceDetails func(string)) (warnings v7action.Warnings, err error) { | ||
handleInstanceDetails("Instances starting...") | ||
return nil, nil | ||
}) | ||
|
||
fakeV7Actor.CreateDeploymentReturns( | ||
"some-deployment-guid", | ||
v7action.Warnings{"some-deployment-warning"}, | ||
nil, | ||
) | ||
paramPlan.Strategy = "rolling" | ||
paramPlan.MaxInFlight = 10 | ||
}) | ||
|
||
It("waits for the app to start", func() { | ||
Expect(fakeV7Actor.PollStartForDeploymentCallCount()).To(Equal(1)) | ||
givenApp, givenDeploymentGUID, noWait, _ := fakeV7Actor.PollStartForDeploymentArgsForCall(0) | ||
Expect(givenApp).To(Equal(resources.Application{GUID: "some-app-guid"})) | ||
Expect(givenDeploymentGUID).To(Equal("some-deployment-guid")) | ||
Expect(noWait).To(Equal(false)) | ||
Expect(events).To(ConsistOf(StartingDeployment, InstanceDetails, WaitingForDeployment)) | ||
Expect(fakeV7Actor.CreateDeploymentCallCount()).To(Equal(1)) | ||
dep := fakeV7Actor.CreateDeploymentArgsForCall(0) | ||
Expect(dep).To(Equal(resources.Deployment{ | ||
Strategy: "rolling", | ||
Options: resources.DeploymentOpts{MaxInFlight: 10}, | ||
Relationships: resources.Relationships{ | ||
constant.RelationshipTypeApplication: resources.Relationship{GUID: "some-app-guid"}, | ||
}, | ||
})) | ||
}) | ||
|
||
It("returns errors and warnings", func() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [suggestion, nonblocking] do we want a happy-path case covered? |
||
Expect(returnedPushPlan).To(Equal(paramPlan)) | ||
Expect(executeErr).NotTo(HaveOccurred()) | ||
Expect(warnings).To(ConsistOf("some-deployment-warning")) | ||
}) | ||
|
||
It("records deployment events", func() { | ||
Expect(events).To(ConsistOf(StartingDeployment, InstanceDetails, WaitingForDeployment)) | ||
}) | ||
}) | ||
}) | ||
|
||
Describe("waiting for app to start", func() { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package v7pushaction | ||
|
||
import "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" | ||
|
||
func SetupDeploymentInformationForPushPlan(pushPlan PushPlan, overrides FlagOverrides) (PushPlan, error) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [suggestion / question / nonblocking] why is this separate from create_deployment_for_push_plan There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay makes sense (the pushplansequence). In that case what's strangely-shaped is the location (siblings within v7pushaction) of two deployment functions that both take pushPlans. I see that this parallels the situation for e.g. droplet config, so I'm happy to move on from this topic for now and leave it up to a separate refactor |
||
pushPlan.Strategy = overrides.Strategy | ||
|
||
if overrides.Strategy != constant.DeploymentStrategyDefault && overrides.MaxInFlight != nil { | ||
pushPlan.MaxInFlight = *overrides.MaxInFlight | ||
} | ||
|
||
return pushPlan, nil | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ type CopySourceCommand struct { | |
RequiredArgs flag.CopySourceArgs `positional-args:"yes"` | ||
usage interface{} `usage:"CF_NAME copy-source SOURCE_APP DESTINATION_APP [-s TARGET_SPACE [-o TARGET_ORG]] [--no-restart] [--strategy STRATEGY] [--no-wait]"` | ||
Strategy flag.DeploymentStrategy `long:"strategy" description:"Deployment strategy can be canary, rolling or null"` | ||
MaxInFlight *int `long:"max-in-flight" description:"Defines the maximum number of instances that will be actively being started. Only applies when --strategy flag is specified."` | ||
NoWait bool `long:"no-wait" description:"Exit when the first instance of the web process is healthy"` | ||
NoRestart bool `long:"no-restart" description:"Do not restage the destination application"` | ||
Organization string `short:"o" long:"organization" description:"Org that contains the destination application"` | ||
|
@@ -48,6 +49,14 @@ func (cmd *CopySourceCommand) ValidateFlags() error { | |
} | ||
} | ||
|
||
if cmd.Strategy.Name == constant.DeploymentStrategyDefault && cmd.MaxInFlight != nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [suggestion, blocking] I believe this is now incorrect: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. LGTM |
||
return translatableerror.RequiredFlagsError{Arg1: "--max-in-flight", Arg2: "--strategy"} | ||
} | ||
|
||
if cmd.Strategy.Name != constant.DeploymentStrategyDefault && cmd.MaxInFlight != nil && *cmd.MaxInFlight < 1 { | ||
return translatableerror.IncorrectUsageError{Message: "--max-in-flight must be greater than or equal to 1"} | ||
} | ||
|
||
return nil | ||
} | ||
|
||
|
@@ -160,10 +169,15 @@ func (cmd CopySourceCommand) Execute(args []string) error { | |
cmd.UI.DisplayNewline() | ||
|
||
opts := shared.AppStartOpts{ | ||
Strategy: cmd.Strategy.Name, | ||
NoWait: cmd.NoWait, | ||
AppAction: constant.ApplicationRestarting, | ||
NoWait: cmd.NoWait, | ||
Strategy: cmd.Strategy.Name, | ||
} | ||
|
||
if cmd.MaxInFlight != nil { | ||
opts.MaxInFlight = *cmd.MaxInFlight | ||
} | ||
|
||
err = cmd.Stager.StageAndStart(targetApp, targetSpace, targetOrg, pkg.GUID, opts) | ||
if err != nil { | ||
return mapErr(cmd.Config, targetApp.Name, err) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[comment, no action] good improvement / we should be using this style. I wonder if our linter catches the assignment approach you've replaced