Skip to content

Commit

Permalink
[PLAT-14188] Fixing upgrade disk availability check
Browse files Browse the repository at this point in the history
Summary: In newer installs we don't write the .installed marker file and instead store the state in a state file. This diff adds support to also check the state file when performing checks for installed status.

Test Plan: Create YBA on VM with 50GB disk space skipping space check, ensure upgrade automatically succeeds.

Reviewers: dshubin, sanketh

Reviewed By: dshubin

Subscribers: yugaware

Differential Revision: https://phorge.dev.yugabyte.com/D36028
  • Loading branch information
mchiddy committed Jun 26, 2024
1 parent 7c99ff9 commit ef31455
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 16 deletions.
7 changes: 6 additions & 1 deletion managed/yba-installer/cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 0 additions & 2 deletions managed/yba-installer/cmd/log_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),

Expand Down
5 changes: 0 additions & 5 deletions managed/yba-installer/cmd/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 0 additions & 6 deletions managed/yba-installer/pkg/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 8 additions & 2 deletions managed/yba-installer/pkg/preflight/checks/diskavail.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit ef31455

Please sign in to comment.