Vladimír Čunát [Wed, 28 Jul 2021 19:00:07 +0000 (21:00 +0200)]
lib/log.h: improve readability (hopefully)
* improve order
- follow grouping of topics more closely (targets, groups, levels)
- order kr_log_LEVEL by severity
* move unneeded <stdarg.h>
* improve doc-comments
- some claims there were even wrong now
- describe some log levels at kr_log_LEVEL
Vladimír Čunát [Wed, 28 Jul 2021 17:29:51 +0000 (19:29 +0200)]
lib/log level names: disregard SYSLOG_NAMES
It's a non-standard feature of syslog.h and I don't think it's worth
the trouble.
We didn't really utilize it; someone would have to #define it,
and moreover we would get into problems if this wasn't being done
the same on all places including log.h.
Making the names adapt to the platform would also mean that
config files and docs wouldn't be portable.
Vladimír Čunát [Wed, 28 Jul 2021 16:26:59 +0000 (18:26 +0200)]
lib/log.h nit: tweak macro for __LINE__
- we don't need doubling the layer in this case,
as the SD_JOURNAL_METADATA macro adds a layer already
- `TO_STR` was perhaps a too short name and could collide
Vladimír Čunát [Tue, 13 Jul 2021 11:05:40 +0000 (13:05 +0200)]
treewide: replace VERBOSE_STATUS, WITH_VERBOSE, etc.
The main problem there was ignoring the log groups,
and VERBOSE_STATUS also ignores trace-logging.
Typically the new kr_log_is_debug*() are the best choice.
In a couple places with heavy WITH_VERBOSE usage it's
instead locally redefined to consider the right group.
Vladimír Čunát [Tue, 13 Jul 2021 10:06:28 +0000 (12:06 +0200)]
validate: add kr_rrset_validation_ctx_t::log_qry
... so we can use it for more precise logging. Some calls get simpler.
In particular, without the associated request, we can't produce anything
into trace-logs, which could be confusing. Normal logs will benefit, too.
(more precise replacement of WITH_VERBOSE will come in a subsequent commit)
Vladimír Čunát [Mon, 12 Jul 2021 18:02:12 +0000 (20:02 +0200)]
rework logging from control sockets (+simplify)
- unify interactive mode to stdout
- use its own logging group
- elevated log level when the command throws an exception
- don't try detecting that the logs go back into the same console
(yes, in that case you can see some lines twice)
- don't make the binary mode turn off logging
Vladimír Čunát [Mon, 12 Jul 2021 20:00:15 +0000 (22:00 +0200)]
QRVERBOSE: fix ignoring the log groups
It would be yet another condition to check; overall I think the
necessary checks would get too complex to be done in a macro
and therefore copied all over the place.
Note: it's interesting that such a change reduces binary size
by about 3% (on master), and I suspect that speed won't suffer at all
(after that TODO is done).
Vladimír Čunát [Mon, 12 Jul 2021 09:27:17 +0000 (11:27 +0200)]
lib/log: typing improvements
- const for names of log groups
- enum kr_log_group for a single log group
- the kr_log_groups bitmap doesn't need to be exposed or even exported
- return bool instead of int
Tomas Krizek [Thu, 8 Jul 2021 15:07:10 +0000 (17:07 +0200)]
logging: use LOG_GRP_HTTP for http lua module
It's better to use separate log group, to separate between logs that
come from the lua module vs native C implementation. It is also more
descriptive, since http modules is used for other stuff besides its
deprecated DoH.
Tomas Krizek [Thu, 8 Jul 2021 11:28:11 +0000 (13:28 +0200)]
logging: add LOG_GRP_DEVEL
This serves two purposes:
1. As a utility logger during development.
2. As the last entry in enum - to make iteration over the values
possible. Changing the value of LOG_GRP_DEVEL shouldn't be an issue,
since it shouldn't be used in production code.
Tomas Krizek [Wed, 7 Jul 2021 15:15:08 +0000 (17:15 +0200)]
logging: add get_log_group() with better API
The function returns a table where key is the group name and the value
is either true (when logging selected group), or nil (when group isn't
selected).
This replaces the list_log_group() which didn't really work.
Vladimír Čunát [Thu, 15 Jul 2021 10:06:35 +0000 (12:06 +0200)]
daemon/lua/kres-gen.lua: make it self-contained
Now those type definitions can be simply loaded without any error, e.g.
luajit daemon/lua/kres-gen.lua
That will be useful for checking them without regenerating them.
Vladimír Čunát [Mon, 21 Jun 2021 14:44:33 +0000 (16:44 +0200)]
distro/pkg/nix: add
- Support is in apkg master now.
- The generated default.nix is exactly as in the distro:
https://github.com/NixOS/nixpkgs/blob/master/pkgs/servers/dns/knot-resolver/default.nix
(except for new version+hash, and one test needed a tweak since 5.3.2)
Tomas Krizek [Mon, 21 Jun 2021 14:45:09 +0000 (16:45 +0200)]
ci: attempt to make CI more robust by reducing paralelism
Some tests (typically those using network) ocassionally fail due to
timeouts, which is probably due to increased CI load - perhaps reducing
it could make the tests more stable.
Vladimír Čunát [Mon, 17 May 2021 14:48:30 +0000 (16:48 +0200)]
policy.FLAGS: fix not applying properly in edge cases
Perhaps this bug was now more pronounced since 5.3.0 changes.
Example problem was disabling minimization or 0x20 (globally or
for some problematic requests); without this change they would get
re-enabled during some fallback actions... which might be exactly
the wrong moment wrt. the motivation to setting these.
https://gitter.im/CZ-NIC/knot-resolver?at=60a221e86a950f3d46ed1cd9
Vladimír Čunát [Fri, 21 May 2021 15:29:25 +0000 (17:29 +0200)]
lib/selection: be more careful with RO transactions
They probably couldn't hang open for long, as each client request
should cause some cache-searching and thus close it, and even with
queries stopping I haven't managed to find a case where it would be
left open but... it's nicer to clean up and it should be very cheap.
Vladimír Čunát [Tue, 1 Jun 2021 14:26:04 +0000 (16:26 +0200)]
daemon/worker: fix a memory leak
Discovered case: TCP write towards upstream fails due to ECONNRESET,
and on this place of code we "forget" the whole qr_task and thus its
corresponding kr_request, so it remains unanswered and using memory.