@@ -3,6 +3,7 @@ package cluster
33import (
44 "context"
55 "fmt"
6+ "os"
67 "path/filepath"
78 "strings"
89
@@ -24,6 +25,7 @@ import (
2425 "github.com/openshift/installer/pkg/asset/password"
2526 "github.com/openshift/installer/pkg/asset/quota"
2627 "github.com/openshift/installer/pkg/asset/rhcos"
28+ "github.com/openshift/installer/pkg/clusterapi"
2729 infra "github.com/openshift/installer/pkg/infrastructure/platform"
2830 typesaws "github.com/openshift/installer/pkg/types/aws"
2931 typesazure "github.com/openshift/installer/pkg/types/azure"
@@ -161,9 +163,21 @@ func (c *Cluster) Load(f asset.FileFetcher) (found bool, err error) {
161163 return true , err
162164 }
163165 if len (matches ) != 0 {
164- return true , errors .Errorf ("terraform state files alread exist. There may already be a running cluster" )
166+ return true , fmt .Errorf ("terraform state files already exist. There may already be a running cluster" )
165167 }
166168
169+ matches , err = filepath .Glob (filepath .Join (InstallDir , clusterapi .ArtifactsDir , "envtest.kubeconfig" ))
170+ if err != nil {
171+ return true , fmt .Errorf ("error checking for existence of envtest.kubeconfig: %w" , err )
172+ }
173+
174+ // Cluster-API based installs can be re-entered, but this is an experimental feature
175+ // that should be opted into and only used for testing and development.
176+ reentrant := strings .EqualFold (os .Getenv ("OPENSHIFT_INSTALL_REENTRANT" ), "true" )
177+
178+ if ! reentrant && len (matches ) != 0 {
179+ return true , fmt .Errorf ("local infrastructure provisioning artifacts already exist. There may already be a running cluster" )
180+ }
167181 return false , nil
168182}
169183
0 commit comments