From 0aa3b6682840e50f98689f740d75ddce9fb7fae7 Mon Sep 17 00:00:00 2001 From: Nils Elde Date: Fri, 6 Mar 2020 15:23:51 -0500 Subject: [PATCH] regroup steps into 2 phases; more accurate names --- pkg/api/admin/openshiftcluster.go | 3 +-- .../admin/openshiftcluster_validatestatic_test.go | 4 ++-- pkg/api/openshiftcluster.go | 3 +-- pkg/api/openshiftclusterdocument_example.go | 2 +- pkg/api/zz_generated_installphase_enumer.go | 11 +++++------ pkg/install/install.go | 13 +++++-------- 6 files changed, 15 insertions(+), 21 deletions(-) diff --git a/pkg/api/admin/openshiftcluster.go b/pkg/api/admin/openshiftcluster.go index 4437a2725..1c2727342 100644 --- a/pkg/api/admin/openshiftcluster.go +++ b/pkg/api/admin/openshiftcluster.go @@ -137,7 +137,6 @@ type InstallPhase int // InstallPhase constants. const ( - InstallPhaseDeployStorage InstallPhase = iota - InstallPhaseDeployResources + InstallPhaseBootstrap InstallPhase = iota InstallPhaseRemoveBootstrap ) diff --git a/pkg/api/admin/openshiftcluster_validatestatic_test.go b/pkg/api/admin/openshiftcluster_validatestatic_test.go index 4688de07c..b81d778cc 100644 --- a/pkg/api/admin/openshiftcluster_validatestatic_test.go +++ b/pkg/api/admin/openshiftcluster_validatestatic_test.go @@ -416,12 +416,12 @@ func TestOpenShiftClusterStaticValidateDelta(t *testing.T) { return &OpenShiftCluster{ Properties: Properties{ Install: &Install{ - Phase: InstallPhaseDeployStorage, + Phase: InstallPhaseBootstrap, }, }, } }, - modify: func(oc *OpenShiftCluster) { oc.Properties.Install.Phase = InstallPhaseDeployResources }, + modify: func(oc *OpenShiftCluster) { oc.Properties.Install.Phase = InstallPhaseRemoveBootstrap }, wantErr: "400: PropertyChangeNotAllowed: properties.install.phase: Changing property 'properties.install.phase' is not allowed.", }, { diff --git a/pkg/api/openshiftcluster.go b/pkg/api/openshiftcluster.go index 2bc736d3d..7eecacb69 100644 --- a/pkg/api/openshiftcluster.go +++ b/pkg/api/openshiftcluster.go @@ -213,7 +213,6 @@ type InstallPhase int // InstallPhase constants const ( - InstallPhaseDeployStorage InstallPhase = iota - InstallPhaseDeployResources + InstallPhaseBootstrap InstallPhase = iota InstallPhaseRemoveBootstrap ) diff --git a/pkg/api/openshiftclusterdocument_example.go b/pkg/api/openshiftclusterdocument_example.go index 6a833a50d..5c637c3b4 100644 --- a/pkg/api/openshiftclusterdocument_example.go +++ b/pkg/api/openshiftclusterdocument_example.go @@ -66,7 +66,7 @@ func ExampleOpenShiftClusterDocument() *OpenShiftClusterDocument { }, Install: &Install{ Now: time.Date(1970, 1, 1, 0, 0, 0, 0, time.UTC), - Phase: InstallPhaseDeployStorage, + Phase: InstallPhaseBootstrap, }, StorageSuffix: "rexs1", SSHKey: SecureBytes("ssh-key"), diff --git a/pkg/api/zz_generated_installphase_enumer.go b/pkg/api/zz_generated_installphase_enumer.go index 7f7782819..fd8de98e7 100644 --- a/pkg/api/zz_generated_installphase_enumer.go +++ b/pkg/api/zz_generated_installphase_enumer.go @@ -7,9 +7,9 @@ import ( "fmt" ) -const _InstallPhaseName = "InstallPhaseDeployStorageInstallPhaseDeployResourcesInstallPhaseRemoveBootstrap" +const _InstallPhaseName = "InstallPhaseBootstrapInstallPhaseRemoveBootstrap" -var _InstallPhaseIndex = [...]uint8{0, 25, 52, 79} +var _InstallPhaseIndex = [...]uint8{0, 21, 48} func (i InstallPhase) String() string { if i < 0 || i >= InstallPhase(len(_InstallPhaseIndex)-1) { @@ -18,12 +18,11 @@ func (i InstallPhase) String() string { return _InstallPhaseName[_InstallPhaseIndex[i]:_InstallPhaseIndex[i+1]] } -var _InstallPhaseValues = []InstallPhase{0, 1, 2} +var _InstallPhaseValues = []InstallPhase{0, 1} var _InstallPhaseNameToValueMap = map[string]InstallPhase{ - _InstallPhaseName[0:25]: 0, - _InstallPhaseName[25:52]: 1, - _InstallPhaseName[52:79]: 2, + _InstallPhaseName[0:21]: 0, + _InstallPhaseName[21:48]: 1, } // InstallPhaseString retrieves an enum value from the enum constants string name. diff --git a/pkg/install/install.go b/pkg/install/install.go index 01627aa83..9912ff29b 100644 --- a/pkg/install/install.go +++ b/pkg/install/install.go @@ -137,14 +137,11 @@ func NewInstaller(ctx context.Context, log *logrus.Entry, env env.Interface, db // Install installs an ARO cluster func (i *Installer) Install(ctx context.Context, installConfig *installconfig.InstallConfig, platformCreds *installconfig.PlatformCreds, image *releaseimage.Image) error { steps := map[api.InstallPhase][]interface{}{ - api.InstallPhaseDeployStorage: { + api.InstallPhaseBootstrap: { action(i.createDNS), action(func(ctx context.Context) error { return i.installStorage(ctx, installConfig, platformCreds, image) }), - action(i.incrInstallPhase), - }, - api.InstallPhaseDeployResources: { action(i.installResources), action(i.createPrivateEndpoint), action(i.updateAPIIP), @@ -167,11 +164,11 @@ func (i *Installer) Install(ctx context.Context, installConfig *installconfig.In action(i.updateRouterIP), action(i.configureIngressCertificate), condition{i.ingressControllerReady, 30 * time.Minute}, - action(i.endOfInstallPhase), + action(i.finishInstallation), }, } - err := i.startInstallPhase(ctx) + err := i.startInstallation(ctx) if err != nil { return err } @@ -205,7 +202,7 @@ func (i *Installer) Install(ctx context.Context, installConfig *installconfig.In return nil } -func (i *Installer) startInstallPhase(ctx context.Context) error { +func (i *Installer) startInstallation(ctx context.Context) error { var err error i.doc, err = i.db.PatchWithLease(ctx, i.doc.Key, func(doc *api.OpenShiftClusterDocument) error { if doc.OpenShiftCluster.Properties.Install == nil { @@ -225,7 +222,7 @@ func (i *Installer) incrInstallPhase(ctx context.Context) error { return err } -func (i *Installer) endOfInstallPhase(ctx context.Context) error { +func (i *Installer) finishInstallation(ctx context.Context) error { var err error i.doc, err = i.db.PatchWithLease(ctx, i.doc.Key, func(doc *api.OpenShiftClusterDocument) error { doc.OpenShiftCluster.Properties.Install = nil