feat: retry forgetting device when device is busy (#26)

This commit is contained in:
Mateusz Filipowicz
2025-02-26 09:31:32 +01:00
committed by GitHub
parent 4250c1583b
commit af1aa62b3f
2 changed files with 24 additions and 7 deletions

View File

@@ -1,15 +1,23 @@
name: Acceptance Tests
on:
pull_request:
paths-ignore:
- "README.md"
paths:
- "internal/**"
- "scripts/**"
- "tools/**"
- "main.go"
- "docker-compose.yaml"
push:
branches:
- "main"
tags:
- "v*"
paths-ignore:
- "README.md"
paths:
- "internal/**"
- "scripts/**"
- "tools/**"
- "main.go"
- "docker-compose.yaml"
schedule:
- cron: "0 13 * * *"
jobs:
@@ -55,4 +63,5 @@ jobs:
timeout_minutes: 20
max_attempts: 3
command: make testacc TEST_TIMEOUT=1h UNIFI_STDOUT=true UNIFI_VERSION=${{ matrix.unifi_download_url && 'beta' || matrix.unifi_version }} UNIFI_DOWNLOAD_URL=${{ matrix.unifi_download_url }}
retry_on: "timeout"
# retry_on: "all"
retry_on: "timeout"

View File

@@ -260,8 +260,16 @@ func resourceDeviceDelete(ctx context.Context, d *schema.ResourceData, meta inte
if site == "" {
site = c.Site
}
err := c.ForgetDevice(ctx, site, mac)
err := retry.RetryContext(ctx, 1*time.Minute, func() *retry.RetryError {
internalErr := c.ForgetDevice(ctx, site, mac)
if internalErr == nil {
return nil
}
if base.IsServerErrorContains(internalErr, "api.err.DeviceBusy") {
return retry.RetryableError(internalErr)
}
return retry.NonRetryableError(internalErr)
})
if err != nil {
return diag.FromErr(err)
}