Log processors: in-process hub update

Open
#4,773 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 4 days

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
go
Domain
backend, security

Research direction

Start by reading the existing cron/systemd hub update flow and the configuration and reload paths. The issue identifies exprhelpers globals, appsec configuration parsing, atomic reload, and the update mechanism as separate work areas, but does not name files or tests. Done means updates run in process, validate before swapping configuration, and publish the two specified metrics.

Written by the indexing model from the issue text.

Description

kind/enhancement needs/triage

Automated hub updates are currently handled by a cron/systemd timer that invokes cscli hub update / cscli hub upgrade then reloads crowdsec.

This works fine for deployment in VMs/bare metal, but cannot work for container/k8s/deployment (and windows currently has no support at all for hub auto updates).

We should replace the cron with an-in process update that has no external dependancies.

A new config key would be introduced:

crowdsec_service:
 hub_auto_update:
  enabled: true
  interval: 24h

This would default to enabled (the cron would be removed in the 1st release shipping this).

When crowdsec performs an update, the new configuration would be tested then swapped with the current one (the current cron cannot handle a rollback during a config upgrade, so we will also address this).

Because this require some important internal changes, we should split the work:

  • Stop relying on package level globals for exprhelpers (datafiles, geoip, ...) so that they can be swapped at runtime
  • Decouple appsec configuration parsing from the datasource itself to allow for testing before loading the configuration (this would have the side effect of being able to test them with crowdsec -t)
  • Implement the atomic configuration swap on reload (probably LP only at first ?): this would make crowdsec behaves more like nginx during a reload (a reload can fail, but the current version stays up), where currently we simply refuse the new config and exit.
  • Implement the actual update mechanism

A successfull auto-update would kill all existing buckets (like the current reload does)

New metrics would be published:

  • cs_autoupdate_last_timestamp: timestamp of the last successful autoupdate
  • cs_autoupdate_total: counter that tracks how many autoupdates with changes were performed
Dominant language
Go
Stars
15.1k
Forks
726
Avg merge
4d 23h
Merged PRs (30d)
27

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from crowdsecurity/crowdsec

All issues in crowdsecurity/crowdsec

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.