Skip to content

Pangolin#65

Merged
hhftechnology merged 5 commits intomainfrom
pangolin
Mar 24, 2026
Merged

Pangolin#65
hhftechnology merged 5 commits intomainfrom
pangolin

Conversation

@hhftechnology
Copy link
Owner

Bouncer status fix

strausmann and others added 4 commits March 23, 2026 12:29
CrowdSec v1.7.x replaced the "valid" JSON field with "revoked: false"
in the bouncers list API response. The manager still reads "valid",
which no longer exists, causing all bouncers to show as "disconnected".

This fix reads the "revoked" field and derives Valid = !Revoked.
Falls back to treating the bouncer as valid if neither field is present.

Fixes #47
Address review feedback from Gemini and Copilot:
- Consolidate the validity check into one if/else-if/else block
- Check "revoked" first (new CrowdSec >= v1.7.x), fall back to "valid" (old versions)
- Remove redundant double-parsing of both fields
- Clearer control flow, no duplicate JSON lookups

Fixes #47
…ked field

Rework based on CrowdSec team feedback (Issue #47, @LaurenceJJones):
- "revoked" is always false and will never be used by CrowdSec
- CrowdSec deletes bouncers rather than revoking them
- A bouncer in the list is valid by definition

Changes:
- Remove Revoked field from Bouncer struct (unused by CrowdSec)
- Add CreatedAt and UpdatedAt fields for activity detection
- Set Valid = true for all listed bouncers (existence = valid)
- Determine status from last_pull with updated_at as fallback
  when last_pull is null (updated_at - created_at > 5s = has pulled)
- New "registered" status for bouncers that enrolled but never pulled
- Update BouncerStatusMonitor to show status instead of valid/invalid
- Add "registered" badge to Bouncers page

Status matrix:
| last_pull          | Status      |
|--------------------|-------------|
| < 5 min ago        | connected   |
| 5-60 min ago       | connected   |
| > 60 min ago       | stale       |
| null + updated_at  | connected   |
| null + just created| registered  |

Fixes #47
fix: derive bouncer Valid status from revoked field (CrowdSec >= v1.7.x)
@vercel
Copy link

vercel bot commented Mar 23, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
crowdsec-manager-docs Ready Ready Preview, Comment Mar 24, 2026 6:01am

@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the accuracy and granularity of bouncer status monitoring. By incorporating additional timestamp data and revising the logic for determining bouncer validity and activity, the system now provides a more reliable and informative overview of bouncer health, improving operational visibility.

Highlights

  • Refined Bouncer Status Calculation: The logic for determining bouncer status has been significantly improved, now utilizing last_pull, created_at, and updated_at timestamps for more accurate health reporting.
  • Enhanced Bouncer Data Model: New CreatedAt and UpdatedAt fields were added to the Bouncer data model to support the enhanced status determination.
  • Updated Frontend UI for Bouncer Status: The user interface has been updated to display more detailed bouncer statuses, including 'connected', 'stale', and 'registered', with appropriate visual indicators.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The pull request introduces CreatedAt and UpdatedAt fields to the Bouncer model and refactors bouncer status calculation in the backend to use a more robust lastActivity determination logic, considering both LastPull and UpdatedAt fields. This enables more granular bouncer statuses (e.g., "registered") which are then reflected in the frontend UI. A review comment highlights that the lastActivity logic is duplicated across two functions and suggests centralizing it into a models.Bouncer method for improved maintainability.

Comment on lines +121 to +125
lastActivity := b.LastPull
if lastActivity.IsZero() &&
b.UpdatedAt.After(b.CreatedAt.Add(5*time.Second)) {
lastActivity = b.UpdatedAt
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This logic to determine the lastActivity of a bouncer is duplicated from the parseBouncersJSON function (lines 66-70). To improve maintainability and avoid future inconsistencies, this logic should be centralized. A good approach would be to add a method to the models.Bouncer struct, like LastActivity() time.Time, to encapsulate this behavior. This would ensure that any future changes to this logic are made in only one place.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 904092ac5f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +67 to +68
if lastActivity.IsZero() &&
bouncer.UpdatedAt.After(bouncer.CreatedAt.Add(5*time.Second)) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Guard updated_at fallback when created_at is missing

The fallback condition treats updated_at as activity even when created_at was not parsed, because zero-time CreatedAt makes UpdatedAt.After(CreatedAt.Add(5*time.Second)) true for any real timestamp. In environments where created_at is omitted or unparsable but updated_at is present, bouncers with no last_pull will be misclassified as active (connected/stale) instead of registered, which overstates connectivity. Require parsed created_at (and non-zero updated_at) before applying this fallback.

Useful? React with 👍 / 👎.

@hhftechnology hhftechnology merged commit 1aad7ec into main Mar 24, 2026
8 checks passed
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