Skip to content

Commit

Permalink
cmd/openshift-install/waitfor: Rename from user-provided-infrastructure
Browse files Browse the repository at this point in the history
There is no hard line between installer- and user-provided
infrastructure.  Rename these commands to focus on what they'll do
instead of the work-flow into which we expect them to fit.

We're still working out how we can drop the router-CA injection to
avoid 'wait-for cluster-ready' surprising users my editing their
on-disk kubeconfig [1].  But that's mitigated somewhat by the fact
that addRouterCAToClusterCA is idempotent, because AppendCertsFromPEM
wraps AddCert [2] and AddCert checks to avoid duplicate certificates
[3].

[1]: #1541
[2]: https://github.com/golang/go/blob/go1.12/src/crypto/x509/cert_pool.go#L144
[3]: https://github.com/golang/go/blob/go1.12/src/crypto/x509/cert_pool.go#L106-L109
  • Loading branch information
wking committed Apr 8, 2019
1 parent ee5d518 commit 2a39d8b
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 103 deletions.
4 changes: 2 additions & 2 deletions cmd/openshift-install/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ var (
logrus.Fatal(err)
}

err = finish(ctx, config, rootOpts.dir)
err = waitForClusterReady(ctx, config, rootOpts.dir)
if err != nil {
logrus.Fatal(err)
}
Expand Down Expand Up @@ -433,7 +433,7 @@ func logComplete(directory, consoleURL string) error {
return nil
}

func finish(ctx context.Context, config *rest.Config, directory string) error {
func waitForClusterReady(ctx context.Context, config *rest.Config, directory string) error {
if err := waitForInitializedCluster(ctx, config); err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/openshift-install/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func installerMain() {
for _, subCmd := range []*cobra.Command{
newCreateCmd(),
newDestroyCmd(),
newUPICmd(),
newWaitForCmd(),
newVersionCmd(),
newGraphCmd(),
newCompletionCmd(),
Expand Down
98 changes: 0 additions & 98 deletions cmd/openshift-install/upi.go

This file was deleted.

79 changes: 79 additions & 0 deletions cmd/openshift-install/waitfor.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package main

import (
"context"
"path/filepath"

"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"k8s.io/client-go/tools/clientcmd"
)

func newWaitForCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "wait-for",
Short: "Wait for install-time events",
Long: `Wait for install-time events.
'create cluster' has a few stages that wait for cluster events. But
these waits can also be useful on their own. This subcommand exposes
them directly.`,
RunE: func(cmd *cobra.Command, args []string) error {
return cmd.Help()
},
}
cmd.AddCommand(newWaitForBootstrapCompleteCmd())
cmd.AddCommand(newWaitForClusterReadyCmd())
return cmd
}

func newWaitForBootstrapCompleteCmd() *cobra.Command {
return &cobra.Command{
Use: "bootstrap-complete",
Short: "Wait until cluster bootstrapping has completed",
Args: cobra.ExactArgs(0),
Run: func(_ *cobra.Command, _ []string) {
ctx := context.Background()

cleanup := setupFileHook(rootOpts.dir)
defer cleanup()

config, err := clientcmd.BuildConfigFromFlags("", filepath.Join(rootOpts.dir, "auth", "kubeconfig"))
if err != nil {
logrus.Fatal(errors.Wrap(err, "loading kubeconfig"))
}

err = waitForBootstrapComplete(ctx, config, rootOpts.dir)
if err != nil {
logrus.Fatal(err)
}

logrus.Info("It is now safe to remove the bootstrap resources")
},
}
}

func newWaitForClusterReadyCmd() *cobra.Command {
return &cobra.Command{
Use: "cluster-ready",
Short: "Wait until the cluster is ready",
Args: cobra.ExactArgs(0),
Run: func(cmd *cobra.Command, args []string) {
ctx := context.Background()

cleanup := setupFileHook(rootOpts.dir)
defer cleanup()

config, err := clientcmd.BuildConfigFromFlags("", filepath.Join(rootOpts.dir, "auth", "kubeconfig"))
if err != nil {
logrus.Fatal(errors.Wrap(err, "loading kubeconfig"))
}

err = waitForClusterReady(ctx, config, rootOpts.dir)
if err != nil {
logrus.Fatal(err)
}
},
}
}
4 changes: 2 additions & 2 deletions docs/user/aws/install_upi.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ and load balancer configuration.
## Monitor for `bootstrap-complete` and Initialization

```console
$ bin/openshift-install user-provided-infrastructure bootstrap-complete
$ bin/openshift-install wait-for bootstrap-complete
INFO Waiting up to 30m0s for the Kubernetes API at https://api.test.example.com:6443...
INFO API v1.12.4+c53f462 up
INFO Waiting up to 30m0s for the bootstrap-complete event...
Expand Down Expand Up @@ -248,7 +248,7 @@ TODO: Identify changes needed to Router or Ingress for DNS `*.apps` registration
## Monitor for Cluster Completion

```console
$ bin/openshift-install user-provided-infrastructure finish
$ bin/openshift-install wait-for cluster-ready
INFO Waiting up to 30m0s for the cluster to initialize...
```

Expand Down

0 comments on commit 2a39d8b

Please sign in to comment.