Skip to content

Conversation

sabban
Copy link
Contributor

@sabban sabban commented Jul 20, 2025

Refactored the Queue type to introduce a new Queue interface with a LocalQueue implementation and updated all references to use the new interface.

The old types.Queue is kept alive to be used in expr expressions, but only there.

For now, this PR definitely breaks the ability to load buckets from bucket state files, but I believe it wasn't in a workable state anyway. If it's worth it, I can write a Marshaller and Unmarshaller for the Leaky types to make the feature work again, if not I can clean all the state-related code. In the meantime, I even deactivated the state loading tests.

Once this PR is accepted and merged, it's possible to add a new backend for Queues.

Refactored the ~Queue~ type to introduce a new ~LocalQueue~ implementation and updated all references to use the new interface. This change ensures better type safety and flexibility in queue operations.

BREAKING CHANGE: The ~Queue~ type has been replaced with a new ~LocalQueue~ implementation, and a ~Queue~ interface has been introduced. This may require updates to any code directly interacting with the ~Queue~ type.
Copy link

@sabban: There are no 'kind' label on this PR. You need a 'kind' label to generate the release automatically.

  • /kind feature
  • /kind enhancement
  • /kind refactoring
  • /kind fix
  • /kind chore
  • /kind dependencies
Details

I am a bot created to help the crowdsecurity developers manage community feedback and contributions. You can check out my manifest file to understand my behavior and what I can do. If you want to use this for your project, you can check out the BirthdayResearch/oss-governance-bot repository.

Copy link

@sabban: There are no area labels on this PR. You can add as many areas as you see fit.

  • /area agent
  • /area local-api
  • /area cscli
  • /area appsec
  • /area security
  • /area configuration
Details

I am a bot created to help the crowdsecurity developers manage community feedback and contributions. You can check out my manifest file to understand my behavior and what I can do. If you want to use this for your project, you can check out the BirthdayResearch/oss-governance-bot repository.

@sabban
Copy link
Contributor Author

sabban commented Jul 20, 2025

/kind enhancement
/area agent

Copy link

codecov bot commented Jul 20, 2025

Codecov Report

❌ Patch coverage is 62.73546% with 910 lines in your changes missing coverage. Please review.
✅ Project coverage is 61.60%. Comparing base (cf98131) to head (43e383f).
⚠️ Report is 37 commits behind head on master.

Files with missing lines Patch % Lines
cmd/crowdsec-cli/climachine/inspect.go 18.05% 168 Missing and 9 partials ⚠️
pkg/acquisition/modules/docker/docker.go 59.64% 94 Missing and 19 partials ⚠️
cmd/crowdsec-cli/clisetup/wizard.go 48.48% 89 Missing and 13 partials ⚠️
cmd/crowdsec-cli/clisetup/acquisition.go 48.27% 67 Missing and 8 partials ⚠️
pkg/hubtest/hubtest_item.go 0.00% 34 Missing ⚠️
cmd/crowdsec/lpmetrics.go 82.24% 21 Missing and 9 partials ⚠️
...crowdsec-cli/clisetup/setup/exprwindows_windows.go 19.35% 24 Missing and 1 partial ⚠️
cmd/crowdsec-cli/clisetup/hub.go 72.41% 16 Missing and 8 partials ⚠️
cmd/crowdsec-cli/climetrics/store.go 5.00% 19 Missing ⚠️
cmd/crowdsec-cli/clisetup/setup/acquisition.go 73.13% 12 Missing and 6 partials ⚠️
... and 53 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3738      +/-   ##
==========================================
+ Coverage   60.68%   61.60%   +0.91%     
==========================================
  Files         375      405      +30     
  Lines       41345    41578     +233     
==========================================
+ Hits        25091    25613     +522     
+ Misses      14179    13855     -324     
- Partials     2075     2110      +35     
Flag Coverage Δ
bats 45.52% <48.62%> (+0.72%) ⬆️
unit-linux 34.50% <29.60%> (+0.19%) ⬆️
unit-windows 24.34% <25.68%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@blotus blotus marked this pull request as draft July 22, 2025 08:49
@sabban sabban marked this pull request as ready for review July 25, 2025 19:59
@sabban sabban changed the title leakybucket: refactor queue handling to improve queue handling leakybucket: refactor queue handling to use an interface Jul 25, 2025
blotus and others added 13 commits July 28, 2025 10:16
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.29.2 to 3.29.4.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](github/codeql-action@181d5ee...4e828ff)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 3.29.4
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* enhance: Add averagetime function which allows to compute averagetime span

* enhance: lint

* enhance: Add median function and act on @mmetc feedback

* enhance: NIT on tests

* enhance: switch to []time.Time instead and handle using expr map which returns interfaces

* enhance: Add a bunch of test cases

* enhance: Rename *duration to *interval
---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-version: 1.74.2
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
)

