Skip to content

Commit

Permalink
fetch upgrade status per appliance
Browse files Browse the repository at this point in the history
  • Loading branch information
kajes committed Jun 26, 2024
1 parent 5137767 commit ab03245
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cmd/appliance/upgrade/complete.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func upgradeCompleteRun(cmd *cobra.Command, args []string, opts *upgradeComplete
if err != nil {
return err
}
plan, err := appliancepkg.NewUpgradePlan(rawAppliances, *initialStats, controlHost, filter, orderBy, descending)
plan, err := appliancepkg.NewUpgradePlan(a, rawAppliances, *initialStats, controlHost, filter, orderBy, descending)
if err != nil {
return err
}
Expand Down
12 changes: 10 additions & 2 deletions pkg/appliance/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package appliance

import (
"bytes"
"context"
"errors"
"fmt"
"io"
Expand Down Expand Up @@ -49,7 +50,7 @@ type UpgradePlan struct {
adminHostname string
}

func NewUpgradePlan(appliances []openapi.Appliance, stats openapi.StatsAppliancesList, adminHostname string, filter map[string]map[string]string, orderBy []string, descending bool) (*UpgradePlan, error) {
func NewUpgradePlan(api *Appliance, appliances []openapi.Appliance, stats openapi.StatsAppliancesList, adminHostname string, filter map[string]map[string]string, orderBy []string, descending bool) (*UpgradePlan, error) {
plan := UpgradePlan{
adminHostname: adminHostname,
stats: stats,
Expand Down Expand Up @@ -123,7 +124,14 @@ func NewUpgradePlan(appliances []openapi.Appliance, stats openapi.StatsAppliance
}

// Get upgrade status and target version
upgradeStatus := stats.GetUpgrade()
upgradeStatus, err := api.UpgradeStatus(context.Background(), a.GetId())
if err != nil {
plan.Skipping = append(plan.Skipping, SkipUpgrade{
Appliance: a,
Reason: ErrNoApplianceStats,
})
continue
}
if status := upgradeStatus.GetStatus(); status != UpgradeStatusReady {
plan.Skipping = append(plan.Skipping, SkipUpgrade{
Appliance: a,
Expand Down

0 comments on commit ab03245

Please sign in to comment.