Skip to content
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

Merged
merged 13 commits into from
Aug 9, 2024
Merged

Conversation

joaopapereira
Copy link
Contributor

Description of the Change

Add the max-in-flight flag to all the commands

Copy link
Contributor

@pivotalgeorge pivotalgeorge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks mostly-good to me. some comments are concerns, most are minor suggestions

dep.DropletGUID = pushPlan.DropletGUID
dep.Strategy = pushPlan.Strategy
dep.Relationships = resources.Relationships{constant.RelationshipTypeApplication: resources.Relationship{GUID: pushPlan.Application.GUID}}
dep := resources.Deployment{
Copy link
Contributor

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


import "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant"

func SetupDeploymentInformationForPushPlan(pushPlan PushPlan, overrides FlagOverrides) (PushPlan, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The 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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actor.PreparePushPlanSequence looked like the place where we were configuring the push plan by translating all the needed flags.

Copy link
Contributor

Choose a reason for hiding this comment

The 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

@@ -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" default:"-1" description:"Defines the maximum number of instances that will be actively being started. Only applies when --strategy flag is specified."`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[suggestion, blocking] it feels like the default should be the same as CAPI (1) or at least a valid value (resolves to the same, since 0 and negative numbers are invalid here)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pivotalgeorge looks like this concern has been addressed. Are you ok for this conversation to be resolved?

return translatableerror.RequiredFlagsError{Arg1: "--max-in-flight", Arg2: "--strategy"}
}

if cmd.Strategy.Name != constant.DeploymentStrategyDefault && (cmd.MaxInFlight < -1 || cmd.MaxInFlight == 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[suggestion, nonblocking] (cmd.MaxInFlight <= 0)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[code since changed, comment in new review]

}))
})

It("returns errors and warnings", func() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[suggestion, nonblocking] do we want a happy-path case covered?

@@ -19,6 +20,7 @@ type RollbackCommand struct {
Version flag.Revision `long:"version" required:"true" description:"Roll back to the specified revision"`
relatedCommands interface{} `related_commands:"revisions"`
usage interface{} `usage:"CF_NAME rollback APP_NAME [--version VERSION] [-f]"`
MaxInFlight int `long:"max-in-flight" default:"-1" description:"Defines the maximum number of instances that will be actively being rolled back."`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as previous default value comment

"code.cloudfoundry.org/cli/command/v7/shared"
)

type RestartCommand struct {
BaseCommand

MaxInFlight int `long:"max-in-flight" default:"-1" description:"Defines the maximum number of instances that will be actively restarted at any given time. Only applies when --strategy flag is specified."`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as previous default value comment

@@ -22,6 +23,10 @@ type Deployment struct {
Strategy constant.DeploymentStrategy
}

type DeploymentOpts struct {
MaxInFlight int `json:"max_in_flight"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

if d.Options != b {
ccDeployment.Options = &d.Options
if d.Options.MaxInFlight < 1 {
ccDeployment.Options.MaxInFlight = 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[concern, blocking] what happens when we talk to an older CAPI, I.e. one that doesn't have max-in-flight? in #3088 we approached this by assuming that a value of 0 was "max-in-flight unset in the response" but I'm reading this block to mean that we'll always be setting max-in-flight to the default value of 1 and including it in a POST to CAPI
edit: Unless I am missing something and this object is only for unmarshalling the CAPI response

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The concern is valid. When max-in-flight gets to this point with a value we just send it to CAPI and CAPI will return an error, which I am going to address in the next commit.
Also did change the way we are defining if --max-in-flight is present or not by using a pointer instead of the -1 value which should make everything much easier to reason about.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed on the nullable pointer being easy to reason about. If we handle the version issue in followup work I'm happy to consider this resolved.

gururajsh
gururajsh previously approved these changes Aug 8, 2024
Copy link
Member

@gururajsh gururajsh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Signed-off-by: João Pereira <joaod@vmware.com>
Signed-off-by: João Pereira <joaod@vmware.com>
Signed-off-by: João Pereira <joaod@vmware.com>
Signed-off-by: João Pereira <joaod@vmware.com>
Signed-off-by: João Pereira <joaod@vmware.com>
Signed-off-by: João Pereira <joaod@vmware.com>
Signed-off-by: João Pereira <joaod@vmware.com>
Signed-off-by: João Pereira <joaod@vmware.com>
Signed-off-by: João Pereira <joaod@vmware.com>
Signed-off-by: João Pereira <joaod@vmware.com>
Signed-off-by: João Pereira <joaod@vmware.com>
- Provide a better error when talking to older versions of CAPI
- Address some comments in the PR review

Signed-off-by: João Pereira <joaod@vmware.com>
Signed-off-by: João Pereira <joaod@vmware.com>
Copy link
Member

@gururajsh gururajsh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -48,6 +49,14 @@ func (cmd *CopySourceCommand) ValidateFlags() error {
}
}

if cmd.Strategy.Name == constant.DeploymentStrategyDefault && cmd.MaxInFlight != nil {
Copy link
Contributor

@pivotalgeorge pivotalgeorge Aug 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[suggestion, blocking] I believe this is now incorrect: MaxInFlight can take a value of 0, which should be invalid for this flag
edit: I was looking at a diff against the previous changeset version of this PR, so missed the block below. So, disregard the positive value check comment.
However, shouldn't this read && cmd.MaxInFlight == nil, as a required-arg check
-> I see that the default deployment strategy is empty-string, so this is actually correct.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@pivotalgeorge pivotalgeorge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for addressing previous comments
LGTM

@joaopapereira joaopapereira merged commit 6c01031 into cloudfoundry:v8 Aug 9, 2024
18 checks passed
joaopapereira added a commit to joaopapereira/cf-cli that referenced this pull request Aug 9, 2024
* Allow the user to set max-in-flight while pushing app
* Add max-in-flight flag to the restart command
* Add max-in-flight flag to restage command
* Add max-in-flight flag to rollback command
* Add max-in-flight flag to copy-src command
* Remove `--no-wait` to ensure no flakes

---------

Signed-off-by: João Pereira <joaod@vmware.com>
joaopapereira added a commit to joaopapereira/cf-cli that referenced this pull request Aug 9, 2024
* Allow the user to set max-in-flight while pushing app
* Add max-in-flight flag to the restart command
* Add max-in-flight flag to restage command
* Add max-in-flight flag to rollback command
* Add max-in-flight flag to copy-src command
* Remove `--no-wait` to ensure no flakes

---------

Signed-off-by: João Pereira <joaod@vmware.com>
gururajsh pushed a commit that referenced this pull request Aug 12, 2024
* Allow the user to set max-in-flight while pushing app
* Add max-in-flight flag to the restart command
* Add max-in-flight flag to restage command
* Add max-in-flight flag to rollback command
* Add max-in-flight flag to copy-src command
* Remove `--no-wait` to ensure no flakes

---------

Signed-off-by: João Pereira <joaod@vmware.com>
nicolasbender pushed a commit to sap-contributions/cli that referenced this pull request Nov 5, 2024
* Allow the user to set max-in-flight while pushing app
* Add max-in-flight flag to the restart command
* Add max-in-flight flag to restage command
* Add max-in-flight flag to rollback command
* Add max-in-flight flag to copy-src command
* Remove `--no-wait` to ensure no flakes

---------

Signed-off-by: João Pereira <joaod@vmware.com>
Co-authored-by: Pavel Busko <pavel.busko@sap.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants