Skip to content

fix(apache.service.running): prevent recursive requisite #391

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

dehnert
Copy link

@dehnert dehnert commented Jul 13, 2025

PR progress checklist (to be filled in by reviewers)

  • Changes to documentation are appropriate (or tick if not required)
  • Changes to tests are appropriate (or tick if not required)
  • Reviews completed

What type of PR is this?

Primary type

  • [build] Changes related to the build system
  • [chore] Changes to the build process or auxiliary tools and libraries such as documentation generation
  • [ci] Changes to the continuous integration configuration
  • [feat] A new feature
  • [fix] A bug fix
  • [perf] A code change that improves performance
  • [refactor] A code change that neither fixes a bug nor adds a feature
  • [revert] A change used to revert a previous commit
  • [style] Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc.)

Secondary type

  • [docs] Documentation changes
  • [test] Adding missing or correcting existing tests

Does this PR introduce a BREAKING CHANGE?

No.

Related issues and/or pull requests

This fixes the same issue as #388, but slightly more completely.

Describe the changes you're proposing

The fixes circular requisite errors when using the formula. Most of the change isn't mine (see the commit authors), but I added some tweaks, hence the new PR.

In terms of how the change works, mostly copying from my comment on #388

  • The changes to apache/config/file.sls are all just s/require_in/watch_in/`. AIUI the watch requisite implies the require requisite, so these are required either way, this just means that we restart Apache if they change.
    • Almost all the changes to file.sls are in file.directory states. I think if Apache previously crashed, service.running would rerun anyway, and it's unlikely that Apache would run but incorrectly without these directories, so I don't see why watch_in is needed. OTOH, it's probably harmless.
    • The other one is in OS-dependent config files (the diff looks like deleted lines, because the require_in is getting combined with the watch_in). This seems like an improvement, though it's hard to see how it would improve a circular dep.
    • (My additional change is to add a watch_in for the main config file. This seems like it would be pretty important to getting appropriate config-reloading behavior.)
  • The removed requisites (which are presumably how you break a loop) are in apache/service/running.sls.
    • The three apache-service-running* states lose their watch (and usually require, which AIUI is redundant) on sls: {{ sls_config_file }}, which AFAICT is just the whole apache.config.file from earlier in the PR. Effectively, in combination with the earlier changes, I think this is replacing a broad dependency from the running states on the whole config file sls (in running.sls) with narrow dependencies from the running states to each of the config file states (in file.sls). My guess is that require: sls: whatever requires everything in that SLS, including the includes, and we include {{ sls_service_running}}, which would make a loop.
    • -reload and -running lose their watch/require entirely (there's no consistent watch_in for them), but they're after the service: apache-service-running. I can't find a definition of after, but my guess is this functionally means we need apache-service-running's prereqs, which is good enough. (Also these shouldn't run all that much.)
  • (I make a similar change in apache/config/modules/install.sls to use a finer-grained requisite there (based on danny-smit's patch)

I also reduce the amount of logging dumped to salt when Apache restarts -- the old parameters could really clutter the output, which was very apparent when circular deps meant it kept failing to restart.

Pillar / config required to test the proposed changes

Debug log showing how the proposed changes work

Documentation checklist

  • Updated the README (e.g. Available states).
  • Updated pillar.example.

Testing checklist

  • Included in Kitchen (i.e. under state_top).
  • Covered by new/existing tests (e.g. InSpec, Serverspec, etc.).
  • Updated the relevant test pillar.

Additional context

alxwr and others added 3 commits March 21, 2024 22:48
If Apache fails to start, on a non-systemd system, we dump 20 lines of logs,
which seems like enough to give a good hint of what went wrong.

When available, however, we instead use `journalctl -xe`. `journalctl -x`
annotates each log message, resulting in a large amount of context for each
line. `journalctl -e` implicitly allows a cap of 1000 lines of *log* to be
printed, which is further multiplied by the annotations. IME the annotations
aren't actually useful for Apache restarts (*Apache's* output doesn't have any,
so it's just a lot of explanation of what systemd is doing).

Rather than cluttering up Salt's output, this change makes `journalctl`
consistent with non-systemd log dumping: 20 lines max, with no context. An
admin can easily run `journalctl -xe` themselves if they actually need the
annotations or more lines.
This is a follow-on to PR saltstack-formulas#388:
- When the main Apache config file changes, reload Apache
- Installing modules only needs the module dir to exist, it doesn't need the
  entire config. Tightening up this requisite avoids potential circular
  dependencies.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants