move retry function that is only used by osc builder into that builder's common dir instead of the global common dir. Fix bug in quemu where the wrong retry value is checked against.
This commit is contained in:
parent
fa233a6a56
commit
f52a2ad0fa
|
@ -1,4 +1,4 @@
|
|||
package common
|
||||
package retry
|
||||
|
||||
import (
|
||||
"fmt"
|
|
@ -1,4 +1,4 @@
|
|||
package common
|
||||
package retry
|
||||
|
||||
import (
|
||||
"fmt"
|
|
@ -6,7 +6,7 @@ import (
|
|||
"log"
|
||||
|
||||
"github.com/antihax/optional"
|
||||
"github.com/hashicorp/packer/common"
|
||||
"github.com/hashicorp/packer/builder/osc/common/retry"
|
||||
"github.com/outscale/osc-sdk-go/osc"
|
||||
)
|
||||
|
||||
|
@ -68,7 +68,7 @@ func WaitUntilOscSnapshotDone(conn *osc.APIClient, snapshotID string) error {
|
|||
}
|
||||
|
||||
func waitForState(errCh chan<- error, target string, refresh stateRefreshFunc) {
|
||||
err := common.Retry(2, 2, 0, func(_ uint) (bool, error) {
|
||||
err := retry.Retry(2, 2, 0, func(_ uint) (bool, error) {
|
||||
state, err := refresh()
|
||||
if err != nil {
|
||||
return false, err
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
|
||||
"github.com/antihax/optional"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
retry "github.com/hashicorp/packer/common"
|
||||
"github.com/hashicorp/packer/builder/osc/common/retry"
|
||||
"github.com/hashicorp/packer/helper/multistep"
|
||||
"github.com/hashicorp/packer/packer"
|
||||
"github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate"
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/outscale/osc-sdk-go/osc"
|
||||
|
||||
retry "github.com/hashicorp/packer/common"
|
||||
"github.com/hashicorp/packer/builder/osc/common/retry"
|
||||
"github.com/hashicorp/packer/helper/communicator"
|
||||
"github.com/hashicorp/packer/helper/multistep"
|
||||
"github.com/hashicorp/packer/packer"
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
|
||||
"github.com/antihax/optional"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/hashicorp/packer/common"
|
||||
"github.com/hashicorp/packer/builder/osc/common/retry"
|
||||
"github.com/hashicorp/packer/helper/multistep"
|
||||
"github.com/hashicorp/packer/packer"
|
||||
"github.com/outscale/osc-sdk-go/osc"
|
||||
|
@ -41,7 +41,7 @@ func (s *StepStopBSUBackedVm) Run(ctx context.Context, state multistep.StateBag)
|
|||
// does not exist.
|
||||
|
||||
// Work around this by retrying a few times, up to about 5 minutes.
|
||||
err := common.Retry(10, 60, 6, func(i uint) (bool, error) {
|
||||
err := retry.Retry(10, 60, 6, func(i uint) (bool, error) {
|
||||
ui.Message(fmt.Sprintf("Stopping vm, attempt %d", i+1))
|
||||
|
||||
_, _, err = oscconn.VmApi.StopVms(context.Background(), &osc.StopVmsOpts{
|
||||
|
|
|
@ -7,7 +7,6 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/packer/common"
|
||||
"github.com/hashicorp/packer/common/retry"
|
||||
"github.com/hashicorp/packer/helper/multistep"
|
||||
"github.com/hashicorp/packer/packer"
|
||||
|
@ -62,12 +61,13 @@ func (s *stepConvertDisk) Run(ctx context.Context, state multistep.StateBag) mul
|
|||
})
|
||||
|
||||
if err != nil {
|
||||
if err == common.RetryExhaustedError {
|
||||
switch err.(type) {
|
||||
case *retry.RetryExhaustedError:
|
||||
err = fmt.Errorf("Exhausted retries for getting file lock: %s", err)
|
||||
state.Put("error", err)
|
||||
ui.Error(err.Error())
|
||||
return multistep.ActionHalt
|
||||
} else {
|
||||
default:
|
||||
err := fmt.Errorf("Error converting hard drive: %s", err)
|
||||
state.Put("error", err)
|
||||
ui.Error(err.Error())
|
||||
|
|
Loading…
Reference in New Issue