Commit graph

1971 commits

Author SHA1 Message Date
Eric Lippmann
e5a830cabc Move internal/config#ParseFlags() to config#ParseFlags() 2024-05-22 11:51:22 +02:00
Eric Lippmann
8beb8616ad Move database related code from internal to database 2024-05-22 11:51:22 +02:00
Eric Lippmann
c41cbf260e Move TLS config options to config#TLS 2024-05-22 11:51:21 +02:00
Eric Lippmann
563045cc5a Add logging#Config 2024-05-22 11:51:21 +02:00
Eric Lippmann
1d9dc74391 Add utils#IsUnixAddr() 2024-05-22 11:51:21 +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
aa3c00893f Move contracts#Waiter{,Func} to com#Waiter{,Func} 2024-05-22 11:51:21 +02:00
Eric Lippmann
a62c7e7c53 Move com#SplitOnDupId() to database#SplitOnDupId() 2024-05-22 11:51:21 +02:00
Eric Lippmann
9f432e49a5 Make com#CopyFirst() generic 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
aec0bdada4 Introduce icingadb#RetryConnectorCallbacks
This is a preparation to decouple general database code from Icinga DB
specific code, i.e. `icingaredis/telemetry`.
2024-05-22 11:51:21 +02:00
Eric Lippmann
1e32978651 Use google/go-cmp to determine equality of checksums
Otherwise we would have to move the `Equaler` interface to the
`types` package, which is pretty useless for a single use case.
2024-05-22 11:51:21 +02:00
Eric Lippmann
77ccdfc303 Move type related utility functions from internal to types 2024-05-22 11:51:21 +02:00
Eric Lippmann
2f3bf491d7 Move utils#Name() to types#Name() 2024-05-22 11:51:21 +02:00
Eric Lippmann
b2a43fd47d types#Binary: Assert fmt.Stringer interface compliance
This prevents import cycles because the `database` package uses the
`types` packages.
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
e2b4f0297f Introduce strcase for converting string cases 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
43685e4131 Move internal#CantPerformQuery() to database#CantPerformQuery() 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
Eric Lippmann
1d6c63b9f3
Merge pull request #749 from Icinga/dependabot/go_modules/tests/github.com/jmoiron/sqlx-1.4.0
build(deps): bump github.com/jmoiron/sqlx from 1.3.5 to 1.4.0 in /tests
2024-05-22 11:51:00 +02:00
Eric Lippmann
1a72d2fe1f
Merge pull request #748 from Icinga/dependabot/go_modules/github.com/jmoiron/sqlx-1.4.0
build(deps): bump github.com/jmoiron/sqlx from 1.3.5 to 1.4.0
2024-05-22 11:50:50 +02:00
dependabot[bot]
1d058f175a
build(deps): bump github.com/jmoiron/sqlx from 1.3.5 to 1.4.0 in /tests
Bumps [github.com/jmoiron/sqlx](https://github.com/jmoiron/sqlx) from 1.3.5 to 1.4.0.
- [Release notes](https://github.com/jmoiron/sqlx/releases)
- [Commits](https://github.com/jmoiron/sqlx/compare/v1.3.5...v1.4.0)

---
updated-dependencies:
- dependency-name: github.com/jmoiron/sqlx
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-23 18:52:25 +00:00
dependabot[bot]
4622efcabc
build(deps): bump github.com/jmoiron/sqlx from 1.3.5 to 1.4.0
Bumps [github.com/jmoiron/sqlx](https://github.com/jmoiron/sqlx) from 1.3.5 to 1.4.0.
- [Release notes](https://github.com/jmoiron/sqlx/releases)
- [Commits](https://github.com/jmoiron/sqlx/compare/v1.3.5...v1.4.0)

---
updated-dependencies:
- dependency-name: github.com/jmoiron/sqlx
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-23 18:10:08 +00:00
alvar
a0a65af026
Merge pull request #734 from Icinga/i707-release-v1.1.2
Release Version 1.2.0
2024-04-11 12:09:26 +00:00
Julian Brost
c76788a047
Merge pull request #738 from Icinga/unify-time-duration-notation
Unify notation of `n * time.Duration`
2024-04-11 14:04:12 +02:00
Eric Lippmann
7280916371
Merge pull request #736 from Icinga/redis-trademark
Account Redis' trademark policy
2024-04-11 13:40:38 +02:00
Alvar Penning
f0b7aa2d38
Bump version to 1.2.0 2024-04-11 13:23:34 +02:00
Eric Lippmann
5029e328c8 Unify notation of n * time.Duration 2024-04-11 13:01:31 +02:00
Alvar Penning
ea31ddd788
Update AUTHORS and .mailmap 2024-04-11 12:15:08 +02:00
Julian Brost
889a153738
Merge pull request #740 from Icinga/retry-schema-check
icingadb.DB: Retry Schema Checks
2024-04-11 11:58:29 +02:00
Julian Brost
109372f2e9
Merge pull request #741 from Icinga/icingadb-driver-shouldretry
icingadb: Remove shouldRetry
2024-04-11 11:58:12 +02:00
Alvar Penning
fab2765733
icingadb.DB: Retry Schema Checks
During testing, I just encountered a race condition where my Galera
cluster was not yet ready, causing the initial schema check to fail.

```
2024-04-11T08:13:40.401Z        INFO    icingadb        Starting Icinga DB daemon (1.1.1)
2024-04-11T08:13:40.401Z        INFO    icingadb        Connecting to database at 'mysql:3306'
2024-04-11T08:13:40.404Z        FATAL   icingadb        Error 1047 (08S01): WSREP has not yet prepared node for application use
can't check database schema version
github.com/icinga/icingadb/pkg/icingadb.(*DB).CheckSchema
        /go/src/github.com/Icinga/icingadb/pkg/icingadb/db.go:115
main.run
        /go/src/github.com/Icinga/icingadb/cmd/icingadb/main.go:74
main.main
        /go/src/github.com/Icinga/icingadb/cmd/icingadb/main.go:37
runtime.main
        /usr/local/go/src/runtime/proc.go:271
runtime.goexit
        /usr/local/go/src/runtime/asm_amd64.s:1695
exit status 1
```

This change now also retries the initial cluster check.

References #698.
2024-04-11 11:14:15 +02:00
Alvar Penning
360e7b7071
icingadb: Remove shouldRetry
The additional check against a driver.ErrBadConn is now also part of
retry.Retryable. Thus, it can be dropped.
2024-04-11 11:05:06 +02:00
Julian Brost
974d32412f
Merge pull request #735 from Icinga/go-mod-version-1.22
Increment go.mod Go version to 1.22
2024-04-11 10:54:15 +02:00
Julian Brost
919871f024
Merge pull request #739 from Icinga/retry-io-eof-error
Retry `io.EOF` error
2024-04-11 10:52:43 +02:00
Yonas Habteab
1b380bb76e Retry io.EOF error 2024-04-11 10:09:24 +02:00
Eric Lippmann
25f39383b1 Docs: Account Redis' trademark policy
See https://redis.io/legal/trademark-policy/
2024-04-11 10:07:51 +02:00
Julian Brost
6ff3ca557b
Merge pull request #698 from Icinga/retry-every-database-error
Retry **every** database error
2024-04-11 10:01:42 +02:00
Alvar Penning
f09ecfc222
Increment go.mod Go version to 1.22
With the approaching release, the go version within go.mod can be
incremented to a current Go version.

There were some small changes regarding the go.mod's go semantic since
Go version 1.21, mainly enforcing compilation with a compatible
version[0]. As other modules' go.mod files are now also being included,
there are additional entries in go.sum.

[0]: https://go.dev/doc/modules/gomod-ref#go
2024-04-10 16:02:51 +02:00
Eric Lippmann
3a3baafc86 retry: Mitigate timing issues
`WithBackoff()` will now make one final retry if the timeout expires
during the sleep phase between attempts, which can be a long period
depending on the attempts made and the maximum sleep time.
2024-04-10 15:25:15 +02:00
Eric Lippmann
2b3a5d4229 retry: Set attempt's initial value to 1
This change simplifies the use of `attempt` as a number for reading in
log messages and `if`s. Also before, with `attempt` starting with `0`,
the second attempt would have been taken immediately, as our backoff
implementation returns `0` in this case.

Co-Authored-By: Alvar Penning <alvar.penning@icinga.com>
2024-04-10 15:25:15 +02:00
Eric Lippmann
c2b449d3a6 HA: Don't log retry count
Logging of the `attempt` is a meaningless metric as it is not constantly
logged but only when the retryable error changes, and it has no context
as there is no such thing as max attempts.
2024-04-10 15:25:15 +02:00
Eric Lippmann
51a6ef25b8 retry: Explicitly check context for error
The retryable function may exit prematurely due to context errors that
shouldn't be retried. Before, we checked the returned error for context
errors, i.e. used `errors.Is()` to compare it to `Canceled` and
`DeadlineExceeded` which also yields `true` for errors that implement
`Is()` accordingly. For example, this applies to some non-exported Go
`net` errors. Now we explicitly check the context error instead.
2024-04-10 15:25:15 +02:00
Eric Lippmann
357bcdbb73 retry: Execute on error callbacks for retryable errors only
All of our error callbacks are used to log the error and indicate that
we are retrying. Previously, in the case of context errors or
non-retryable errors, we would have called these too, which would have
resulted in misleading log messages.
2024-04-10 15:25:15 +02:00
Eric Lippmann
3a664c1696 Consolidate default retry timeout and settings 2024-04-10 15:25:14 +02:00
Eric Lippmann
81085c04a4 HA: Give up retrying after 5 minutes
Since we are now retrying every database error,
we also need to set a retry timeout.
2024-04-10 15:24:00 +02:00