Skip to content

Commit

Permalink
ibu: add extra check for stage to avoid going into poll
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Chuzhoy <[email protected]>
  • Loading branch information
achuzhoy committed Apr 19, 2024
1 parent 69f4071 commit 245dd31
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pkg/lca/imagebasedupgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const (
isFalse = "False"
isComplete = "Completed"
ibuName = "upgrade"
idle = "Idle"
)

// ImageBasedUpgradeBuilder provides struct for the imagebasedupgrade object containing connection to
Expand Down Expand Up @@ -366,6 +367,8 @@ func (builder *ImageBasedUpgradeBuilder) WithSeedImagePullSecretRef(

// WaitUntilStageComplete waits the specified timeout for the imagebasedupgrade to complete
// actions for the provided stage .
//
//nolint:gocognit
func (builder *ImageBasedUpgradeBuilder) WaitUntilStageComplete(stage string) (*ImageBasedUpgradeBuilder, error) {
if valid, err := builder.validate(); !valid {
return builder, err
Expand All @@ -381,6 +384,10 @@ func (builder *ImageBasedUpgradeBuilder) WaitUntilStageComplete(stage string) (*
return builder, fmt.Errorf(builder.errorMsg)
}

if stage != idle && stage != "Prep" && stage != "Upgrade" && stage != "Rollback" {
return builder, fmt.Errorf("wrong stage selected for imagebasedupgrade")
}

// Polls periodically to determine if imagebasedupgrade is in desired state.
var err error
err = wait.PollUntilContextTimeout(
Expand All @@ -395,8 +402,8 @@ func (builder *ImageBasedUpgradeBuilder) WaitUntilStageComplete(stage string) (*

for _, condition := range builder.Object.Status.Conditions {
switch stage {
case "Idle":
if condition.Status == isTrue && condition.Type == "Idle" {
case idle:
if condition.Status == isTrue && condition.Type == idle {
return true, nil
}

Expand Down

0 comments on commit 245dd31

Please sign in to comment.