Commit graph

27 commits

Author SHA1 Message Date
Julian Brost
9946fa5902
Merge pull request #767 from Icinga/icingadb-migrate-null-name-i766
icingadb-migrate: Mitigate NULL names in {comment,downtime}_query
2024-07-31 10:29:16 +02:00
Alexander A. Klimov
b6839ce9f0 cmd/icingadb-migrate: replace magic number 20 with sha1.Size 2024-07-09 13:30:08 +00:00
Alvar Penning
b7483eb6f8
icingadb-migrate: Verify env ID length
An env ID with the wrong length, either due to a copy-paste error or
human error during testing, results in a SQL CHECK CONSTRAINT violation
that is retried multiple times until it finally fails.
2024-07-09 13:24:01 +02:00
Alvar Penning
59685cd623
icingadb-migrate: Mitigate NULL names in {comment,downtime}_query
Historical data from an older Icinga 2 installation contained NULL
values for the name column in some rows of the icinga_commenthistory and
icinga_downtimehistory tables.

Normally this field contains something like
${name1}!${name2}!${unique_value} where the $unique_value is based on a
timestamp for older entries and a UUID for newer ones. For a concrete
example, this could be "host.example.com!ping6!123…".

Unfortunately, using an empty string for these NULL values will cause an
error later because the new primary key will be calculated based on it.
Therefore, a new deterministic name is generated based on the primary
keys and the known name1 and name2 values.

Closes #766.
2024-07-09 13:05:36 +02:00
Eric Lippmann
7c068d4adf Use icinga-go-library 2024-05-24 09:56:28 +02:00
Eric Lippmann
8beb8616ad Move database related code from internal to database 2024-05-22 11:51:22 +02:00
Eric Lippmann
1ddaa70aab Move special types to icingadb/types 2024-05-22 11:51:21 +02:00
Eric Lippmann
9eddcac7fb icingadb-migrate: Don't alias types import 2024-05-22 11:51:21 +02:00
Eric Lippmann
f54a142815 Move icingadb#DB to database#DB 2024-05-22 11:51:21 +02:00
Eric Lippmann
490c18fd5f Move database#DB.CheckSchema() to icingadb#CheckSchema() 2024-05-22 11:51:21 +02:00
Eric Lippmann
ed69f42462 Move utils#TableName() to database#TableName() 2024-05-22 11:51:21 +02:00
Eric Lippmann
75501e11f8 Move database related contracts to database/contracts 2024-05-22 11:51:21 +02:00
Eric Lippmann
7b537661ee Move icingadb/objectpacker to objectpacker 2024-05-22 11:51:21 +02:00
Eric Lippmann
9e70aa808c Move config to internal/config 2024-05-22 11:51:21 +02:00
Alexander A. Klimov
2681634105 Unify check attempt data type to uint32 already used somewhere
A float isn't necessary as in Icinga 2 Checkable#max_check_attempts and
check_attempt are ints. But uint8 isn't enough for e.g. 1 check/s to get
HARD after 5m (300s > 255).
2024-04-08 16:01:53 +02:00
Yonas Habteab
eaf9744f16 Move pkg/driver to pkg/icingadb/driver.go 2024-03-28 13:19:44 +01:00
Alexander A. Klimov
10afc562ce Use types.MakeString() instead of manual initialization (refactor) 2024-03-25 14:52:54 +01:00
Julian Brost
336ee4a8ab
Merge pull request #554 from Icinga/553
convertFlappingRows(): fix foreign key error history -> flapping_history
2023-07-31 15:00:39 +02:00
Julian Brost
71c1d2fa4d Migration: refactor output/processing of converted entities
This commit simplifies the `icingaDbOutputStage` type to contain only one
entity slice to be insert/upsert. This allows to simplify the handling in
`migrateOneType()` by removing nested loops.

Additionally, a bit of code inside that function is outsourced into a new
`utils.ChanFromSlice()` function. This makes the body of the loop over the
insert/upsert operation (the loop using the `op` variable) simple enough so
that it can just be unrolled which saves the inline struct and slice definition
for that loop.
2023-07-31 11:10:42 +02:00
Alexander A. Klimov
78327c1f34 cmd/icingadb-migrate: ignore icinga_downtimehistory#was_started=0 rows
Such appear e.g. for scheduled but never triggered flexible Downtimes.
Not triggered = no events.
2023-07-27 17:29:33 +02:00
Julian Brost
5ea6831ebc
Merge pull request #551 from Icinga/550
icingadb-migrate: handle NULL event time columns
2023-07-25 16:38:55 +02:00
Alexander A. Klimov
a163694dc6 Config parsing: fail on unknown fields and print them
Useful against config validation or runtime failures
caused by wrong field spelling or YAML indentation.
2023-06-19 17:38:52 +02:00
Alexander A. Klimov
3d571548e8 icingadb-migrate: handle NULL event time columns
Ignore such rows.
2023-05-26 12:50:41 +02:00
Alexander A. Klimov
03b0e84808 convertFlappingRows(): fix foreign key error history -> flapping_history
Don't INSERT IGNORE everything, then UPSERT everything. Instead INSERT IGNORE
flapping_history, UPSERT flapping_history and finally INSERT IGNORE history.
2022-12-19 16:07:55 +01:00
Alexander A. Klimov
a778fc8d34 migrateOneType(): allow multiple stages of INSERT IGNORE, UPSERT
Refactor the converters so they can signal the caller to behave not as usual
i.e. not to INSERT IGNORE everything, then UPSERT everything.
2022-12-19 16:07:53 +01:00
Alexander A. Klimov
cfaee2e3d4 cmd/icingadb-migrate: avoid unnecessary config option
for columns which are NULLable anyway.
2022-11-07 12:35:31 +01:00
Alexander A. Klimov
6a5f3fd02f cmd/: rename ido2icingadb/ to icingadb-migrate/ 2022-10-26 11:18:52 +02:00