AutoKuma icon indicating copy to clipboard operation
AutoKuma copied to clipboard

Monitor is being created indefinitely if configured notification_id does not exist

Open AurimasNav opened this issue 1 year ago • 3 comments

error:

WARN [autokuma::sync] Encountered error during sync: Server responded with an error: insert into monitor_notification (monitor_id, notification_id) values (97, '1') - SQLITE_CONSTRAINT: FOREIGN KEY constraint failed

In reality monitor is created in uptime kuma, but autokuma keeps on recreating it in indefinite loop.

monitor example:

{
    "name": "domain.internal",
    "type": "http",
    "url": "https://domain.internal",
    "timeout": "10",
    "interval": "60",
    "retryInterval": "20",
    "accepted_statuscodes": ["200-299"],
    "notificationIDList": {
        "1": true
    },
    "ignoreTls": true,
    "parent_name": "prod"
}

Scenario in which this happens - I try to redeploy uptime kuma + autokuma from code, since not all objects can be defined in code (in this case notifications) some objects are missing initially and this causes the creation loop.

AurimasNav avatar Jan 07 '25 09:01 AurimasNav

I've already mentioned this in some other issue but this is a uptime kuma bug. There's basically nothing I can do about this, uptime kuma does not report the id of the newly created monitor in this failure case so there's no way for autokuma to know about the new monitor and frankly uptime kuma should probably clean up any half created monitors anyway.

Btw. since you're already on master, you can create notifications (and tags and docker_hosts) using autokuma, see https://github.com/BigBoot/AutoKuma/issues/81

BigBoot avatar Jan 07 '25 10:01 BigBoot

Could autokuma check if the notification_id is present in uptime-kuma and refuse to create monitor if it does not exist?

AurimasNav avatar Jan 07 '25 10:01 AurimasNav

I've already mentioned this in some other issue but this is a uptime kuma bug. There's basically nothing I can do about this, uptime kuma does not report the id of the newly created monitor in this failure case so there's no way for autokuma to know about the new monitor and frankly uptime kuma should probably clean up any half created monitors anyway.

Btw. since you're already on master, you can create notifications (and tags and docker_hosts) using autokuma, see #81

how do I create a tag? I don't see it on the entity types list - https://github.com/BigBoot/AutoKuma/blob/master/ENTITY_TYPES.md

AurimasNav avatar Jan 07 '25 15:01 AurimasNav