Commit graph

129 commits

Author SHA1 Message Date
Evilham adbdd5d968 Merge pull request 'Actually add vendor files' (#17) from no-cdn into main
All checks were successful
ci/woodpecker/manual/linters Pipeline was successful
Reviewed-on: #17
2024-02-23 13:07:54 +01:00
Evilham 0fbc0f678a
Version bump 24.2.1 2024-02-23 13:10:58 +01:00
Evilham 87e0769f8c
Add vendored files >,< 2024-02-23 13:09:18 +01:00
Evilham cb95b510e4
Bump version for release 2024-02-23 13:04:57 +01:00
Evilham 39a9460bbb Merge pull request 'Add vendored files to avoid thirdparty requests' (#16) from no-cdn into main
Reviewed-on: #16
2024-02-23 13:03:11 +01:00
Evilham cefeb2b77d
Add vendored files to avoid thirdparty requests
While there, upgrade template to Bootstrap v5.3

Closes #3
2024-02-23 12:59:10 +01:00
Evilham c380cae50b
Version bump 23.12.0rc3 2023-12-11 20:04:20 +01:00
Evilham 9b45194dce
Adapt mypy checks so they catch issues like that in past commit
All checks were successful
ci/woodpecker/push/linters Pipeline was successful
2023-12-11 20:00:59 +01:00
Evilham af90f06046
Fix issues introduced in __main__ 2023-12-11 20:00:37 +01:00
Evilham 56fdef377d
Release management: add release management bits
All checks were successful
ci/woodpecker/push/linters Pipeline was successful
We based this on Twisted's own settings, which use hatchling as a
build system.

With these changes, the project is now published as RC on pypi, mostly
to secure the module name.

It has not been tested yet, but we should be able to install using pip
and run the project as a mdoule.
2023-12-11 19:51:06 +01:00
Evilham 23134fa2d6
Config: add new settings replacing hard-coded values
All checks were successful
ci/woodpecker/push/linters Pipeline was successful
This mostly relates to timeouts.

We are using minutes because it is human-friendly, but some could
benefit in certain cases from using seconds.

We are open to changing this in the future.
2023-12-11 19:09:07 +01:00
Evilham 45ed9bbed7
Rework logging and execution
It is now possible to run adlermanager with:
python -m adlermanager

While there we improve logging.
2023-12-11 18:41:59 +01:00
Evilham 1a44337ded
Relocate motd for future module publishing
While there, allow for a simple way of customising the MOTD by placing
a motd.txt in DATA_DIR.
2023-12-11 14:30:21 +01:00
Evilham 4b8f336371
Minor data loading and structure rework for easier reloading
We will want to issue configuration reloads with USR1 signals soon
enough, in order to achieve this we need to be able to reload each
object without losing state.

In this commit, we add reload methods to most objects, so we can
easily propagate the reload order.
2023-12-11 14:28:57 +01:00
Evilham e0415f50d9
SSH list_sites: show current site configuration
This can be useful for managers that are just quickly checking things.
2023-12-11 13:50:00 +01:00
Evilham 491e13fd09
black: fix formatting from previous change
All checks were successful
ci/woodpecker/push/linters Pipeline was successful
2023-12-10 20:14:00 +01:00
Evilham 513dbff6e9
Add unicode support to our RecvLine subclass
Some checks failed
ci/woodpecker/push/linters Pipeline failed
We should look into upstreaming these fixes to twisted.

Twisted's RecvLine currently discards anything other than ascii
printable characters, which happens to include things like: àéñü or
l·l, which we use extensively.

Since RecvLine processes each 'keystroke' on its own, it only has
access to one byte at a time, which means we get to have "fun"
implementing our own simple Unicode-state parsing.

Python's documentation happened to be quite useful as a reminder:
https://docs.python.org/3/library/codecs.html#encodings-and-unicode

Closes #4
2023-12-10 18:58:13 +01:00
Evilham ad08662114
Avoid strange bytes on SSH login, improve non-interactive detection
Some checks failed
ci/woodpecker/push/linters Pipeline failed
The strange bytes came from `setMode` in:
7697871b4d/src/twisted/conch/insults/insults.py (L726-L729)

```
    def setModes(self, modes):
        # XXX Support ANSI-Compatible private modes
        modesBytes = b";".join(b"%d" % (mode,) for mode in modes)
        self.write(b"\x1b[" + modesBytes + b"h")
```

Instead of calling this method, we now set the mode attribute of the
protocol directly and early.

Having a better detection of interactive mode simplifies our code and
makes it more reliable too.
2023-12-10 16:53:17 +01:00
Evilham 7137569a3c
UX: print Config when starting
All checks were successful
ci/woodpecker/push/linters Pipeline was successful
This might help people spot unexpected settings or awkward values.
2023-12-09 00:45:36 +01:00
Evilham d1a287bdfb
README: fix minor typo 2023-12-09 00:45:06 +01:00
Evilham 7ca180c13e
Fix typo introduced in !5 and add more env vars
All checks were successful
ci/woodpecker/push/linters Pipeline was successful
Currently we are only documenting Pipenv for deployment, so we might
as well add PYTHONPATH and MYPYPATH as they would be expected.

Closes #13
2023-12-09 00:16:41 +01:00
Evilham 7ba5cc1ce8 Merge pull request 'README.md: add dev env instructions' (#5) from dev-env-update into main
All checks were successful
ci/woodpecker/push/linters Pipeline was successful
Reviewed-on: #5
2023-12-08 00:39:03 +01:00
Evilham b8c81cdb61
Documentation: add dotenv.example and better instructions
All checks were successful
ci/woodpecker/pr/linters Pipeline was successful
ci/woodpecker/push/linters Pipeline was successful
Improvement upon basework at !5, closes #8
2023-12-08 00:37:36 +01:00
pedro 8500bca052
README.md: add dev env instructions 2023-12-07 22:10:19 +01:00
Evilham 3f6b5d95f5 Merge pull request 'ssh: bugfix to avoid terminal clear when login' (#7) from bugfix-terminal-reset into main
All checks were successful
ci/woodpecker/push/linters Pipeline was successful
Reviewed-on: #7
2023-12-07 22:03:56 +01:00
Evilham d5e26bceef
linters: Fix minor issues detected on CI for MR
All checks were successful
ci/woodpecker/push/linters Pipeline was successful
ci/woodpecker/pr/linters Pipeline was successful
Related to MR !7, which closes #6
2023-12-07 22:00:42 +01:00
pedro 3eed68d173
ssh: bugfix to avoid terminal clear when login 2023-12-07 21:51:25 +01:00
pedro b99e5740a3 ssh: bugfix to avoid terminal clear when login
Some checks failed
ci/woodpecker/push/linters Pipeline failed
ci/woodpecker/pr/linters Pipeline failed
2023-12-07 05:04:10 +01:00
Evilham 0277eb304d
Support custom site configuration commands.
All checks were successful
ci/woodpecker/push/linters Pipeline was successful
This enables us to force a particular message on top.

Currently this functionality is mostly PoC, we should explore what
works best in reality.
2023-12-06 20:49:05 +01:00
Evilham bc88afaca2
SSH: add list_sites command
All checks were successful
ci/woodpecker/push/linters Pipeline was successful
It returns basic site info, including its current state
2023-12-06 17:08:31 +01:00
Evilham df0a647dc2
linting: fix errors found on CI
All checks were successful
ci/woodpecker/push/linters Pipeline was successful
2023-12-06 17:00:16 +01:00
Evilham 4155e0aa97
CI: fix path in environment variables >,<
Some checks failed
ci/woodpecker/push/linters Pipeline failed
2023-12-06 16:39:00 +01:00
Evilham 3e17240a71
dev dependencies: add black :-D it was only implicit
Some checks failed
ci/woodpecker/push/linters Pipeline failed
Caught on CI, as the pipeline failed without finding the command.
2023-12-06 16:30:24 +01:00
Evilham e3d9395f55
CI: add basic linter workflows
Some checks failed
ci/woodpecker/push/linters Pipeline failed
2023-12-06 16:24:08 +01:00
Evilham e5cfceda3a
Typing: add stubs, hints and tooling settings 2023-12-06 14:37:23 +01:00
Evilham ba98f0c389
Support non-interactive commands from SSH
Previously any command "ssh user@host CMD" would hang due to us not
handling the execCommand method.

While implementing that, we reliased that exit codes were not being
propagated and that overall handling of non-interactive sessions was
subpar.

This commit tries to address that and closes #2
2023-12-06 13:24:00 +01:00
Evilham 4cf3856c32
Implement some SSH logic and rework helpers for better typing
This will enable us to further improve the SSH access for custom
messages and status updates.
2023-12-05 17:04:28 +01:00
Evilham 8dc7ba035b
Move code to 'src' subfolder as it is now usual. 2023-12-05 15:52:45 +01:00
Evilham 3df3617c93
typing: fix last issue in currently used code 2023-11-30 01:21:18 +01:00
Evilham 72a7e7323d
Change source code link for new home 2023-11-30 01:10:05 +01:00
Evilham c1f7b12366
Partial rewrite with sane typing (modern python!)
While there, we get rid of annoying:
Failure: twisted.internet.defer.CancelledError

Whenever we would cancel a deferred (which we use a lot in this app)
2023-11-30 01:05:06 +01:00
Evilham d8071eabb7
Mock: fix mock script for newer requirements
This includes the new "adlermanager: domain" constraint.
2023-11-29 22:11:12 +01:00
Evilham 261857ebee
Cleanup: remove unnecessary code and dependencies
While there also fix development dependencies.
2023-11-29 22:08:41 +01:00
Evilham b0d00fdf95
Unconfuse labels, amongst tons of bugfixes!
It seems like we never deployed this long in production :-), so there
were some confusing things left to fix (this was originally written in
a weekend):

- Some constants were repeated throughout the code
- Naming was inconsistent, which meant that setting up the status page
  was not an entirely easy feat, now the sample file can actually be
  followed
- Due to naming being inconsistent, alert names were given an
  importance that they should have never had
- Given that multiple alerts with different severity levels can be
  triggered on Prometheus' side (e.g. warning probably always trigger
  when critical triggers), we could have seen ourselves in the
  position of receiving them in an undefined order, and switching from
  "critical" to "warning" in a very flaky fashion.
- Similarly, when an alert had been *resolved*, this was not timely
  reflected on AdlerManager, instead it waited until prometheus
  stopped sending the alert, then for AdlerManager's timeout to occur
- We now filter received alerts by using an 'adlermanager' label,
  whose value should match the domain on which the status page is
  being served. This is due to a misinterpretation of Prometheus'
  configuration for alertmanagers called 'relabel_configs'.
  We expected it to apply to alerts sent to alertmanager, instead, it
  seems to be a functionality to modify alertmanager's settings
  themselves.
  Since alert_relabel_configs applies globally, it also is not a good
  fit to selectively drop certain alerts.
  This does mean that, even if not published, AdlerManager potentially
  receives all alerts produced by the Prometheus instance.
  https://prometheus.io/docs/prometheus/latest/configuration/configuration/#alert_relabel_configs
- For the heartbeat alert, instead of relying on the funnily named
  EverythingIsFine (insert meme here) alert, we now rely on a label
  called 'heartbeat' being set.
- The text shown when there are alerts now uses annotations.summary
  when available.
2023-11-29 21:12:23 +01:00
Evilham 748d55c432
black: apply black in all project for consistency 2023-11-29 21:08:38 +01:00
Evilham 9d0b91c191
Make SSH optional (and disabled by default) 2023-10-19 21:18:10 +02:00
Evilham 4f2133183f
Update dependencies 2023-10-19 21:15:51 +02:00
Evilham 2556982526 Backport various fixes. 2019-11-05 10:28:18 +01:00
Evilham 7a013ee0cd Backport prometheus-mock 2019-11-05 10:25:20 +01:00
Evilham 935c133aee Merge branch 'master' of github.com:evilham/prometheus-adlermanager 2019-11-05 10:20:59 +01:00