IntersectMBO / cardano-node

The core component that is used to participate in a Cardano decentralised blockchain.
https://cardano.org
Apache License 2.0
3.05k stars 721 forks source link

[BUG] - cardano-tracer systemd dependency #5021

Closed jpy-luke closed 2 weeks ago

jpy-luke commented 1 year ago

Internal/External External

Area Other build dependencies

Summary cardano-tracer module assumes that Host OS Linux implicates the availability systemd-journal. Its cabal file does not obey the build configuration flag systemd like the cardano-node module's does. This results in dependency resolution failure on non-systemd build hosts. In addition this is present as a preprocessor macro switch in the module's Journal.hs source, failing the build even when the build configuration has been rectified to obey the systemd flag. Removing the relevant ifdef branches from the relevant source file the project build successfully and it works runtime with logMode FileMode.

Steps to reproduce Steps to reproduce the behavior:

  1. Use a non-systemd build host
  2. Follow https://github.com/input-output-hk/cardano-node/blob/master/doc/getting-started/install.md/
  3. cabal build all

Expected behavior When the flags: -systemd is present in build configuration, cabal build all should not fail dependency resolution or trigger attempting to build code paths using Systemd.Journal package. Alternatively systemd is declared as a hard dependency of the project and documented in project build instructions.

System info (please complete the following information):

Screenshots and attachments

cardano-tracer/cardano-tracer.cabal dependency:

  if os(linux)
    build-depends:     libsystemd-journal

Error with aforementioned

[__2] trying: cardano-tracer-1.35.6 (user goal)
[__3] next goal: libsystemd-journal (dependency of cardano-tracer)
[__3] rejecting: libsystemd-journal-1.4.5 (conflict: pkg-config package
libsystemd>=209, not found in the pkg-config database)

cardano-tracer/src/Cardano/Tracer/Handlers/Logs/Journal.hs problem source (truncated):

#ifdef LINUX
import           Systemd.Journal

Results naturally in

src/Cardano/Tracer/Handlers/Logs/Journal.hs:22:1: error:
    Could not find module ‘Systemd.Journal’

Additional context There seems to be previous work attempting to mitigate this problem in https://github.com/input-output-hk/cardano-node/blob/master/scripts/gen-cabal-nosystemd.sh and related PR https://github.com/input-output-hk/cardano-node/pull/1775 but this predates cardano-tracer and appears to not have followed the changes.

If trying to force systemd dependency is not a project goal, I can make a PR for evaluation for addressing this. Otherwise it should be documented as a requirement.

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 120 days.

mgmeier commented 2 weeks ago

Fixed by PR #5937.

The systemd dependency is now made optional, and put behind a feature flag (enabled by default on Linux).

flag systemd
  description: Enable systemd support.
  default:     True
  manual:      True

For Linux systems that do not support systemd, disable by configuring cabal with -f -systemd.

This means, cardano-tracer builds can now be configured exactly the same as cardano-node builds wrt. systemd.