Skip to content

Commit

Permalink
MGMT-17384: Change waiting for encapsulated machine config from retry…
Browse files Browse the repository at this point in the history
… to wait-for-predicate

When the function ops.GetEncapsulatedMC takes too long, the host stage 'Writing image to disk'
times out since retry is used.
This changes the machanism to timeout instead of retry.
  • Loading branch information
ori-amizur committed Apr 1, 2024
1 parent 3e7a76c commit 4a22426
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/installer/installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package installer

import (
"context"
stderrors "errors"
"fmt"
"net/http"
"path/filepath"
Expand Down Expand Up @@ -274,15 +275,17 @@ func convertToOverwriteKargs(args []string) []string {
}

func (i *installer) getEncapsulatedMC(ignitionPath string) (*mcfgv1.MachineConfig, error) {
interval := 5 * time.Second
var mc *mcfgv1.MachineConfig
err := utils.Retry(240, interval, i.log, func() error {
var gerr error
mc, gerr = i.ops.GetEncapsulatedMC(ignitionPath)
return gerr
var err error
waitErr := utils.WaitForPredicate(20*time.Minute, 5*time.Second, func() bool {
mc, err = i.ops.GetEncapsulatedMC(ignitionPath)
if err != nil {
i.log.WithError(err).Warningf("failed to get encapsulated Machine Config")
}
return err == nil
})
if err != nil {
return nil, err
if waitErr != nil {
return nil, stderrors.Join(waitErr, err)
}
return mc, nil
}
Expand Down

0 comments on commit 4a22426

Please sign in to comment.