From e3b65ebce979f99a4d71bc139cf54089a0db5718 Mon Sep 17 00:00:00 2001 From: Stephen Benjamin Date: Thu, 16 Jan 2020 09:10:25 -0500 Subject: [PATCH] cmd/openshift-install/create: add env var to preserve bootstrap For a variety of reasons, it may be useful to keep the bootstrap VM around for debugging. My general approach has been to interrupt the installer before it has a chance to delete the bootstrap VM. If the environment variable OPENSHIFT_INSTALL_PRESERVE_BOOTSTRAP is set to any value, the installer will not delete the bootstrap. --- cmd/openshift-install/create.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/cmd/openshift-install/create.go b/cmd/openshift-install/create.go index f9ae4c6bb39..ad175d162ee 100644 --- a/cmd/openshift-install/create.go +++ b/cmd/openshift-install/create.go @@ -5,6 +5,7 @@ import ( "crypto/x509" "fmt" "io/ioutil" + "os" "path/filepath" "strings" "time" @@ -105,10 +106,15 @@ var ( logrus.Fatal("Bootstrap failed to complete: ", err) } - logrus.Info("Destroying the bootstrap resources...") - err = destroybootstrap.Destroy(rootOpts.dir) - if err != nil { - logrus.Fatal(err) + if oi, ok := os.LookupEnv("OPENSHIFT_INSTALL_PRESERVE_BOOTSTRAP"); ok && oi != "" { + logrus.Warn("OPENSHIFT_INSTALL_PRESERVE_BOOTSTRAP is set, not destroying bootstrap resources. " + + "Warning: this should only be used for debugging purposes, and poses a risk to cluster stability.") + } else { + logrus.Info("Destroying the bootstrap resources...") + err = destroybootstrap.Destroy(rootOpts.dir) + if err != nil { + logrus.Fatal(err) + } } err = waitForInstallComplete(ctx, config, rootOpts.dir)