Skip to content

Conversation

@bvtujo
Copy link
Contributor

@bvtujo bvtujo commented Sep 25, 2023

Adds multideployments and an --all flag.

Customers can now specify a deployment order tag with their workload names, eg. "fe/1,be/2" to deploy services in a particular order.
Shared numbers create a deployment group, which can be parallelized in the future.

tk: unit tests for new behavior

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the Apache 2.0 License.

@bvtujo bvtujo requested a review from a team as a code owner September 25, 2023 17:51
@bvtujo bvtujo requested review from efekarakus and removed request for a team September 25, 2023 17:51
name: workload,
cmd: deployCmd,
})
if err := deployCmd.Ask(); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Am I correct that we would be prompting "which environment do you want to deploy xxx to" for each service xxx?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, env gets asked once, separately, early on in Run(). Then, when loadWkldCmd gets called, it uses the env value provided earlier to populate that variable in each individual command. Ask() is really there to catch esoteric less-used flags that are workload specific.

Comment on lines 424 to 426
count := 0
for i := 0; i < len(cmds); i++ {
count += len(cmds[i])
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess we could also have count defined earlier, and increment it while we loop through each deploymentOrderGroup (the nested for-loop above), just to have one less for-loop iteration (not a huge difference though)

}
if err := o.deployWkld.RecommendActions(); err != nil {
return err
log.Infof("Will deploy %d %s in the following order.\n", count, english.PluralWord(count, "workload", ""))
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice information here!

}

func parseDeploymentOrderTags(namesWithOptionalOrder []string) (map[string]int, error) {
prioritiesMap := make(map[string]int)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we use "priorities" instead of "orders" here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is a first step to parallelizing deployments--the idea is to create multiple groups which may be deployed in parallel, and then deploy those groups in a prescribed order. I wanted to use a different word to distinguish this, which is a precursor data structure, from the final.

@github-actions
Copy link

github-actions bot commented Oct 2, 2023

🍕 Here are the new binary sizes!

Name New size (kiB) size (kiB) Delta (%)
macOS (amd) 51960 51740 +0.43
macOS (arm) 52816 52596 +0.42
linux (amd) 45700 45496 +0.45
linux (arm) 44996 44804 +0.43
windows (amd) 43156 42968 +0.44

@codecov-commenter
Copy link

codecov-commenter commented Oct 2, 2023

Codecov Report

Attention: 60 lines in your changes are missing coverage. Please review.

Comparison is base (439abd8) 69.82% compared to head (efb00e9) 69.86%.

Additional details and impacted files
@@             Coverage Diff              @@
##           mainline    #5324      +/-   ##
============================================
+ Coverage     69.82%   69.86%   +0.03%     
============================================
  Files           296      297       +1     
  Lines         44835    45020     +185     
  Branches        287      287              
============================================
+ Hits          31307    31453     +146     
- Misses        12009    12038      +29     
- Partials       1519     1529      +10     
Files Coverage Δ
internal/pkg/cli/flag.go 90.47% <ø> (ø)
internal/pkg/queue/queue.go 100.00% <100.00%> (ø)
internal/pkg/term/selector/selector.go 78.44% <100.00%> (-0.37%) ⬇️
internal/pkg/cli/deploy.go 55.45% <73.68%> (+9.52%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines -209 to -210
if o.yesInitWkld == nil {
confirmInitWkld, err := o.prompt.Confirm(fmt.Sprintf("Found manifest for uninitialized %s %q. Initialize it?", workloadType, name), "This workload will be initialized, then deployed.", prompt.WithFinalMessage(fmt.Sprintf("Initialize %s:", workloadType)))
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious, why do we remove this prompt? (I don't have an opinion on this yeet, just curious)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dannyrandall made a great comment in bugbash feedback that simply specifying an un-initialized service is sufficient to divine the customer's intent to init it. This changes makes --init-wkld into a flag which specifically modifies the behavior of --all. That is, when --all and --init-wkld are true, copilot deploy will initialize and deploy everything in the ws. But when --init-wkld is false or unspecified, we'll only deploy initialized workloads.

}

// Pop removes the last element from the array.
func (p *pq) Pop() any {
Copy link
Contributor

@Lou1415926 Lou1415926 Oct 2, 2023

Choose a reason for hiding this comment

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

Not a request for this PR, but I feel like ideally we'd have a separate file / package for this and have some unit tests implemented on it! Edit: oops, nvm, I think we don't need that at all. This is just to satisfy the interface that the heap package wants.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

lmao too late I already wrote a generic priority queue

Copy link
Contributor

@Lou1415926 Lou1415926 left a comment

Choose a reason for hiding this comment

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

Just a few more comments!

}

for g, deploymentGroup := range cmds {
// TODO parallelize this. Steps involve:
Copy link
Contributor

Choose a reason for hiding this comment

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

❤️

// FilterItemsByStrings(wantedStrings, stringSlice2, func(s string) string { return s })
//
// It returns a list of strings (items whose stringFunc() exists in the list of wantedStrings).
func FilterItemsByStrings[T any](wantedStrings []string, possibleItems []T, stringFunc func(T) string) []string {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
func FilterItemsByStrings[T any](wantedStrings []string, possibleItems []T, stringFunc func(T) string) []string {
func filterItemsByStrings[T any](wantedStrings []string, possibleItems []T, stringFunc func(T) string) []string {

// func(w *config.Workload) string { return w.Name }
//
// as the stringFunc parameter.
func FilterOutItems[T any](allItems []string, unwantedItems []T, stringFunc func(T) string) []string {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
func FilterOutItems[T any](allItems []string, unwantedItems []T, stringFunc func(T) string) []string {
func filterOutItems[T any](allItems []string, unwantedItems []T, stringFunc func(T) string) []string {

cmd.Flags().BoolVar(&deployEnvironment, deployEnvFlag, false, deployEnvFlagDescription)
cmd.Flags().BoolVar(&initEnvironment, yesInitEnvFlag, false, yesInitEnvFlagDescription)
cmd.Flags().BoolVar(&initWorkload, yesInitWorkloadFlag, false, yesInitWorkloadFlagDescription)
cmd.Flags().BoolVar(&vars.yesInitWkld, yesInitWorkloadFlag, false, yesInitWorkloadFlagDescription)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the default true?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no, I think we should err on the side of only deploying initted local workloads unless the customer opts in.

Copy link
Contributor

@iamhopaul123 iamhopaul123 left a comment

Choose a reason for hiding this comment

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

🎉

@mergify mergify bot merged commit cbb1718 into mainline Oct 4, 2023
@mergify mergify bot deleted the feat/enable-multiselect branch October 4, 2023 16:35
KollaAdithya pushed a commit to KollaAdithya/copilot-cli that referenced this pull request Oct 18, 2023
Adds multideployments and an --all flag. 

Customers can now specify a deployment order tag with their workload names, eg. "fe/1,be/2" to deploy services in a particular order. 
Shared numbers create a deployment group, which can be parallelized in the future. 

tk: unit tests for new behavior




By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the Apache 2.0 License.
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.

4 participants