0
0
mirror of https://github.com/bpg/terraform-provider-proxmox.git synced 2025-07-01 02:52:58 +00:00

feat(provider): better error logging when provider can't generate a VM/Container ID (#1645)

Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
This commit is contained in:
Pavel Boldyrev 2024-11-19 21:07:17 -05:00 committed by GitHub
parent 8c17e81476
commit 071cad4df2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -93,6 +93,8 @@ func (g IDGenerator) NextID(ctx context.Context) (int, error) {
var newID *int
var errs []error
id, err := retry.DoWithData(func() (*int, error) {
if g.config.RandomIDs {
//nolint:gosec
@ -109,6 +111,8 @@ func (g IDGenerator) NextID(ctx context.Context) (int, error) {
retry.OnRetry(func(_ uint, err error) {
if strings.Contains(err.Error(), "already exists") && newID != nil {
newID = ptr.Ptr(*newID + 1)
} else {
errs = append(errs, err)
}
}),
retry.Context(ctx),
@ -117,7 +121,8 @@ func (g IDGenerator) NextID(ctx context.Context) (int, error) {
retry.Delay(200*time.Millisecond),
)
if err != nil {
return -1, fmt.Errorf("unable to retrieve the next available VM identifier: %w", err)
errs = append(errs, err)
return -1, fmt.Errorf("unable to retrieve the next available VM identifier: %w", errors.Join(errs...))
}
if !g.config.RandomIDs {