diff --git a/managed/yba-installer/cmd/install.go b/managed/yba-installer/cmd/install.go index db221293bf19..5345e9af8204 100644 --- a/managed/yba-installer/cmd/install.go +++ b/managed/yba-installer/cmd/install.go @@ -23,7 +23,12 @@ var installCmd = &cobra.Command{ `, Args: cobra.NoArgs, PreRun: func(cmd *cobra.Command, args []string) { - if _, err := os.Stat(common.YbaInstalledMarker()); err == nil { + state, err := ybactlstate.Initialize() + if err != nil { + if _, err := os.Stat(common.YbaInstalledMarker()); err != nil { + log.Fatal("YugabyteDB Anywhere already installed, cannot install twice.") + } + } else if state.CurrentStatus == ybactlstate.InstalledStatus { log.Fatal("YugabyteDB Anywhere already installed, cannot install twice.") } if common.RunFromInstalled() { diff --git a/managed/yba-installer/cmd/log_gen.go b/managed/yba-installer/cmd/log_gen.go index 8d02b37433f9..0a221cb60d6f 100644 --- a/managed/yba-installer/cmd/log_gen.go +++ b/managed/yba-installer/cmd/log_gen.go @@ -55,8 +55,6 @@ other useful data.`, common.YbactlLogFile(), filepath.Join(common.YbactlInstallDir(), ybactlstate.StateFileName), filepath.Join(common.YbactlInstallDir(), common.VersionMetadataJSON), - common.YbaInstalledMarker(), - common.YbaInstallingMarker(), common.LicenseFile(), filepath.Join(common.YbactlInstallDir(), common.GoBinaryName), diff --git a/managed/yba-installer/cmd/upgrade.go b/managed/yba-installer/cmd/upgrade.go index 3d8f5f50251f..5afb658bc08f 100644 --- a/managed/yba-installer/cmd/upgrade.go +++ b/managed/yba-installer/cmd/upgrade.go @@ -128,11 +128,6 @@ func upgradeCmd() *cobra.Command { log.Fatal("preflight failed") } - state.CurrentStatus = ybactlstate.UpgradingStatus - if err := ybactlstate.StoreState(state); err != nil { - log.Fatal("could not update state: " + err.Error()) - } - // Take a backup of YBA as a safety measure backupDir := filepath.Join(common.GetDataRoot(), "upgradeYbaBackup") if err := common.MkdirAll(backupDir, common.DirMode); err == nil { diff --git a/managed/yba-installer/pkg/common/common.go b/managed/yba-installer/pkg/common/common.go index 182724209ea9..4d1e587bf5c0 100644 --- a/managed/yba-installer/pkg/common/common.go +++ b/managed/yba-installer/pkg/common/common.go @@ -29,12 +29,6 @@ import ( // all services. func Install(version string) error { log.Info("Starting Common install") - // Hidden file written on first install (.installCompleted) at the end of the install, - // if the file already exists then it means that an installation has already taken place, - // and that future installs are prohibited. - if _, err := os.Stat(YbaInstalledMarker()); err == nil { - log.Fatal("Install of YBA already completed, cannot perform reinstall without clean.") - } // Change into the dir we are in so that we can specify paths relative to ourselves // TODO(minor): probably not a good idea in the long run diff --git a/managed/yba-installer/pkg/preflight/checks/diskavail.go b/managed/yba-installer/pkg/preflight/checks/diskavail.go index 41aa1a4434fb..7acae63df1d2 100644 --- a/managed/yba-installer/pkg/preflight/checks/diskavail.go +++ b/managed/yba-installer/pkg/preflight/checks/diskavail.go @@ -14,6 +14,7 @@ import ( "github.com/dustin/go-humanize" "github.com/yugabyte/yugabyte-db/managed/yba-installer/pkg/common" log "github.com/yugabyte/yugabyte-db/managed/yba-installer/pkg/logging" + "github.com/yugabyte/yugabyte-db/managed/yba-installer/pkg/ybactlstate" ) const minFreeDiskInstall uint64 = 200 * 1024 * 1024 * 1024 // 200 GB @@ -54,8 +55,13 @@ func (r diskAvailCheck) Execute() Result { } minDiskReq := minFreeDiskInstall - _, err = os.Stat(common.YbaInstalledMarker()) - if err == nil { + state, err := ybactlstate.Initialize() + if err != nil { + if _, err := os.Stat(common.YbaInstalledMarker()); err != nil { + // upgrade + minDiskReq = minFreeDiskUpgrade + } + } else if state.CurrentStatus == ybactlstate.UpgradingStatus { // upgrade minDiskReq = minFreeDiskUpgrade }