Bumps [github.com/r3labs/diff/v2](https://github.com/r3labs/diff) from 2.14.1 to 2.15.1.
- [Commits](r3labs/diff@v2.14.1...v2.15.1)

---
updated-dependencies:
- dependency-name: github.com/r3labs/diff/v2
  dependency-version: 2.15.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* refactor without label
* fix the deadlock
#3760)

Bumps [github.com/alexliesenfeld/health](https://github.com/alexliesenfeld/health) from 0.8.0 to 0.8.1.
- [Release notes](https://github.com/alexliesenfeld/health/releases)
- [Changelog](https://github.com/alexliesenfeld/health/blob/main/CHANGELOG.md)
- [Commits](alexliesenfeld/health@v0.8.0...v0.8.1)

---
updated-dependencies:
- dependency-name: github.com/alexliesenfeld/health
  dependency-version: 0.8.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
dependabot bot and others added 30 commits July 31, 2025 11:37
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.29.4 to 3.29.5.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](github/codeql-action@4e828ff...51f7732)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 3.29.5
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…#3764)

Bumps [github.com/hashicorp/go-version](https://github.com/hashicorp/go-version) from 1.2.1 to 1.7.0.
- [Release notes](https://github.com/hashicorp/go-version/releases)
- [Changelog](https://github.com/hashicorp/go-version/blob/main/CHANGELOG.md)
- [Commits](hashicorp/go-version@v1.2.1...v1.7.0)

---
updated-dependencies:
- dependency-name: github.com/hashicorp/go-version
  dependency-version: 1.7.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…3763)

Bumps [github.com/go-openapi/swag](https://github.com/go-openapi/swag) from 0.23.0 to 0.23.1.
- [Commits](go-openapi/swag@v0.23.0...v0.23.1)

---
updated-dependencies:
- dependency-name: github.com/go-openapi/swag
  dependency-version: 0.23.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…3761)

Bumps [github.com/go-sql-driver/mysql](https://github.com/go-sql-driver/mysql) from 1.6.0 to 1.9.3.
- [Release notes](https://github.com/go-sql-driver/mysql/releases)
- [Changelog](https://github.com/go-sql-driver/mysql/blob/v1.9.3/CHANGELOG.md)
- [Commits](go-sql-driver/mysql@v1.6.0...v1.9.3)

---
updated-dependencies:
- dependency-name: github.com/go-sql-driver/mysql
  dependency-version: 1.9.3
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* feat: add swarm support to docker acquistion

* format

* merge issue

* test issue

* lint

* enhance: extract some functions for @mmetc

* test with regexp

* enhance: Handle invalid regexp instead of panic and add some test cases

* fix text + shorten error messages

* enhance: Disable context check

---------

Co-authored-by: marco <[email protected]>
Co-authored-by: Sebastien Blot <[email protected]>
* clean up buckets serialization code
120 seconds may not be enough to download data files.
This was never used outside testing, should not impact anyone.
If someone really used the feature, it's not compatible anyway with the
previous version and they'll get an error at runtime.
* dry root check

* dry plugin install

* log info, warnings to stderr
* cscli setup:

- remove redundant detect options, keep only --force and --ignore
- use gopsutil instead of osinfo - it can recognize derived distributions
- detect systemd units even if masked or disabled

The goal is to detect what's installed and potentially configurable,
regardless if it's running, temporary disabled or not yet configured

* lint

* rename UnitEnabled -> UnitInstalled

* detect.yaml

* change Path.Exists("/etc/...") -> Host.PlatformFamily == "..."
Bumps [docker/login-action](https://github.com/docker/login-action) from 3.4.0 to 3.5.0.
- [Release notes](https://github.com/docker/login-action/releases)
- [Commits](docker/login-action@74a5d14...184bdaa)

---
updated-dependencies:
- dependency-name: docker/login-action
  dependency-version: 3.5.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…0.3 (#3769)

Bumps [github.com/crowdsecurity/machineid](https://github.com/crowdsecurity/machineid) from 1.0.2 to 1.0.3.
- [Commits](crowdsecurity/machineid@v1.0.2...v1.0.3)

---
updated-dependencies:
- dependency-name: github.com/crowdsecurity/machineid
  dependency-version: 1.0.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Refactored the ~Queue~ type to introduce a new ~LocalQueue~ implementation and updated all references to use the new interface. This change ensures better type safety and flexibility in queue operations.

BREAKING CHANGE: The ~Queue~ type has been replaced with a new ~LocalQueue~ implementation, and a ~Queue~ interface has been introduced. This may require updates to any code directly interacting with the ~Queue~ type.
- Updated go.mod to include valkey-go dependency
- Replaced NewQueue with CreateQueue in types/queue.go for improved
  functionality
- Updated leakybucket/bucket.go to use the new CreateQueue function
  with hash parameter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants