BigBoot / AutoKuma

AutoKuma is a utility that automates the creation of Uptime Kuma monitors based on Docker container labels. With AutoKuma, you can eliminate the need for manual monitor creation in the Uptime Kuma UI.
MIT License
307 stars 15 forks source link

[unreleased] AutoKuma db out of sync due to groups creation not prioritized #92

Open landure opened 2 weeks ago

landure commented 2 weeks ago

Hi,

I was incorrectly using master image. This issue occured:

with the introduction of AutoKuma database, an unwanted behavior appeared (with static monitors)

# group.toml
type = "group"
name = "My Group"
# alpaga.com.toml
type = "http"
name = "alpaga"
parent_name="group"
url = "https://www.alpaga.com/"
max_retries = 3
retry_interval = 60
notification_id_list = {"1"= true}

If alpaga.com is created before the group, Uptime Kuma responds with this error:

 WARN [autokuma::sync] Encountered error during sync: Server responded with an error: INSERT INTO monitor_tag (tag_id, monitor_id, value) VALUES (1, 92, 'group') - SQLITE_CONSTRAINT: FOREIGN KEY constraint failed

alpaga.com is created in Uptime Kuma, without parent group, but not stored in AutoKuma database. AutoKuma will then create several alpaga.com probes, until the creation of the parent group.

This is also the case when the notification is missing.

This behavior was not an issue when AutoKuma based itself on labels to identifys its entries in Uptime Kuma.

BigBoot commented 2 weeks ago

Hmm I'd consider this a bug in uptime kuma tbh. The monitor should not be created if an error happens, I also can't just ignore the error on the autokuma side because I never get the id of the monitor in case of an error.

Btw this can only happen when manually referencing an id (e.g. in your notification_id_list), when using one of the _names the id is resolved locally, so this error is not actually originating from your monitor->group relation but something else. The error seems to indicate this is from a missing "Tag" not a missing parent monitor.