From 072a0798335a36196ba1696c41576d7059c4cc7f Mon Sep 17 00:00:00 2001 From: Sean Gillespie Date: Mon, 29 Oct 2018 10:24:04 -0700 Subject: [PATCH] Use math.MaxInt32 to signal unbounded parallelism Downlevel versions of the Pulumi Node SDK assumed that a parallelism level of zero implied serial execution, which current CLIs use to signal unbounded parallelism. This commit works around the downlevel issue by using math.MaxInt32 to signal unbounded parallelism. (cherry picked from commit ca540cc736eacd282fbc8ea54831f4b3ccebfd77) --- cmd/destroy.go | 2 +- cmd/preview.go | 2 +- cmd/refresh.go | 2 +- cmd/up.go | 5 +++-- pkg/resource/deploy/plan.go | 3 ++- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/cmd/destroy.go b/cmd/destroy.go index 60d5bf6d6..0bd34b724 100644 --- a/cmd/destroy.go +++ b/cmd/destroy.go @@ -133,7 +133,7 @@ func newDestroyCmd() *cobra.Command { "Display operation as a rich diff showing the overall change") cmd.PersistentFlags().IntVarP( ¶llel, "parallel", "p", defaultParallel, - "Allow P resource operations to run in parallel at once (1 for no parallelism, 0 for unbounded parallelism)") + "Allow P resource operations to run in parallel at once (1 for no parallelism). Defaults to unbounded.") cmd.PersistentFlags().BoolVarP( &refresh, "refresh", "r", false, "Refresh the state of the stack's resources before this update") diff --git a/cmd/preview.go b/cmd/preview.go index 233d1ba46..99ea9ecd4 100644 --- a/cmd/preview.go +++ b/cmd/preview.go @@ -131,7 +131,7 @@ func newPreviewCmd() *cobra.Command { "Display operation as a rich diff showing the overall change") cmd.PersistentFlags().IntVarP( ¶llel, "parallel", "p", defaultParallel, - "Allow P resource operations to run in parallel at once (1 for no parallelism, 0 for unbounded parallelism)") + "Allow P resource operations to run in parallel at once (1 for no parallelism). Defaults to unbounded.") cmd.PersistentFlags().BoolVar( &showConfig, "show-config", false, "Show configuration keys and variables") diff --git a/cmd/refresh.go b/cmd/refresh.go index 63f987892..bef874587 100644 --- a/cmd/refresh.go +++ b/cmd/refresh.go @@ -142,7 +142,7 @@ func newRefreshCmd() *cobra.Command { "Display operation as a rich diff showing the overall change") cmd.PersistentFlags().IntVarP( ¶llel, "parallel", "p", defaultParallel, - "Allow P resource operations to run in parallel at once (1 for no parallelism, 0 for unbounded parallelism)") + "Allow P resource operations to run in parallel at once (1 for no parallelism). Defaults to unbounded.") cmd.PersistentFlags().BoolVar( &showReplacementSteps, "show-replacement-steps", false, "Show detailed resource replacement creates and deletes instead of a single step") diff --git a/cmd/up.go b/cmd/up.go index 56bd50ffc..aa3fbb99f 100644 --- a/cmd/up.go +++ b/cmd/up.go @@ -17,6 +17,7 @@ package cmd import ( "context" "io/ioutil" + "math" "os" "github.com/pulumi/pulumi/pkg/tokens" @@ -36,7 +37,7 @@ import ( ) const ( - defaultParallel = 0 + defaultParallel = math.MaxInt32 ) // nolint: vetshadow, intentionally disabling here for cleaner err declaration/assignment. @@ -328,7 +329,7 @@ func newUpCmd() *cobra.Command { "Display operation as a rich diff showing the overall change") cmd.PersistentFlags().IntVarP( ¶llel, "parallel", "p", defaultParallel, - "Allow P resource operations to run in parallel at once (1 for no parallelism, 0 for unbounded parallelism)") + "Allow P resource operations to run in parallel at once (1 for no parallelism). Defaults to unbounded.") cmd.PersistentFlags().BoolVarP( &refresh, "refresh", "r", false, "Refresh the state of the stack's resources before this update") diff --git a/pkg/resource/deploy/plan.go b/pkg/resource/deploy/plan.go index fbce7a1d1..ef3eade4c 100644 --- a/pkg/resource/deploy/plan.go +++ b/pkg/resource/deploy/plan.go @@ -16,6 +16,7 @@ package deploy import ( "context" + "math" "github.com/blang/semver" "github.com/pkg/errors" @@ -50,7 +51,7 @@ func (o Options) DegreeOfParallelism() int { // InfiniteParallelism returns whether or not the requested level of parallelism is unbounded. func (o Options) InfiniteParallelism() bool { - return o.Parallel == 0 + return o.Parallel == math.MaxInt32 } // Events is an interface that can be used to hook interesting engine/planning events.