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

Add --tear-down-early, defaulting to true #19

Merged
merged 1 commit into from
Feb 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cmd/cluster-bootstrap/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ var (
strict bool
requiredPodClauses []string
waitForTearDownEvent string
earlyTearDown bool
}
)

Expand All @@ -42,6 +43,7 @@ func init() {
cmdStart.Flags().BoolVar(&startOpts.strict, "strict", false, "Strict mode will cause start command to exit early if any manifests in the asset directory cannot be created.")
cmdStart.Flags().StringSliceVar(&startOpts.requiredPodClauses, "required-pods", defaultRequiredPods, "List of pods name prefixes with their namespace (written as <namespace>/<pod-prefix>) that are required to be running and ready before the start command does the pivot, or alternatively a list of or'ed pod prefixes with a description (written as <desc>:<namespace>/<pod-prefix>|<namespace>/<pod-prefix>|...).")
cmdStart.Flags().StringVar(&startOpts.waitForTearDownEvent, "tear-down-event", "", "if this optional event name of the form <ns>/<event-name> is given, the event is waited for before tearing down the bootstrap control plane")
cmdStart.Flags().BoolVar(&startOpts.earlyTearDown, "tear-down-early", true, "tear down immediate after the non-bootstrap control plane is up and bootstrap-success event is created.")
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: immediately

}

func runCmdStart(cmd *cobra.Command, args []string) error {
Expand All @@ -56,6 +58,7 @@ func runCmdStart(cmd *cobra.Command, args []string) error {
Strict: startOpts.strict,
RequiredPodPrefixes: podPrefixes,
WaitForTearDownEvent: startOpts.waitForTearDownEvent,
EarlyTearDown: startOpts.earlyTearDown,
})
if err != nil {
return err
Expand Down
23 changes: 17 additions & 6 deletions pkg/start/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type Config struct {
Strict bool
RequiredPodPrefixes map[string][]string
WaitForTearDownEvent string
EarlyTearDown bool
}

type startCommand struct {
Expand All @@ -42,6 +43,7 @@ type startCommand struct {
strict bool
requiredPodPrefixes map[string][]string
waitForTearDownEvent string
earlyTearDown bool
}

func NewStartCommand(config Config) (*startCommand, error) {
Expand All @@ -51,6 +53,7 @@ func NewStartCommand(config Config) (*startCommand, error) {
strict: config.Strict,
requiredPodPrefixes: config.RequiredPodPrefixes,
waitForTearDownEvent: config.WaitForTearDownEvent,
earlyTearDown: config.EarlyTearDown,
}, nil
}

Expand Down Expand Up @@ -133,10 +136,16 @@ func (b *startCommand) Run() error {
return err
}

// switch over to ELB client and continue with the assets
// continue with assets
ctx, cancel = context.WithTimeout(context.Background(), assetsCreatedTimeout)
defer cancel()
assetsDone = createAssetsInBackground(ctx, cancel, restConfig)
if b.earlyTearDown {
// switch over to ELB client and continue with the assets
assetsDone = createAssetsInBackground(ctx, cancel, restConfig)
} else {
// we don't tear down the local control plane early. So we can keep using it and enjoy the speed up.
assetsDone = createAssetsInBackground(ctx, cancel, localClientConfig)
}

// optionally wait for tear down event coming from the installer. This is necessary to
// remove the bootstrap node from the AWS load balancer.
Expand All @@ -153,10 +162,12 @@ func (b *startCommand) Run() error {
}

// tear down the bootstrap control plane. Set bcp to nil to avoid a second tear down in the defer func.
err = bcp.Teardown()
bcp = nil
if err != nil {
UserOutput("Error tearing down temporary bootstrap control plane: %v\n", err)
if b.earlyTearDown {
err = bcp.Teardown()
bcp = nil
if err != nil {
UserOutput("Error tearing down temporary bootstrap control plane: %v\n", err)
}
}

// wait for the tail of assets to be created after tear down
Expand Down