Skip to content

Commit

Permalink
[PLAT-13040][PLAT-12428] YBA Installer improvements
Browse files Browse the repository at this point in the history
Summary:
Updated status command to show all provided hostnames, not just the first.

Added a new preflight check that will block upgrades if a service is offline.

Fixed issue with generate-config not working with sudo.

Test Plan: tested the 3 changes via install + upgrade + status

Reviewers: muthu, sanketh

Reviewed By: muthu

Subscribers: yugaware

Differential Revision: https://phorge.dev.yugabyte.com/D40064
  • Loading branch information
shubin-yb committed Dec 3, 2024
1 parent 58034b5 commit 19f6032
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 4 deletions.
10 changes: 9 additions & 1 deletion managed/yba-installer/cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/yugabyte/yugabyte-db/managed/yba-installer/pkg/components/ybactl"
"github.com/yugabyte/yugabyte-db/managed/yba-installer/pkg/config"
log "github.com/yugabyte/yugabyte-db/managed/yba-installer/pkg/logging"
"github.com/yugabyte/yugabyte-db/managed/yba-installer/pkg/preflight/checks"
)

var (
Expand Down Expand Up @@ -55,8 +56,10 @@ func initAfterFlagsParsed(cmdName string) {

// Replicated migration handles config and root checks on its own.
// License does not need any config, so skip for now
// Generate config will create the config, and set as_root as needed.
if !(strings.HasPrefix(cmdName, "yba-ctl replicated-migrate") ||
strings.HasPrefix(cmdName, "yba-ctl license")) {
strings.HasPrefix(cmdName, "yba-ctl license") ||
strings.HasPrefix(cmdName, "yba-ctl generate-config")) {
handleRootCheck(cmdName)
}

Expand Down Expand Up @@ -113,6 +116,11 @@ func initServices() {
} else {
serviceOrder = []string{PrometheusServiceName, YbPlatformServiceName}
}
serviceList := []common.Component{}
for _, service := range services {
serviceList = append(serviceList, service)
}
checks.SetServicesRunningCheck(serviceList)
// populate names of services for valid args
}

Expand Down
12 changes: 9 additions & 3 deletions managed/yba-installer/pkg/common/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"os"
"strconv"
"strings"
"text/tabwriter"

"github.com/spf13/viper"
Expand Down Expand Up @@ -66,10 +67,15 @@ func generalStatus(stateStatus string) {
if hostnames == nil || len(hostnames) == 0 {
log.Fatal("Could not read host in yba-ctl.yml")
}
ybaUrl := "https://" + hostnames[0]
if viper.GetInt("platform.port") != 443 {
ybaUrl += fmt.Sprintf(":%d", viper.GetInt("platform.port"))
ybaUrls := []string{}
for _, host := range hostnames {
url := "https://" + host
if viper.GetInt("platform.port") != 443 {
url += fmt.Sprintf(":%d", viper.GetInt("platform.port"))
}
ybaUrls = append(ybaUrls, url)
}
ybaUrl := strings.Join(ybaUrls, ", ")
statusString := ybaUrl + " \t" + GetBaseInstall() + " \t" + InputFile() + " \t" +
YbactlLogFile() + " \t" + stateStatus + " \t"

Expand Down
61 changes: 61 additions & 0 deletions managed/yba-installer/pkg/preflight/checks/services_running.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package checks

import (
"fmt"
"strings"

"github.com/yugabyte/yugabyte-db/managed/yba-installer/pkg/common"
"github.com/yugabyte/yugabyte-db/managed/yba-installer/pkg/logging"
)

var ServicesRunningCheck *servicesRunningCheck = &servicesRunningCheck{
CheckName: "services_running",
skipAllowed: true,
Services: []common.Component{},
}

func SetServicesRunningCheck(services []common.Component) {
logging.Debug("setting services running check: " + fmt.Sprint(services))
ServicesRunningCheck.Services = services
}

type servicesRunningCheck struct {
CheckName string
skipAllowed bool
Services []common.Component
}

func (s *servicesRunningCheck) Name() string {
return s.CheckName
}

func (s *servicesRunningCheck) SkipAllowed() bool {
return s.skipAllowed
}

func (s *servicesRunningCheck) Execute() Result {
res := Result{
Check: s.CheckName,
Status: StatusPassed,
}

failedServices := make([]string, 0)
for _, service := range s.Services {
status, err := service.Status()
if err != nil {
logging.Error(fmt.Sprintf("Failed to get %s status: %s", service.Name(), err.Error()))
failedServices = append(failedServices, service.Name())
continue
}
if !common.IsHappyStatus(status) {
logging.Error(fmt.Sprintf("%s has bad status %s", service.Name(), status))
failedServices = append(failedServices, service.Name())
}
}
if len(failedServices) > 0 {
res.Error = fmt.Errorf("services '%s' are not running", strings.Join(failedServices, ", "))
res.Status = StatusCritical
}

return res
}
1 change: 1 addition & 0 deletions managed/yba-installer/pkg/preflight/predefined_lists.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ var UpgradeChecks = []Check{
checks.OpenSSL,
checks.Prometheus,
checks.NonRootUpgradeCheck,
checks.ServicesRunningCheck,
}

var ReplicatedMigrateChecks = []Check{
Expand Down

0 comments on commit 19f6032

Please sign in to comment.